SaltDns.Shaker.Presence (Salt v1.0.0)

Which Shaker connections are open, on any replica.

The project does not use Phoenix.Presence/Phoenix.Tracker, so this is built on OTP's own :pg (process groups), which is distributed with the cluster: a process joins a group named after the node id, and connected?/1 asks every connected replica. It answers "right now", which is why connection state is not a database column (SaltDns.Shaker.Node).

Started only while the Shaker switch is on. One connection per node is expected; more than one is still "connected".

Summary

Functions

True when any replica has a connection for node_id.

The number of nodes with at least one open connection, cluster-wide.

Registers the calling connection as connected for node_id.

Removes the calling connection from node_id's group.

Functions

connected?(node_id)

@spec connected?(String.t()) :: boolean()

True when any replica has a connection for node_id.

connected_count()

@spec connected_count() :: non_neg_integer()

The number of nodes with at least one open connection, cluster-wide.

join(node_id)

@spec join(String.t()) :: :ok

Registers the calling connection as connected for node_id.

leave(node_id)

@spec leave(String.t()) :: :ok

Removes the calling connection from node_id's group.