pub struct WriterTaskHandle { /* private fields */ }Expand description
Sender half of the write queue. Cheaply cloneable (wraps an
mpsc::Sender) — every migrated store that shares one writer task holds
a clone of this handle.
Implementations§
Source§impl WriterTaskHandle
impl WriterTaskHandle
Sourcepub async fn send<R, F>(&self, op: F) -> Result<R, StorageError>
pub async fn send<R, F>(&self, op: F) -> Result<R, StorageError>
Send a write operation to the writer task and await its typed reply.
Backpressure: this suspends on the channel’s send().await when the
bounded queue is full (ADR-067 “Channel capacity and queue-full
policy”) — there is no try_send escape hatch. Callers that need a
deadline on that wait should use Self::send_with_timeout instead.
Sourcepub async fn send_with_timeout<R, F>(
&self,
op: F,
timeout: Duration,
) -> Result<R, StorageError>
pub async fn send_with_timeout<R, F>( &self, op: F, timeout: Duration, ) -> Result<R, StorageError>
Like Self::send, but bounds the wait for the bounded channel to
free capacity with timeout.
The timeout applies ONLY to enqueueing the request (the channel
send().await that can suspend on a full queue) — never to waiting
for the writer task’s reply once the request has been accepted.
StorageError::WriteQueueFull means exactly “the bounded channel was
full and this request was never accepted”; it must never be returned
for a request that was accepted and is still executing (or already
committed) by the time timeout elapses — that would misreport a
slow op or a lock wait as a queue-capacity failure, and could tell a
caller a write failed when it actually landed. ADR-067’s queue-full
policy has no immediate-error try_send path — only this caller-side
deadline on the enqueue step.
Sourcepub async fn send_top_level<R, F>(&self, op: F) -> Result<R, StorageError>
pub async fn send_top_level<R, F>(&self, op: F) -> Result<R, StorageError>
Send a write operation that MUST run outside any open transaction
(e.g. VACUUM, which SQLite forbids inside BEGIN/COMMIT) and
await its typed reply.
Still serialized through the same single writer owner as
Self::send — the request goes through the identical bounded
channel and drain loop, one request at a time — but the drain loop
skips the per-request BEGIN IMMEDIATE/COMMIT/ROLLBACK wrap
entirely for this request (ADR-067 Component A). The single-writer
guarantee is preserved; only
the transaction wrap is skipped.
Sourcepub fn queue_depth(&self) -> usize
pub fn queue_depth(&self) -> usize
Current write-queue backlog depth: requests enqueued but not yet accepted by the writer task’s drain loop.
Reads mpsc::Sender::max_capacity() - capacity(), so it is a
point-in-time snapshot racy under concurrent senders/the drain loop
draining concurrently — acceptable for a monitoring gauge (the
load/perf harness metrics read-surface), never used for any correctness
decision.
Trait Implementations§
Source§impl Clone for WriterTaskHandle
impl Clone for WriterTaskHandle
Source§fn clone(&self) -> WriterTaskHandle
fn clone(&self) -> WriterTaskHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for WriterTaskHandle
impl RefUnwindSafe for WriterTaskHandle
impl Send for WriterTaskHandle
impl Sync for WriterTaskHandle
impl Unpin for WriterTaskHandle
impl UnsafeUnpin for WriterTaskHandle
impl UnwindSafe for WriterTaskHandle
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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