Amarula.Protocol.Socket.Router (amarula v0.1.0)
View SourcePure routing decision for inbound server nodes — cluster 3 of the
Connection split (see docs/plans/CM_SPLIT.plan.md).
Connection.process_server_node/2 used to inline a ~20-arm case over
{tag, type, first_child, xmlns} that both decided which handler runs and
ran it. This module isolates the decision: route/1 maps a node to a handler
tag (an atom) plus, where the routing key implies it, a sub-kind. CM keeps the
handlers and just dispatches on the returned tag.
Keeping the table pure makes the protocol's dispatch surface testable without a live socket, and turns "which frames do we handle?" into one readable list.
Summary
Types
The handler a node routes to. CM maps each to its handler function. :unhandled
is the explicit catch-all (CM logs it loudly).
Functions
Decide which handler an inbound node routes to. Pure: depends only on the node's
tag, type/xmlns attrs, and first-child tag — never on connection state.
Types
@type handler() ::
:pair_device
| :pair_success
| :auth_success
| :message
| :stream_error
| :connection_failure
| :server_ping
| :ping_response
| :iq_response
| :xml_stream_end
| :offline_preview
| :offline_complete
| :edge_routing
| :dirty
| :ignore
| :notification
| :presence
| :retry_receipt
| :receipt_ack
| :call_ack
| :message_ack
| :unhandled
The handler a node routes to. CM maps each to its handler function. :unhandled
is the explicit catch-all (CM logs it loudly).
Functions
@spec route(Amarula.Protocol.Binary.Node.t()) :: handler()
Decide which handler an inbound node routes to. Pure: depends only on the node's
tag, type/xmlns attrs, and first-child tag — never on connection state.