pub struct UsageBuffer { /* private fields */ }Expand description
Thread-safe in-memory aggregator with bounded idempotency memory.
Implementations§
Source§impl UsageBuffer
impl UsageBuffer
Sourcepub fn new(max_idempotency_keys: usize) -> UsageBuffer
pub fn new(max_idempotency_keys: usize) -> UsageBuffer
Construct a buffer retaining at most max_idempotency_keys once-only
keys. Zero disables in-process deduplication.
Sourcepub fn record(&self, event: UsageEvent) -> Result<RecordOutcome, RecordError>
pub fn record(&self, event: UsageEvent) -> Result<RecordOutcome, RecordError>
Record one event into a (customer, meter) aggregate.
§Errors
Returns RecordError::Poisoned if another thread panicked while
mutating the buffer, or RecordError::UnitsOverflow rather than
silently saturating an invoice quantity.
Sourcepub fn retry_buckets(&self) -> usize
pub fn retry_buckets(&self) -> usize
Number of aggregates waiting to be retried.
Separated from Self::pending_buckets because the two mean very
different things operationally: pending rising means traffic, retry
rising means the provider is refusing, and a retry count that never
falls is a batch that will never be accepted.
Sourcepub fn pending_buckets(&self) -> usize
pub fn pending_buckets(&self) -> usize
Number of live aggregate buckets plus retry events.
Trait Implementations§
Source§impl Debug for UsageBuffer
impl Debug for UsageBuffer
Source§impl Default for UsageBuffer
impl Default for UsageBuffer
Source§fn default() -> UsageBuffer
fn default() -> UsageBuffer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for UsageBuffer
impl RefUnwindSafe for UsageBuffer
impl Send for UsageBuffer
impl Sync for UsageBuffer
impl Unpin for UsageBuffer
impl UnsafeUnpin for UsageBuffer
impl UnwindSafe for UsageBuffer
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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