Xirsys.Sockets.Accumulator behaviour (xturn_sockets v2.0.0)

View Source

Per-tier packet framing state machine.

Bounded buffers

Every Accumulator implementation should support a :max_size option limiting how much data or how many whole packets may be held before signalling overflow. Because push/3 returns only acc(), implementations typically record overflow during push/3 (for example by dropping the oldest entry and setting a flag) and surface it once from the next pop/1 as {:error, :buffer_overflow, acc}. The engine logs :frame_error telemetry and continues draining after overflow.

Summary

Types

acc()

@type acc() :: term()

meta()

@type meta() :: map()

Callbacks

init(keyword)

@callback init(keyword()) :: acc()

pop(acc)

@callback pop(acc()) ::
  {:ok, binary(), meta(), acc()} | {:more, acc()} | {:error, term(), acc()}

push(acc, binary, meta)

@callback push(acc(), binary(), meta()) :: acc()