Xirsys.Sockets.Accumulator.Raw (xturn_sockets v2.2.1)
View SourceNo framing: each push/3 is one immediately poppable packet.
What problem this solves
Datagram transports (UDP, DTLS) and inner tiers that already receive whole payloads need no length header parsing. Each read or descend push becomes one handler packet.
RFCs
Options
:max_size- maximum queued whole packets (default:1024)
Overflow drops the oldest packet and surfaces :buffer_overflow on the next
pop/1, then draining continues.
Summary
Functions
Builds an empty packet queue.
Dequeues one packet, reports overflow, or returns {:more, acc} when empty.
Enqueues chunk as one packet. Drops the oldest entry when over :max_size.
Functions
Builds an empty packet queue.
Parameters
opts-:max_size(default1024)iex> acc = Xirsys.Sockets.Accumulator.Raw.init([]) iex> acc = Xirsys.Sockets.Accumulator.Raw.push(acc, "hello", %{n: 1}) iex> {:ok, "hello", %{n: 1}, acc} = Xirsys.Sockets.Accumulator.Raw.pop(acc) iex> elem(Xirsys.Sockets.Accumulator.Raw.pop(acc), 0) :more
Dequeues one packet, reports overflow, or returns {:more, acc} when empty.
Parameters
acc- state afterpush/3
Enqueues chunk as one packet. Drops the oldest entry when over :max_size.