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

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

leave(name)

@spec leave(GenServer.server()) :: :ok

Notifies the cluster that this node is leaving and stops the process.

members(name, opts)

Returns current cluster members.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts the SWIM protocol GenServer.

subscribe(name, pid)

@spec subscribe(GenServer.server(), pid()) :: :ok

Subscribes a process to membership events.

unsubscribe(name, pid)

@spec unsubscribe(GenServer.server(), pid()) :: :ok

Unsubscribes a process from membership events.