partisan_peer_discovery_agent behaviour (partisan v6.3.0)

View Source

This state machine polls a discovery backend (the callback module) and joins the peers it reports.

A discovery answer is a hint for joining, never a membership authority: the agent only ever adds peers, through partisan_peer_service:add_members/1. A member the backend stops reporting stays a member; a node leaves the cluster only through partisan_peer_service:leave/0,1. The reason is that every backend answers from a readiness- or health-gated, eventually consistent source (DNS, an orchestrator's endpoint list), which omits a node that is booting or briefly unhealthy. Treating that omission as a departure removed the node from the membership and gossiped the removal, and the node then shut its own peer service down on receiving it ("membership doesn't contain us") — once per poll, for as long as it stayed out of the answer. Pinned by partisan_peer_discovery_agent_test and partisan_SUITE:discovery_never_evicts_test/1.

Summary

Callbacks

init/1

-callback init(Opts :: map()) -> {ok, State :: any()} | {error, Reason :: any()}.

lookup/2

-callback lookup(State :: any(), Timeout :: timeout()) ->
                    {ok, [partisan:node_spec()], NewState :: any()} |
                    {error, Reason :: any(), NewState :: any()}.

Functions

callback_mode()

code_change(OldVsn, StateName, State, Extra)

disable()

-spec disable() -> ok.

disabled(EventType, EventContent, State)

enable()

-spec enable() -> ok.

enabled(EventType, EventContent, State)

In this state the agent uses the callback module to discover peers by calling its lookup/2 callback.

init(_)

lookup()

start()

-spec start() -> {ok, pid()} | ignore | {error, term()}.

start_link()

-spec start_link() -> {ok, pid()} | ignore | {error, term()}.

status()

-spec status() -> enabled | disabled.

terminate(Reason, StateName, State)