WebsockexNova.ConnectionRegistry (WebsockexNova v0.1.1)

View Source

Registry for WebSocket connection information.

This registry maps connection IDs to transport PIDs, allowing transparent reconnection without requiring client code to update connection references.

The registry is used internally by the library to maintain a stable reference to connection processes even when the underlying transport process changes during reconnection.

Summary

Functions

Returns a specification to start this module under a supervisor. See Supervisor.child_spec/2 for details.

Get the current transport_pid for a connection_id.

Register a connection_id with a transport_pid. If the connection_id is already registered, it updates the association.

Start the connection registry. Should be called by the application supervisor.

Unregister a connection_id from the registry.

Updates the transport_pid for an existing connection_id. This is typically used during reconnection when the transport process changes.

Functions

child_spec(args)

Returns a specification to start this module under a supervisor. See Supervisor.child_spec/2 for details.

get_transport_pid(connection_id)

Get the current transport_pid for a connection_id.

Returns {:ok, pid} if found, or {:error, :not_found} if not found.

register(connection_id, transport_pid)

Register a connection_id with a transport_pid. If the connection_id is already registered, it updates the association.

Returns :ok.

start_link(args \\ [])

Start the connection registry. Should be called by the application supervisor.

unregister(connection_id)

Unregister a connection_id from the registry.

Returns :ok regardless of whether the connection_id was registered.

update_transport_pid(connection_id, new_transport_pid)

Updates the transport_pid for an existing connection_id. This is typically used during reconnection when the transport process changes.

Returns :ok if the update was successful, or {:error, :not_found} if the connection_id was not found.