View Source ProcessHub.Strategy.Distribution.Guided (ProcessHub v0.2.0-alpha)

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.

When processes are started using Guided distribution strategy, they will be bound to the nodes specified in the child mappings. If the node goes down, the processes won't be migrated to other nodes. They will stay on the same node until the node is restarted.

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, []}}
iex> ProcessHub.start_children(:my_hub, [child_spec], [child_mapping: %{my_child: [:node1, :node2]}])

Summary

Types

@type t() :: %ProcessHub.Strategy.Distribution.Guided{}

Functions

@spec cache_key() :: :guided_distribution_cache
Link to this function

handle_children_start(hub_id, map)

View Source
@spec handle_children_start(ProcessHub.hub_id(), %{
  :start_opts => keyword(),
  optional(any()) => any()
}) ::
  :ok
Link to this function

insert_child_mappings(hub_id, child_mappings)

View Source
@spec insert_child_mappings(ProcessHub.hub_id(), any()) :: :ok