pub fn spawn_warming_creditor(
allowance: Arc<WarmingAllowance>,
metrics: Arc<Metrics>,
) -> (Arc<dyn WarmingCreditSink>, StopHandle)Expand description
Spawn the single background task that owns the credit queue and applies each
credit to allowance, returning the WarmingCreditSink the serve path
enqueues through and the StopHandle that stops the task.
This is what takes the bucket lock off the stream task (see the module
Seam): a serve completion resolves the source from the tag map — one shard
read, never the bucket lock — and does one bounded try_send. This task
takes the bucket lock instead, where waiting behind the buy loop costs a
queued credit rather than a held lane slot.
The handle is returned rather than detached so shutdown can await the drain
and a task that died is visible as a join error instead of as credits that
quietly stop landing. StopHandle::shutdown ends the loop after it
flushes whatever is already queued (the handle owns the stop token beside
the task, so the join cannot hang on the sinks the client handler holds);
the loop also ends if every sink is dropped first.