MailboxRepository

Queues opaque envelopes per recipient device. See docs/transport-ordering.md for why the order matters.

Ordering contract: for each ordered pair (sender DeviceAddress, recipient DeviceAddress), envelopes are drained in the order their enqueue calls returned. An envelope whose enqueue returned before another one's started comes out first. Nothing is promised about the order between different senders, or between one sender's envelopes for different recipients.

Every enqueued envelope is returned by exactly one drain: none is lost, duplicated or returned twice, also when calls run concurrently. There are no acknowledgements, expiry or persistence guarantees beyond that.

Functions

Link copied to clipboard
abstract suspend fun drain(recipient: DeviceAddress): List<EncryptedEnvelope>

Removes and returns the queued envelopes of recipient, each (sender, recipient) stream in order. Atomic.

Link copied to clipboard
abstract suspend fun enqueue(envelope: EncryptedEnvelope)

Appends envelope to the queue of its recipient. Atomic.