| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Relay.Reliable.Outbox
Description
Documentation
Sender-local reliable state for one session. Collapses Monarch's
Outbox (sequence assignment) and Unacked (in-flight buffer): in
the ack-driven model a message is simply either acknowledged or
still awaiting acknowledgement.
Constructors
| Outbox | |
Fields
| |
emptyOutbox :: SessionId -> Outbox a Source #
Initial sender state for a session. The first assigned sequence number is 1; nothing is in flight or acknowledged.
send :: a -> Outbox a -> (Outbox a, Frame a) Source #
Assign the next sequence number to a payload, record it as in-flight, and return the frame to put on the wire.
ack :: Nat -> Outbox a -> (Outbox a, [a]) Source #
Process a cumulative acknowledgement: drop every in-flight frame
with sequence number <= n and return their payloads in sequence
order.
Total under impossible acks: the recorded watermark is clamped to
min n (nextSeq - 1), so an ack for frames never sent (a dishonest
n >= nextSeq) cannot push largestAcked past what exists. The
watermark never decreases, so an ack at or below it is a no-op.
unackedFrames :: Outbox a -> [Frame a] Source #
The in-flight frames to retransmit, each carrying its original sequence number, in ascending sequence order. Retransmission never reassigns sequence numbers.