Struct FileStore
pub(crate) struct FileStore {
writer: Writer,
compact_threshold: Option<u64>,
bytes_since_compact: u64,
frame_buf: Vec<u8>,
}tokio only.Expand description
Runtime journal-file backend with an append-only writer and compaction bookkeeping.
Fields§
§writer: Writer§compact_threshold: Option<u64>§bytes_since_compact: u64Journal bytes written since the last compaction. Persists across reconnects with the store so short-lived connections do not reset it.
frame_buf: Vec<u8>The reused buffer that the pending ops are framed into. It is then moved to the writer’s blocking pool. A steady stream of flushes does not allocate or copy per flush.
Implementations§
§impl FileStore
impl FileStore
pub(crate) async fn persist(
&mut self,
client: &mut Client<JournaledSession>,
) -> Result<()>
pub(crate) async fn persist( &mut self, client: &mut Client<JournaledSession>, ) -> Result<()>
Frames the session’s pending ops, appends them, and once the growth threshold is exceeded compacts the journal. Clears the in-memory buffer only on a successful write. After a failed write the ops remain buffered. The returned error lets the caller stop acknowledging state that was never made durable.
If the journal missed an op, the pending ops are incomplete. The whole session is then written as a snapshot instead.
async fn compact(&mut self, client: &Client<JournaledSession>) -> Result<()>
async fn compact(&mut self, client: &Client<JournaledSession>) -> Result<()>
Rewrites the journal as one snapshot of the session.
Auto Trait Implementations§
impl Freeze for FileStore
impl RefUnwindSafe for FileStore
impl Send for FileStore
impl Sync for FileStore
impl Unpin for FileStore
impl UnsafeUnpin for FileStore
impl UnwindSafe for FileStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more