The seam between "one node" and "many nodes".
Everything that has to be shared between servers goes through this
behaviour; everything per-connection (the websocket process, its local
Registry entry) stays local on every node.
PusherServer.Backend.Local— in-memory, zero dependencies. The default.PusherServer.Backend.Redis— shares broadcasts, presence and channel occupancy between nodes through Redis. Enabled by setting:redis_url/PUSHER_REDIS_URL.
Callers don't use a backend directly — they go through PusherServer.Cluster.
Summary
Callbacks
Called right after a local socket subscribed. true if the channel just became occupied cluster-wide.
Called right after a local socket left. true if the channel just became vacant cluster-wide.
Extra children to supervise for this backend (connections, subscribers, ...).
Names of every channel that currently has at least one subscriber, cluster-wide.
Returns true if this is the first connection for user_id on the channel (cluster-wide).
Unique members as {user_id, user_info} pairs.
Returns {is_last_connection_for_user, user_id}, or {false, nil} if the socket wasn't tracked.
Re-records an already announced presence entry, silently and idempotently.
Called by a socket after the shared store lost its data (see
PusherServer.Backend.Redis.Janitor). Never announces anything.
Propagate an already-encoded message to the other nodes. The sending node has already delivered it to its own local subscribers.
Total subscribers on a channel across the cluster.
Types
Callbacks
Called right after a local socket subscribed. true if the channel just became occupied cluster-wide.
Called right after a local socket left. true if the channel just became vacant cluster-wide.
@callback child_specs(name(), PusherServer.Config.t()) :: [Supervisor.child_spec()]
Extra children to supervise for this backend (connections, subscribers, ...).
Names of every channel that currently has at least one subscriber, cluster-wide.
Returns true if this is the first connection for user_id on the channel (cluster-wide).
Unique members as {user_id, user_info} pairs.
Returns {is_last_connection_for_user, user_id}, or {false, nil} if the socket wasn't tracked.
Re-records an already announced presence entry, silently and idempotently.
Called by a socket after the shared store lost its data (see
PusherServer.Backend.Redis.Janitor). Never announces anything.
@callback publish( name(), channel(), encoded :: String.t(), exclude_socket_id :: String.t() | nil ) :: :ok
Propagate an already-encoded message to the other nodes. The sending node has already delivered it to its own local subscribers.
@callback subscription_count(name(), channel()) :: non_neg_integer()
Total subscribers on a channel across the cluster.