View Source ProcessHub.Service.HookManager (ProcessHub v0.7.0)
The hook manager service provides API functions for managing hook dispatching, registration, and lookup.
Summary
Functions
Cancels a hook handler.
Executes the hook handlers and lets each handler modify the hook data.
Dispatches the hook to the registered handlers and passes the hook data as an argument.
Dispatches the hook synchronously, awaiting each handler's reply before moving to the next, so a handler can block the caller until its own prerequisites are ready.
Dispatches multiple hooks to the registered handlers.
Registers a new hook handler.
Registers a new hook handlers.
Returns all registered hook handlers for the given hook key
Types
@type handler_priority() :: integer()
@type hook_key() :: atom()
@type t() :: %ProcessHub.Service.HookManager{ a: [any()], f: atom(), id: handler_id(), m: module(), p: handler_priority() | nil }
Functions
@spec cancel_handler(:ets.tid(), hook_key(), handler_id()) :: :ok
Cancels a hook handler.
Executes the hook handlers and lets each handler modify the hook data.
It is possible to register a hook handler with a wildcard argument :_ which
will be replaced with the hook data when the hook is dispatched.
Works similar to dispatch_hook/3 but each handler is expected to return the modified
hook data. The hook data is passed to the next handler in the chain.
Dispatches the hook to the registered handlers and passes the hook data as an argument.
It is possible to register a hook handler with a wildcard argument :_ which
will be replaced with the hook data when the hook is dispatched.
dispatch_hook_blocking(hook_table, hook_key, hook_data, total_timeout_ms)
View Source@spec dispatch_hook_blocking(:ets.tid(), hook_key(), any(), pos_integer()) :: :ok
Dispatches the hook synchronously, awaiting each handler's reply before moving to the next, so a handler can block the caller until its own prerequisites are ready.
Handlers run in registered order under a shared total_timeout_ms budget; each
gets whatever remains of it. Every handler is isolated: one that raises,
throws, crashes, or outruns its slice is logged at WARN and the dispatch
continues, so a misbehaving handler can neither crash the caller nor hang it
past the budget.
Dispatches multiple hooks to the registered handlers.
Registers a new hook handler.
@spec register_handlers(:ets.tid(), hook_key(), [t()]) :: :ok | {:error, {:handler_id_not_unique, [handler_id()]}}
Registers a new hook handlers.
Returns all registered hook handlers for the given hook key