libduvet/http/ack

Types

Wraps a send so each key gets at most one ack per interval, never one older than what was sent.

pub opaque type AckThrottle

Values

pub fn ack(
  throttle: AckThrottle,
  key: String,
  message_id: String,
) -> Nil

Records an ack, sending it now or merging it with the next one.

pub const ack_interval: Int

Read acks go out at most once per room or conversation every [ack_interval]: reading a busy room would otherwise send one per message. The first goes out at once; later ones within the interval merge into one trailing ack with the newest message ID. IDs are UUIDv7, so they compare by time as strings.

pub fn dispose(throttle: AckThrottle) -> Nil

Cancels the trailing acks still waiting.

pub fn start(send: fn(String, String) -> Nil) -> AckThrottle

Starts the throttle; [send] performs an ack, and its failures are the caller’s to swallow.

✨ Search Document