SwimEx. Protocol
(SwimEx v0.1.0)
View Source
SWIM+INF+Susp protocol state machine.
Owns all membership state, the gossip queue, pending ping tracking, and suspicion timers. The Transport process owns the socket; this GenServer drives everything else.
Message flow
Period fires → pick probe target T
→ send ping(seq) to T
→ wait ping_timeout
ping_timeout fires (no direct ack)
→ send ping_req(seq, target=T) to k random nodes
→ wait ping_timeout again (indirect)
indirect_timeout fires (no indirect ack)
→ gossip suspect(T, inc)
→ start suspicion timer
suspicion_timeout fires
→ gossip dead(T, inc)Acks at any stage cancel the relevant timer and update membership. A suspect node can refute by sending alive(self, inc+1).
Summary
Functions
Returns a specification to start this module under a supervisor.
Notifies the cluster that this node is leaving and stops the process.
Returns current cluster members.
Starts the SWIM protocol GenServer.
Subscribes a process to membership events.
Unsubscribes a process from membership events.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec leave(GenServer.server()) :: :ok
Notifies the cluster that this node is leaving and stops the process.
@spec members( GenServer.server(), keyword() ) :: [ {String.t(), :inet.port_number(), String.t(), SwimEx.Membership.status(), non_neg_integer()} ]
Returns current cluster members.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the SWIM protocol GenServer.
@spec subscribe(GenServer.server(), pid()) :: :ok
Subscribes a process to membership events.
@spec unsubscribe(GenServer.server(), pid()) :: :ok
Unsubscribes a process from membership events.