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

Copy Markdown

Behaviour for implementing custom performance monitoring hooks.

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

Summary

Callbacks

Handle a hook point execution.

Initialize the hook provider.

Clean up resources when the hook provider is unregistered.

Types

context()

@type context() :: map()

hook_fn()

@type hook_fn() :: (context() -> context())

hook_point()

@type hook_point() :: atom()

Callbacks

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.

init(opts)

@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}.

terminate(reason, state)

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

Clean up resources when the hook provider is unregistered.