Supervisor and dispatcher for sharded STUN/TURN control workers.
What problem this solves
STUN/TURN control handling mutates per-request %Conn{} state and must stay
ordered per client endpoint. Hashing {client_ip, client_port} to a fixed
worker serializes that client's requests without a global lock while still
using multiple cores across clients.
Internal note
dispatch/2 is called from socket handlers when a frame is classified as
control-plane traffic.
RFCs
- RFC 5766 (TURN control transactions)
Summary
Functions
Returns a specification to start this module under a supervisor.
Casts frame to the worker shard for meta.client_ip / meta.client_port.
Configured pool size (:client_worker_pool_size or scheduler count).
Starts the worker pool supervisor (registered as __MODULE__).
Shard index for a client five-tuple (same hash as dispatch/2).
Registered module atom for worker index (ClientWorker.N).
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Casts frame to the worker shard for meta.client_ip / meta.client_port.
meta must include :transport, :socket, and server/client endpoints.
@spec pool_size() :: pos_integer()
Configured pool size (:client_worker_pool_size or scheduler count).
Starts the worker pool supervisor (registered as __MODULE__).
@spec worker_index(:inet.ip_address(), :inet.port_number()) :: non_neg_integer()
Shard index for a client five-tuple (same hash as dispatch/2).
@spec worker_name(non_neg_integer()) :: atom()
Registered module atom for worker index (ClientWorker.N).