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

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

Summary

Functions

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

Dispatches multiple hooks to the registered handlers.

Returns all registered hook handlers for the given hook key

Types

@type hook_handler() :: {module(), atom(), [any()]}
@type hook_handlers() :: %{required(hook_key()) => [hook_handler()]}
@type hook_key() ::
  :pre_cluster_join_hook
  | :post_cluster_join_hook
  | :pre_cluster_leave_hook
  | :post_cluster_leave_hook
  | :registry_pid_insert_hook
  | :registry_pid_remove_hook
  | :children_migrated_hook
  | :forwarded_migration_hook
  | :priority_state_updated_hook
  | :pre_nodes_redistribution_hook
  | :post_nodes_redistribution_hook
  | :pre_children_start_hook

Functions

Link to this function

dispatch_hook(hub_id, hook_key, hook_data)

View Source
@spec dispatch_hook(ProcessHub.hub_id(), hook_key(), any()) :: :ok

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_handler()]) :: :ok

Dispatches multiple hooks to the registered handlers.

Link to this function

register_hook_handlers(hub_id, hook_key, hook_handlers)

View Source
@spec register_hook_handlers(ProcessHub.hub_id(), hook_key(), [hook_handler()]) ::
  {atom(), boolean()}

Registers a new hook handler.

Link to this function

registered_handlers(hub_id, hook_key)

View Source
@spec registered_handlers(ProcessHub.hub_id(), hook_key()) :: [hook_handler()]

Returns all registered hook handlers for the given hook key