View Source ProcessHub.Service.Synchronizer (ProcessHub v0.6.0)

The synchronizer service provides API functions for synchronizing process registry data between nodes.

Summary

Functions

Appends remote data to the local process registry.

Broadcasts local registry data to the specified target nodes.

Returns {:ok, data} to broadcast, or :suppress.

Detaches remote data from the local process registry.

Returns local node's process registry data used for synchronization.

Helper function to trigger interval synchronization.

Functions

Link to this function

append_data(hub, remote_data)

View Source
@spec append_data(ProcessHub.Hub.t(), %{
  required(node()) => [
    {ProcessHub.child_spec(), pid(), ProcessHub.child_metadata()}
  ]
}) :: :ok

Appends remote data to the local process registry.

Link to this function

broadcast_local_registry(state, target_nodes)

View Source
@spec broadcast_local_registry(ProcessHub.Hub.t(), [node()]) :: :ok

Broadcasts local registry data to the specified target nodes.

Called when new nodes join the cluster to share local process information.

Link to this function

broadcastable_local_data(hub)

View Source
@spec broadcastable_local_data(ProcessHub.Hub.t()) ::
  {:ok, [{ProcessHub.child_spec(), pid(), ProcessHub.child_metadata()}]}
  | :suppress

Returns {:ok, data} to broadcast, or :suppress.

A node that has hosted no local child since boot returns an empty local_sync_data/1; broadcasting it would make peers' detach_data/2 treat the node as authoritatively empty and wipe its records. We suppress that empty until the node has hosted a child at least once (latched in storage.misc, which resets on restart). A node that legitimately drained its children is already latched, so it still broadcasts its empty and peers reconcile.

Link to this function

detach_data(hub, remote_children)

View Source
@spec detach_data(ProcessHub.Hub.t(), %{
  required(node()) => [{ProcessHub.child_spec(), pid()}]
}) :: :ok

Detaches remote data from the local process registry.

Link to this function

exec_interval_sync(hub_id, strategy, sync_data, remote_node)

View Source
@spec local_sync_data(ProcessHub.Hub.t()) :: [
  {ProcessHub.child_spec(), pid(), ProcessHub.child_metadata()}
]

Returns local node's process registry data used for synchronization.

Helper function to trigger interval synchronization.

The system will use the configured synchronization strategy.