Gamend.Presence (gamend_core v1.0.1192)

Copy Markdown View Source

Cluster-wide tracking of who is connected where.

Backed by Phoenix.Presence, so entries are tied to process liveness and replicated between nodes by CRDT: a node that dies takes its entries with it, with no sweeper to notice. That is the property node-local ETS and database flags both lack.

Used for signaling room membership and lobby spectators. Not for anything queried in SQL — presence lives in memory and cannot be joined against a table — and not for anything durable, since a full cluster restart empties it.

During a netsplit each side sees only its own members until they heal.

Summary

Functions

Callback implementation for Phoenix.Presence.fetch/2.

Whether the calling process holds this user's only tracked socket.

Callback implementation for Phoenix.Presence.list/1.

Callback implementation for Phoenix.Presence.track/3.

Callback implementation for Phoenix.Presence.untrack/2.

Number of topics connected users are spread over.

Topic this user is tracked on.

Functions

child_spec(opts)

fetch(topic, presences)

Callback implementation for Phoenix.Presence.fetch/2.

fetchers_pids()

get_by_key(topic, key)

Callback implementation for Phoenix.Presence.get_by_key/2.

last_socket?(user_id)

@spec last_socket?(Ecto.UUID.t()) :: boolean()

Whether the calling process holds this user's only tracked socket.

Cluster-wide, unlike the per-node registry count it replaces.

list(topic)

Callback implementation for Phoenix.Presence.list/1.

track(socket, key, meta)

Callback implementation for Phoenix.Presence.track/3.

track(pid, topic, key, meta)

Callback implementation for Phoenix.Presence.track/4.

untrack(socket, key)

Callback implementation for Phoenix.Presence.untrack/2.

untrack(pid, topic, key)

Callback implementation for Phoenix.Presence.untrack/3.

update(socket, key, meta)

Callback implementation for Phoenix.Presence.update/3.

update(pid, topic, key, meta)

Callback implementation for Phoenix.Presence.update/4.

users_buckets()

@spec users_buckets() :: pos_integer()

Number of topics connected users are spread over.

users_topic(user_id)

@spec users_topic(Ecto.UUID.t()) :: String.t()

Topic this user is tracked on.