Opt-in ETS connection tracking, without a GenServer.
Maps a caller-chosen connection id to a Gun pid in a public named ETS table
(:zen_websocket_connections), monitoring each pid so dead connections can be
swept. The table is created lazily by init/0 and every other function assumes
it exists — call init/0 once (typically from your application start) before
registering.
ZenWebsocket.Client does not use this registry; it is a utility for consumers
that want to look connections up by a stable id.
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
shutdown | 0 | Drop all monitors and delete the registry ETS table. | - |
cleanup_dead | 1 | Remove every registration pointing at a dead Gun pid. | gun_pid: value |
get | 1 | Look up the Gun pid registered for a connection id. | connection_id: value |
deregister | 1 | Remove a connection by id and drop its monitor. | connection_id: value |
register | 2 | Register a connection id against a Gun pid and monitor the pid. | connection_id: value, gun_pid: value |
init | 0 | Create the connection registry ETS table if it does not exist. | - |
Summary
Functions
Cleanup dead connection by PID.
Deregister a connection by ID.
Get connection info by ID.
Initialize the connection registry ETS table.
Register a connection with monitoring.
Cleanup all connections and destroy table.
Functions
@spec cleanup_dead(pid()) :: :ok
Cleanup dead connection by PID.
@spec deregister(String.t()) :: :ok
Deregister a connection by ID.
Get connection info by ID.
@spec init() :: :ok
Initialize the connection registry ETS table.
Register a connection with monitoring.
@spec shutdown() :: :ok
Cleanup all connections and destroy table.