pub struct UsageRecorder { /* private fields */ }Expand description
Cheap-to-clone handle for request handlers.
The queue is partitioned into lanes by the request thread’s sticky
locality (GL-137). One shared channel put every request of every account on
the same sender count, semaphore, tail and waker lines, and woke the writer
once per event: eight threads measured 3.2 µs per reserve-and-record. A
request reserves in its own lane and tries the others before shedding, so
the shed point is still exactly queue_capacity — a partition, not a
reservation.
Implementations§
Source§impl UsageRecorder
impl UsageRecorder
Sourcepub fn try_reserve(&self) -> Result<UsagePermit, DenyReason>
pub fn try_reserve(&self) -> Result<UsagePermit, DenyReason>
Reserve accounting capacity for one request, before admission. A full queue denies here — before any units are reserved or any work runs.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Whether the writer task has exited and can no longer accept events.
Sourcepub fn health(&self) -> WriterHealth
pub fn health(&self) -> WriterHealth
The writer’s accounting health, readable at any time.
Deliberately on the recorder: a service holds this handle in its
request state, while the UsageWriter is usually moved into whatever
owns shutdown — so exposing the numbers only there would put them out of
reach of the endpoint that needs to report them.