Xirsys.Sockets.Engine (xturn_sockets v2.2.0)
View SourceDrain loop: pop every whole packet from a tier, dispatch the handler, repeat.
Connection and DatagramServer call push_and_drain/9 after each read.
drain/8 is used for timer ticks (reorder timeouts) without a new chunk.
Summary
Types
Result of a drain pass: updated accumulators, handler states, async tier
pids, and :ok or :close.
Functions
Pops whole packets from tier_key until the accumulator returns {:more, _}.
Pushes chunk into :root, then drains from :root.
Types
Functions
@spec drain( Xirsys.Sockets.Pipeline.t(), atom(), Xirsys.Sockets.Conn.t(), map(), map(), map(), module(), pid() ) :: drain_result()
Pops whole packets from tier_key until the accumulator returns {:more, _}.
Handler {:reply, _, _} is sent on conn.socket. {:descend, next, payload, _}
pushes payload into next. {:close, _} stops the connection after this pass.
Framing errors emit :frame_error and continue.
Parameters
pipeline- compiled pipelinetier_key- tier to drain (:root, ...)conn- connection context used for repliesaccs- map of tier name to accumulator statestates- map of tier name to handler statetier_sessions- map of async tier name to session pidtransport_mod-Xirsys.Sockets.Transportimplementationowner_pid- connection or datagram-server process
@spec push_and_drain( Xirsys.Sockets.Pipeline.t(), binary(), map(), Xirsys.Sockets.Conn.t(), map(), map(), map(), module(), pid() ) :: drain_result()
Pushes chunk into :root, then drains from :root.
Unthrottled: this path carries media as well as control traffic. Apply
Config.check_rate_limit/1 in the handler for the message classes that
need a budget.
Parameters
pipeline- compiled pipelinechunk- inbound bytes fromhandle_message/2meta- packet metadata (:from,:received_at, ...)conn- connection contextaccs/states/tier_sessions- session mapstransport_mod- transport used for{:reply, _, _}owner_pid- owning process