View Source ProcessHub.Service.HookManager (ProcessHub v0.1.1-alpha)

The hook manager service provides API functions for managing hook dispatching, registration, and lookup.

Summary

Functions

Returns the cache key for the hook manager.

Dispatches the hook to the registered handlers and passes the hook data as an argument.

Dispatches multiple hooks to the registered handlers.

Registers a new hook handler.

Returns all registered hook handlers sorted by hook key.

Types

@type hook() :: {module(), atom(), [any()]}
@type hook_key() :: atom()
@type hooks() :: %{required(hook_key()) => [hook()]}

Functions

@spec cache_key() :: :hooks

Returns the cache key for the hook manager.

Link to this function

dispatch_hook(hub_id, hook_key, hook_data)

View Source
@spec dispatch_hook(ProcessHub.hub_id() | :ets.tid(), hook_key(), any()) ::
  {:ok, pid()}

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.

Link to this function

dispatch_hooks(hub_id, hooks)

View Source
@spec dispatch_hooks(ProcessHub.hub_id(), [hook()]) :: :ok | {:ok, pid()}

Dispatches multiple hooks to the registered handlers.

Link to this function

register_handler(hub_id, hook_key, hook)

View Source
@spec register_handler(ProcessHub.hub_id() | :ets.tid(), hook_key(), hook()) :: true

Registers a new hook handler.

Link to this function

registered_handlers(hub_id)

View Source
@spec registered_handlers(ProcessHub.hub_id() | :ets.tid()) :: hooks()

Returns all registered hook handlers sorted by hook key.