import "github.com/apache/beam/sdks/go/pkg/beam/core/util/hooks"
Package hooks allows runners to tailor execution of the worker harness.
Examples of customization:
gRPC integration session recording profile recording
Registration methods for hooks must be called prior to calling beam.Init() Request methods for hooks must be called as part of building the pipeline request for the runner's Execute method.
Decode decodes a hook name and its arguments from a single string. This is a convenience function for users of this package that are composing hooks.
DeserializeHooksFromOptions extracts the hook configuration information from the options and configures the hooks with the supplied options.
EnableHook enables the hook to be run for the pipline. It will be receive the supplied args when the pipeline executes. It is safe to enable the same hook with different options, as this is necessary if a hook wants to compose behavior.
Encode encodes a hook name and its arguments into a single string. This is a convenience function for users of this package that are composing hooks.
IsEnabled returns true and the registered options if the hook is already enabled.
func RegisterHook(name string, h HookFactory)
RegisterHook registers a Hook for the supplied identifier.
RunInitHooks runs the init hooks.
RunRequestHooks runs the hooks that handle a FnAPI request.
func RunResponseHooks(ctx context.Context, req *fnpb.InstructionRequest, resp *fnpb.InstructionResponse)
RunResponseHooks runs the hooks that handle a FnAPI response.
func SerializeHooksToOptions()
SerializeHooksToOptions serializes the activated hooks and their configuration into a JSON string that can be deserialized later by the runner.
type Hook struct { // Init is called once at the startup of the worker prior to // connecting to the FnAPI services. Init InitHook // Req is called each time the worker handles a FnAPI instruction request. Req RequestHook // Resp is called each time the worker generates a FnAPI instruction response. Resp ResponseHook }
A Hook is a set of hooks to run at various stages of executing a pipeline.
HookFactory is a function that produces a Hook from the supplied arguments.
InitHook is a hook that is called when the harness initializes.
RequestHook is called when handling a FnAPI instruction. It can return an updated context to pass additional information to downstream callers, or return the original context provided.
type ResponseHook func(context.Context, *fnpb.InstructionRequest, *fnpb.InstructionResponse) error
ResponseHook is called when sending a FnAPI instruction response.
Package hooks imports 9 packages (graph) and is imported by 5 packages. Updated 2019-06-13. Refresh now. Tools for package owners.