Expand description
A durable, at-least-once MPSC queue backed by in-memory and durable backends.
Items are written to a Store and survive process and machine crashes.
Delivery is at-least-once: an item is removed only once the consumer acks it,
so a crash between handling and ack redelivers it. The core is synchronous and
runtime-agnostic.
use persistent_queue::{Builder, MemStore};
let (tx, rx) = Builder::new(MemStore::new()).capacity(1024).open().unwrap();
tx.push(b"job").unwrap();
let item = rx.reserve().unwrap().unwrap();
assert_eq!(&*item, b"job");
item.ack().unwrap();See DESIGN.md for the on-disk layout, crash recovery, and durability model.
Structs§
- Builder
- Builds a queue over a
Store. - Consumer
- The consumer half. Single consumer, so it does not implement
Clone. - MemStore
- In-memory
Storebacked by aBTreeMap. Not persistent;durableis a no-op. Useful as the default, for tests, and as a benchmark baseline. - Producer
- The producer half. Clone it for multiple producers.
- Reserved
- A reserved (in-flight) item. Derefs to its bytes;
ackremoves it,nackor drop returns it for redelivery.
Enums§
- Durability
- How writes are made durable.
- Op
- A single write in a
Store::commitbatch. - Open
Error - Error from opening a queue over a store.
- Push
Error - Error from a blocking
Producer::push. - TryPush
Error - Error from
Producer::try_push.
Traits§
- Store
- An ordered key/value byte store: the durable substrate under the queue.
Type Aliases§
- Ends
- The producer and consumer ends returned by
Builder::open. - KeyValue
- A key/value pair returned by a store seek.