OutboundQueue constructor

OutboundQueue({
  1. required Future<void> onSend(
    1. List<int> data
    ),
  2. required int maxBufferSize,
})

A serialized, byte-bounded outbound send queue.

Messages are sent one at a time (each add waits for the previous send to complete), which both preserves ordering and provides a natural back-pressure point: when a consumer is slow, its onSend futures complete slowly and the queued byte count grows. If the queued (not-yet-sent) bytes would exceed maxBufferSize, add rejects with OutboundBufferOverflow instead of buffering without bound.

Constructor

onSend performs the actual transport write for one message and must complete when the write is done (or fail on error).

Implementation

OutboundQueue({
  required Future<void> Function(List<int> data) onSend,
  required int maxBufferSize,
})  : _onSend = onSend,
      _maxBufferSize = maxBufferSize;