pub fn spawn(
pool: &ConnectionPool,
capacity: usize,
) -> Result<WriterTaskHandle, SqliteError>Expand description
Spawn the write-owner task (ADR-067 Component A) on the current Tokio runtime.
Opens a dedicated standalone writer connection
(ConnectionPool::open_standalone_writer) that the task owns
exclusively for its lifetime — independent of the pool’s Mutex-guarded
writer() connection, which unmigrated paths continue to use in this
slice. Returns the cloneable WriterTaskHandle sender half; the task
keeps running in the background until every clone of the handle is
dropped and the channel closes, at which point the drain loop exits.
capacity bounds the channel (ADR-067 recommends 256;
PoolConfig::write_queue_capacity resolves the default from
KHIVE_WRITE_QUEUE_CAPACITY). Slice 1 commits one request per BEGIN IMMEDIATE — Component B’s batched-commit window is a later slice.
Must be called from within a Tokio runtime context (this calls
tokio::spawn). Returns an error if the pool cannot open a standalone
writer connection — for example, an in-memory pool, which has no
standalone-connection support (ConnectionPool::open_standalone_writer).