View Source ProcessHub.Strategy.Migration.MigrationConsent behaviour (ProcessHub v0.6.0)
Opt-in migration consent, enabled by setting consent_settings on the
HotSwap or ColdSwap migration strategy.
Before migrating a participating child, the hub asks the process whether it
may be moved. :ready migrates it through the regular migration path;
:defer (or no reply within :consent_timeout) parks it in the deferred
list, retried every :retry_interval and force-migrated after
:max_defer_time. ProcessHub.Service.Migration.migration_ready/2 signals
readiness early.
Participating processes use this module:
defmodule MyServer do
use GenServer
use ProcessHub.Strategy.Migration.MigrationConsent
# Optional override, defaults to :ready.
def migration_consent(state), do: if(state.busy?, do: :defer, else: :ready)
endConsent covers the primary instance only; Replication-managed replicas are
unaffected. Detection reads the child spec start module, so processes
started through wrapper modules migrate immediately. Forced migration uses
the best-effort handover path, so prepare_handover_state should return
resumable progress.
Summary
Types
:consent_timeout- shared deadline for consent replies (default: 5000):retry_interval- deferred-migration retry interval (default: 10000):max_defer_time- max deferral before forced migration (default: 600000)
Callbacks
Returns whether the process consents to being migrated right now.
Functions
Returns whether the child spec's start module participates in consent.
Types
@type t() :: %ProcessHub.Strategy.Migration.MigrationConsent{ consent_timeout: pos_integer(), max_defer_time: pos_integer(), retry_interval: pos_integer() }
:consent_timeout- shared deadline for consent replies (default: 5000):retry_interval- deferred-migration retry interval (default: 10000):max_defer_time- max deferral before forced migration (default: 600000)
Callbacks
@callback migration_consent(state :: term()) :: :ready | :defer
Returns whether the process consents to being migrated right now.
Functions
@spec participates?(ProcessHub.child_spec()) :: boolean()
Returns whether the child spec's start module participates in consent.