View Source ProcessHub.Strategy.Migration.Base protocol (ProcessHub v0.5.0-beta)
The migration strategy protocol provides API functions for migrating child processes.
Summary
Functions
Handles migration when nodes leave the cluster (topology contraction).
Handles migration when nodes join the cluster (topology expansion).
Triggered when coordinator is initialized.
Types
@type t() :: term()
All the types that implement this protocol.
Functions
@spec handle_topology_contraction( struct :: t(), hub :: ProcessHub.Hub.t(), removed_nodes :: [node()], handler :: ProcessHub.Task.ClusterUpdateTask.NodeDown.t() ) :: ProcessHub.Task.ClusterUpdateTask.NodeDown.t()
Handles migration when nodes leave the cluster (topology contraction).
Called from NodeDown handler to redistribute processes from removed nodes. Each strategy implementation handles its own logic for starting processes that should now be on the local node.
Parameters
struct- the strategy structhub- the hub stateremoved_nodes- list of nodes that have left the clusterhandler- the NodeDown handler struct
Returns
Updated handler struct with any additional data computed during processing.
@spec handle_topology_expansion( struct :: t(), hub :: ProcessHub.Hub.t(), nodes :: [node()], handler :: ProcessHub.Task.ClusterUpdateTask.NodeUp.t() ) :: ProcessHub.Task.ClusterUpdateTask.NodeUp.t()
Handles migration when nodes join the cluster (topology expansion).
Called from NodeUp handler to redistribute processes to newly joined nodes. Each strategy implementation handles its own logic for migrating processes that should now be on the new nodes.
Parameters
struct- the strategy structhub- the hub statenodes- list of nodes that have joined the clusterhandler- the NodeUp handler struct
Returns
Updated handler struct with any additional data computed during processing.
@spec init( struct(), ProcessHub.Hub.t() ) :: struct()
Triggered when coordinator is initialized.
Could be used to perform initialization.