pub struct MemoryStorage { /* private fields */ }Expand description
Pure in-memory storage backend.
See module docs for the detailed semantic contract. Safe to share
across threads as Send + Sync; internal state is behind &mut self
so callers wrap it in their own synchronisation (as
KimberliteInner does via its outer RwLock).
Implementations§
Source§impl MemoryStorage
impl MemoryStorage
Sourcepub fn with_max_segment_size(max_segment_size: u64) -> Self
pub fn with_max_segment_size(max_segment_size: u64) -> Self
Creates a new empty in-memory storage with a custom notional segment size. Intended for tests that want to exercise the rotation bookkeeping without writing 256 MB of data.
Sourcepub fn max_segment_size(&self) -> u64
pub fn max_segment_size(&self) -> u64
Returns the configured notional segment size in bytes.
Trait Implementations§
Source§impl Debug for MemoryStorage
impl Debug for MemoryStorage
Source§impl Default for MemoryStorage
impl Default for MemoryStorage
Source§impl StorageBackend for MemoryStorage
impl StorageBackend for MemoryStorage
Source§fn append_batch(
&mut self,
stream_id: StreamId,
events: Vec<Bytes>,
expected_offset: Offset,
prev_hash: Option<ChainHash>,
_fsync: bool,
) -> Result<(Offset, ChainHash), StorageError>
fn append_batch( &mut self, stream_id: StreamId, events: Vec<Bytes>, expected_offset: Offset, prev_hash: Option<ChainHash>, _fsync: bool, ) -> Result<(Offset, ChainHash), StorageError>
Appends a batch of events to a stream and extends the hash chain. Read more
Source§fn read_from(
&mut self,
stream_id: StreamId,
from_offset: Offset,
max_bytes: u64,
) -> Result<Vec<Bytes>, StorageError>
fn read_from( &mut self, stream_id: StreamId, from_offset: Offset, max_bytes: u64, ) -> Result<Vec<Bytes>, StorageError>
Reads events from a stream with checkpoint-optimised chain
verification. Read more
Source§fn latest_chain_hash(
&mut self,
stream_id: StreamId,
) -> Result<Option<ChainHash>, StorageError>
fn latest_chain_hash( &mut self, stream_id: StreamId, ) -> Result<Option<ChainHash>, StorageError>
Returns the chain hash of the last appended record for the
stream, or
None if the stream has never been written to. Read moreSource§fn segment_count(&self, stream_id: StreamId) -> usize
fn segment_count(&self, stream_id: StreamId) -> usize
Number of segments (active + completed) for a stream. Read more
Source§fn completed_segments(&self, stream_id: StreamId) -> Vec<u32>
fn completed_segments(&self, stream_id: StreamId) -> Vec<u32>
Numbers of the completed (immutable) segments for a stream.
Source§fn flush_indexes(&mut self) -> Result<(), StorageError>
fn flush_indexes(&mut self) -> Result<(), StorageError>
Best-effort flush of any backend-internal buffers. Read more
Auto Trait Implementations§
impl Freeze for MemoryStorage
impl RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnsafeUnpin for MemoryStorage
impl UnwindSafe for MemoryStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more