pub struct Journal { /* private fields */ }Expand description
An At-Least-Once journal for storing fixed-size entries, with
RocksDB-backed persistence.
All indices here are monotonic u64, wrapping around on overflow.
Invariant: consumed_index <= write_index.
Writes go directly to RocksDB (synchronous and durable), so there is no
separate “persisted” boundary — write_index is the persisted boundary.
Implementations§
Source§impl Journal
impl Journal
Sourcepub fn with_capacity(capacity: usize) -> Result<Self, Error>
pub fn with_capacity(capacity: usize) -> Result<Self, Error>
Create a new journal with the specified capacity and default configuration.
Sourcepub fn with_capacity_and_config(
capacity: usize,
config: JournalConfig,
) -> Result<Self, Error>
pub fn with_capacity_and_config( capacity: usize, config: JournalConfig, ) -> Result<Self, Error>
Create a new journal with the specified capacity and configuration.
Sourcepub fn reader(&self) -> JournalReader
pub fn reader(&self) -> JournalReader
Sourcepub fn try_reader(&self) -> Option<JournalReader>
pub fn try_reader(&self) -> Option<JournalReader>
Try acquires a reader for this journal.
If a reader is already taken, returns None.
Sourcepub fn commit(&self, data: &[u8])
pub fn commit(&self, data: &[u8])
Commit a new entry to the journal.
The entry is written to RocksDB synchronously.
§Panics
Panics if the journal is full or has encountered a fatal error.
Sourcepub fn try_commit(&self, data: &[u8]) -> Result<(), Error>
pub fn try_commit(&self, data: &[u8]) -> Result<(), Error>
Try commit a new entry to the journal.
The entry is written to RocksDB synchronously.
Sourcepub fn consumed_index(&self) -> u64
pub fn consumed_index(&self) -> u64
Get the current consumed index.
Sourcepub fn write_index(&self) -> u64
pub fn write_index(&self) -> u64
Get the current write index.