ClusterHelper.PullEngine (ClusterHelper v1.0.1)

Copy Markdown View Source

Coordinates background pull operations for cluster synchronisation.

Manages async tasks that pull role data from remote nodes, using generation-based change detection to minimise unnecessary RPC traffic.

Summary

Functions

Starts background pulls from all connected nodes for the given scope.

Pulls roles from a newly discovered node, discovering matching scopes first.

Functions

pull_all(server, scope)

@spec pull_all(pid(), atom()) :: :ok

Starts background pulls from all connected nodes for the given scope.

Each pull runs in a separate Task via Task.Supervisor, and results are sent back to server as {:pull_update_node, scope, node, roles}.

pull_all_with_generation_check(server, scope, remote_generations)

@spec pull_all_with_generation_check(pid(), atom(), %{optional(atom()) => map()}) ::
  :ok

Generation-aware periodic pull.

For each live node, checks the remote generation first. Only does a full role pull when the generation has changed. Also detects and reports stale nodes (in ETS but no longer in Node.list()).

Results are sent back as:

  • {:pull_update_node, scope, node, roles, gen} — generation known
  • {:pull_update_node, scope, node, roles} — fallback, no generation
  • {:stale_node, scope, node} — node no longer in cluster

pull_new_node(server, remote_node, local_scopes)

@spec pull_new_node(pid(), node(), MapSet.t(atom())) :: :ok

Pulls roles from a newly discovered node, discovering matching scopes first.