Selecto.Performance.HookBehaviour behaviour (Selecto v0.3.8)

Behaviour for implementing custom performance monitoring hooks.

Modules implementing this behaviour can be used as hook providers for the Selecto performance monitoring system.

Link to this section Summary

Callbacks

Handle a hook point execution.

Initialize the hook provider.

Clean up resources when the hook provider is unregistered.

Link to this section Types

@type context() :: map()
@type hook_fn() :: (context() -> context())
Link to this type

hook_point()

@type hook_point() :: atom()

Link to this section Callbacks

Link to this callback

handle_hook(hook_point, context, state)

@callback handle_hook(hook_point(), context(), state :: term()) :: context()

Handle a hook point execution.

Receives the hook point name, current context, and provider state. Should return an updated context.

@callback init(opts :: keyword()) :: {:ok, term()} | {:error, term()}

Initialize the hook provider.

Called once when the hook provider is registered. Should return {:ok, state} or {:error, reason}.

Link to this callback

terminate(reason, state)

(optional)
@callback terminate(reason :: term(), state :: term()) :: :ok

Clean up resources when the hook provider is unregistered.