Sovite.Cluster.Joiner (sovite v0.6.0)

Copy Markdown View Source

Keeps joining known peers (Sovite.Cluster.Peer), and reports nodes coming and going. Start it once Sovite.Cluster.start/1 returned.

children = [
  {Sovite.Cluster.Joiner, peers: [peer1, peer2], interval: 10_000}
]

Every :interval milliseconds, it joins the peers this node is not connected to. A cluster forms when every node knows at least one other; nodes learn the rest from each other. Peers that are down are tried again on the next round.

Options

  • :peers - Sovite.Cluster.Peer structs, or name@host:port strings, parsed (and their hosts resolved) on each round. Defaults to none.
  • :port - the port of peers given as strings without one. Defaults to 4370.
  • :interval - milliseconds between rounds. Defaults to 10 seconds.
  • :name - a registered name, or nil for none (the default).

Telemetry

  • [:sovite, :cluster, :node, :up] - %{}, %{node}, when a connection to a node opens.
  • [:sovite, :cluster, :node, :down] - %{}, %{node}, when the last connection to a node closes.
  • [:sovite, :cluster, :join, :error] - %{}, %{peer, reason}, when joining a peer fails at once, or a peer string does not parse.

Summary

Functions

Replaces the peers to join.

Starts the joiner.

Functions

set_peers(server, peers)

@spec set_peers(GenServer.server(), [Sovite.Cluster.Peer.t() | String.t()]) :: :ok

Replaces the peers to join.

start_link(opts)

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

Starts the joiner.