View Source ProcessHub.Strategy.Distribution.Guided (ProcessHub v0.4.0-beta)
Provides implementation for distribution behaviour using consistent hashing.
This strategy expects the child mappings to be provided during process start-up initialization. The child mappings are used to determine the nodes and processes mapping.
Bounded processes
Guided distribution strategy does not support process migration. If a node goes down, the processes will not be migrated to other nodes. They are bound to the nodes specified in the child mappings.
Guided distribution strategy is useful when you want to have more control over the distribution of processes. For example, you can use it to ensure that processes are started on specific nodes.
Required mappings
When using Guided distribution strategy, you must provide the child mappings during the initialization. If the child mappings are not provided, the initialization will fail.
Example:
iex> child_spec = %{id: :my_child, start: {MyProcess, :start_link, [nil]}} iex> ProcessHub.start_children(:my_hub, [child_spec], [child_mapping: %{my_child: [:node1, :node2]}])
Summary
Types
@type t() :: %ProcessHub.Strategy.Distribution.Guided{}
Functions
@spec handle_children_start(ProcessHub.Hub.t(), %{ :start_opts => keyword(), optional(any()) => any() }) :: :ok
@spec insert_child_mappings(ProcessHub.Hub.t(), any()) :: :ok