View Source ProcessHub.Strategy.Redundancy.Base protocol (ProcessHub v0.5.0-beta)
The redundancy protocol relies on the HashRing library to distribute processes across
the cluster and determine which node should be responsible for a given process by its child_id key.
It is possible to start the same process on multiple nodes in the cluster.
Summary
Functions
Handles redundancy when nodes join or leave the cluster.
Triggered when coordinator is initialized.
Returns the master node that the given child_id belongs to.
Returns the replication factor for the given strategy struct. This is the number of replicas that the process will be started with.
Types
@type t() :: term()
All the types that implement this protocol.
Functions
@spec handle_redundancy( struct(), ProcessHub.Hub.t(), calculated_cids :: %{required(ProcessHub.child_id()) => [node()]}, nodes :: [node()] ) :: :ok
Handles redundancy when nodes join or leave the cluster.
For Replication strategy:
- Starts/stops replicas locally (indices 1+ from calculated_cids)
- Sends mode signals (active/passive transitions)
Note: Primary process starting/stopping is handled by migration strategy.
Parameters
strategy- the redundancy strategy structhub- the hub statecalculated_cids- map of child_id => [node()] from migration strategy.Index 0 = primary, indices 1+ = replicasnodes- list of nodes that triggered redistribution
@spec init( struct(), ProcessHub.Hub.t() ) :: struct()
Triggered when coordinator is initialized.
Could be used to perform initialization.
@spec master_node(struct(), ProcessHub.Hub.t(), ProcessHub.child_id(), [node()]) :: node()
Returns the master node that the given child_id belongs to.
@spec replication_factor(struct()) :: pos_integer()
Returns the replication factor for the given strategy struct. This is the number of replicas that the process will be started with.