Expand description
Single-writer task and bounded write queue (ADR-067 Component A). Single-writer task and bounded write queue (ADR-067 Component A).
WriterTask (via spawn and the drain loop run_writer_task) owns a
dedicated standalone writer rusqlite::Connection and is the only code
path that issues BEGIN IMMEDIATE for write traffic routed through the
channel it drains. Callers reach it exclusively through a
WriterTaskHandle, sending a typed closure and awaiting a typed
oneshot reply so each store method’s natural return type (e.g.
BatchWriteSummary) survives the trip through the type-erased channel
unmodified — a flat Result<u64, StorageError> reply would conflate
affected/failed into one count and drop first_error.
See crates/khive-db/docs/api/writer-task.md for migration-slice scope
(which write paths currently route through this vs. the legacy
pool-mutex path) and the ADR-067 component breakdown.
Structs§
- Write
Request - One write request awaiting execution by the writer task.
- Writer
Task Handle - 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.
Traits§
- AnyWrite
Request - Type-erased write request the writer task’s drain loop can hold in a
homogeneous channel (
mpsc::Sender<Box<dyn AnyWriteRequest + Send>>), while each concreteWriteRequest<R>still carries its own typed reply. Sealed: only this module may implement it (ADR-067 lines 210-212).
Functions§
- spawn
- Spawn the write-owner task (ADR-067 Component A) on the current Tokio runtime.