pub struct SeqNumStore { /* private fields */ }Expand description
Server-side durable store for the last-accepted seq_num per requester key.
Backed by one JSON file per requester key under {root}/. Writes are
atomic (tmp-file + rename) and fsynced before rename so that a crash after
bytes are transmitted cannot allow a replay.
Implementations§
Source§impl SeqNumStore
impl SeqNumStore
pub fn open(root: impl Into<PathBuf>) -> Self
pub fn for_data_dir(data_dir: impl AsRef<Path>) -> Self
pub fn for_group_fetch_data_dir(data_dir: impl AsRef<Path>) -> Self
Sourcepub fn last_seen(
&self,
requester_key_hex: &str,
) -> Result<u64, SeqNumStoreError>
pub fn last_seen( &self, requester_key_hex: &str, ) -> Result<u64, SeqNumStoreError>
Return the last accepted seq_num for this requester key, or 0 if
the key has never been seen.
Sourcepub fn advance(
&self,
requester_key_hex: &str,
new_seq_num: u64,
) -> Result<(), SeqNumStoreError>
pub fn advance( &self, requester_key_hex: &str, new_seq_num: u64, ) -> Result<(), SeqNumStoreError>
Durably advance the stored seq_num for this requester key.
Fsync + atomic rename ensures the update survives a crash (R-ACCESS-11).
Returns SeqNumStoreError::NotMonotonic if new_seq_num <= current.
Auto Trait Implementations§
impl Freeze for SeqNumStore
impl RefUnwindSafe for SeqNumStore
impl Send for SeqNumStore
impl Sync for SeqNumStore
impl Unpin for SeqNumStore
impl UnsafeUnpin for SeqNumStore
impl UnwindSafe for SeqNumStore
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