pub struct EventStoreWriter { /* private fields */ }Expand description
The dedicated event store writer.
Implementations§
Source§impl EventStoreWriter
impl EventStoreWriter
Sourcepub fn spawn(
backend: Box<dyn EventStore + Send>,
clock: &'static AtomicTime,
halt: HaltCallback,
config: WriterConfig,
) -> Result<Self, EventStoreError>
pub fn spawn( backend: Box<dyn EventStore + Send>, clock: &'static AtomicTime, halt: HaltCallback, config: WriterConfig, ) -> Result<Self, EventStoreError>
Spawns the writer thread and takes ownership of backend.
The backend must already have an open run; the writer reads its current
high-watermark to seed the next assigned seq.
§Errors
Returns EventStoreError::Backend when the backend has no open run or when
the writer thread cannot be spawned.
Sourcepub fn submit(&self, draft: EntryDraft) -> Result<(), SubmitError>
pub fn submit(&self, draft: EntryDraft) -> Result<(), SubmitError>
Submits a captured entry. Stamps ts_publish from the clock at receive time
and hands the draft to the writer thread.
Blocks (with retry) when the channel is full. If the cumulative wait exceeds
the halt threshold, fires the halt callback once and returns
SubmitError::HaltSignaled; subsequent submits return SubmitError::Closed
without blocking.
Under concurrent submitters, two threads stalled at the threshold can each reach the halt-fire path before either sets the halted flag, so the halt callback may run more than once and a submit already past the entry check may briefly race with another thread’s halt-fire; the kernel’s fail-stop callback must therefore be idempotent.
§Errors
Returns SubmitError::Closed when the writer is shut down, the writer
thread has exited, or a prior submit already fired a fail-stop halt; returns
SubmitError::HaltSignaled when this submit’s stall first crosses the
configured halt threshold.
Sourcepub fn high_watermark(&self) -> u64
pub fn high_watermark(&self) -> u64
Returns the largest seq durably acknowledged by the backend.
Updated only after a successful append_batch ack; reflects what is safe to
anchor a snapshot against.
Sourcepub fn record_snapshot_anchor(
&self,
blob_ref: impl Into<String>,
content_hash: impl Into<String>,
) -> Result<SnapshotAnchor, EventStoreError>
pub fn record_snapshot_anchor( &self, blob_ref: impl Into<String>, content_hash: impl Into<String>, ) -> Result<SnapshotAnchor, EventStoreError>
Flushes pending entries and records a snapshot anchor at the durable high-watermark.
The cache owns blob_ref and content_hash; the writer derives the
high-watermark only after earlier submitted entries have committed, so the
anchor never points past durable event-store state.
§Errors
Returns EventStoreError::Closed when the writer is closed or halted, and
forwards backend errors when flushing pending entries or recording the anchor
fails.
Sourcepub fn close(self, run_ended: EntryDraft) -> Result<u64, EventStoreError>
pub fn close(self, run_ended: EntryDraft) -> Result<u64, EventStoreError>
Drains the channel, commits run_ended as the final entry, and seals the
manifest with crate::manifest::RunStatus::Ended.
Consumes the writer; further submits are unrepresentable.
§Errors
Returns EventStoreError when the writer thread fails to commit the final
batch, when seal fails, or when the writer thread panicked.
Trait Implementations§
Source§impl Debug for EventStoreWriter
impl Debug for EventStoreWriter
Source§impl Drop for EventStoreWriter
impl Drop for EventStoreWriter
Auto Trait Implementations§
impl !Freeze for EventStoreWriter
impl !RefUnwindSafe for EventStoreWriter
impl !UnwindSafe for EventStoreWriter
impl Send for EventStoreWriter
impl Sync for EventStoreWriter
impl Unpin for EventStoreWriter
impl UnsafeUnpin for EventStoreWriter
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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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