Event Queues
In-memory and RocksDB-backed event queues for Arch services.
= "0.1"
The package name is arch-event-queues; the Rust import path is arch_event_queues.
In-Memory Queue
Use EventQueue<T> when events only need to live in memory.
use EventQueue;
let queue = new;
queue
.push
.unwrap;
assert_eq!;
Durable Queue
Use DurableEventQueue<T> when events must survive process restarts until they
are acknowledged. Payloads must implement borsh::BorshSerialize,
borsh::BorshDeserialize, and Clone.
use DurableEventQueue;
use ;
let dir = tempdir.unwrap;
let queue = open.unwrap;
let queued = queue
.push
.unwrap;
let next = queue.pop.unwrap.expect;
assert_eq!;
queue.ack.unwrap;
Eager vs Lazy
DurableEventQueue::open(path) uses eager mode. On startup, it scans RocksDB,
deserializes every unacked event, and fills the in-memory ready queue. This
makes polling cheap after open, but startup cost grows with the number and size
of unacked events.
DurableEventQueueOptions::lazy() uses lazy mode. Startup scans keys to find
ids but does not deserialize event payloads until they are popped. This is
better for large backlogs or large payloads.
use ;
;
let dir = tempdir.unwrap;
let queue =
open_with_options
.unwrap;