View Source ProcessHub.Strategy.Migration.Base protocol (ProcessHub v0.5.0-beta)

The migration strategy protocol provides API functions for migrating child processes.

Summary

Types

t()

All the types that implement this protocol.

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

Link to this function

handle_topology_contraction(struct, hub, removed_nodes, handler)

View Source
@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 struct
  • hub - the hub state
  • removed_nodes - list of nodes that have left the cluster
  • handler - the NodeDown handler struct

Returns

Updated handler struct with any additional data computed during processing.

Link to this function

handle_topology_expansion(struct, hub, nodes, handler)

View Source
@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 struct
  • hub - the hub state
  • nodes - list of nodes that have joined the cluster
  • handler - 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.