Skip to main content

persistent_queue/
lib.rs

1//! A durable, at-least-once MPSC queue backed by in-memory and durable backends.
2//!
3//! Items are written to a [`Store`] and survive process and machine crashes.
4//! Delivery is at-least-once: an item is removed only once the consumer acks it,
5//! so a crash between handling and ack redelivers it. The core is synchronous and
6//! runtime-agnostic.
7//!
8//! ```
9//! use persistent_queue::{Builder, MemStore};
10//!
11//! let (tx, rx) = Builder::new(MemStore::new()).capacity(1024).open().unwrap();
12//! tx.push(b"job").unwrap();
13//! let item = rx.reserve().unwrap().unwrap();
14//! assert_eq!(&*item, b"job");
15//! item.ack().unwrap();
16//! ```
17//!
18//! See `DESIGN.md` for the on-disk layout, crash recovery, and durability model.
19#![warn(missing_docs)]
20
21mod error;
22mod queue;
23mod store;
24mod sync;
25
26pub use error::{OpenError, PushError, TryPushError};
27pub use queue::{Builder, Consumer, Durability, Ends, Producer, Reserved};
28pub use store::{KeyValue, MemStore, Op, Store};
29
30#[cfg(feature = "redb")]
31pub use store::RedbStore;
32#[cfg(feature = "rocksdb")]
33pub use store::RocksStore;
34#[cfg(feature = "sled")]
35pub use store::SledStore;