Documentation ¶
Overview ¶
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.
Index ¶
- func Decode(in string) (string, []string)
- func DeserializeHooksFromOptions(ctx context.Context)
- func EnableHook(name string, args ...string) error
- func Encode(name string, opts []string) string
- func IsEnabled(name string) (bool, []string)
- func RegisterHook(name string, h HookFactory)
- func RunInitHooks(ctx context.Context) (context.Context, error)
- func RunRequestHooks(ctx context.Context, req *fnpb.InstructionRequest) context.Context
- func RunResponseHooks(ctx context.Context, req *fnpb.InstructionRequest, ...)
- func SerializeHooksToOptions()
- type Hook
- type HookFactory
- type InitHook
- type RequestHook
- type ResponseHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
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.
func DeserializeHooksFromOptions ¶
DeserializeHooksFromOptions extracts the hook configuration information from the options and configures the hooks with the supplied options.
func EnableHook ¶
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.
func Encode ¶
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.
func RegisterHook ¶
func RegisterHook(name string, h HookFactory)
RegisterHook registers a Hook for the supplied identifier.
func RunInitHooks ¶
RunInitHooks runs the init hooks.
func RunRequestHooks ¶
RunRequestHooks runs the hooks that handle a FnAPI request.
func RunResponseHooks ¶
func RunResponseHooks(ctx context.Context, req *fnpb.InstructionRequest, resp *fnpb.InstructionResponse)
RunResponseHooks runs the hooks that handle a FnAPI response.
func SerializeHooksToOptions ¶
func SerializeHooksToOptions()
SerializeHooksToOptions serializes the activated hooks and their configuration into a JSON string that can be deserialized later by the runner.
Types ¶
type Hook ¶
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.
type HookFactory ¶
HookFactory is a function that produces a Hook from the supplied arguments.
type RequestHook ¶
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 ¶
type ResponseHook func(context.Context, *fnpb.InstructionRequest, *fnpb.InstructionResponse) error
ResponseHook is called when sending a FnAPI instruction response.