pub struct LogWriter<C> { /* private fields */ }Expand description
Background-task-fronted log writer.
Construction (via write_agent_completion etc.) spawns a tokio
task that owns the per-stream [LogWriterState]. The handle here
is a thin sender + JoinHandle pair.
Implementations§
Source§impl<C> LogWriter<C>
impl<C> LogWriter<C>
Sourcepub fn write(&self, chunk: C) -> Result<(), Error>
pub fn write(&self, chunk: C) -> Result<(), Error>
Hand off one chunk to the listener task. Returns
Err(Error::Instance(_)) only when the listener has already
exited — typically because an earlier DB write failed. The
caller should treat that error the same way it would treat an
upstream stream error: stop reading, surface upward.
Sourcepub fn written_once(&self) -> bool
pub fn written_once(&self) -> bool
Sync peek: has the listener completed at least one successful
apply_chunk batch? Flips false → true exactly once,
immediately after the first batch’s write completes and
before the listener parks on the next recv.
Sourcepub async fn wait_written_once(&self) -> Result<(), Error>
pub async fn wait_written_once(&self) -> Result<(), Error>
Async wait that resolves once the listener has completed its
first successful apply_chunk batch. Returns immediately if
that already happened. Errors only if the listener task
exited before its first successful write (DB error on the
very first batch).
Sourcepub async fn finalize(self) -> Result<(), Error>
pub async fn finalize(self) -> Result<(), Error>
Consume the writer. Drops the sender (signaling EOF to the listener) and awaits the task. Returns only once:
- the channel is empty:
recv()returnsNoneonly after the listener has drained every queued chunk, AND - no work is in flight: the task’s future has fully completed, so no row-bucket joins or blob writes remain pending.
Surfaces the first DB error the task encountered, if any.
Auto Trait Implementations§
impl<C> !RefUnwindSafe for LogWriter<C>
impl<C> !UnwindSafe for LogWriter<C>
impl<C> Freeze for LogWriter<C>
impl<C> Send for LogWriter<C>where
C: Send,
impl<C> Sync for LogWriter<C>where
C: Send,
impl<C> Unpin for LogWriter<C>
impl<C> UnsafeUnpin for LogWriter<C>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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