pub struct GlobalCounters { /* private fields */ }Expand description
Cross-instance counter reconciliation over a shared Redis-protocol store.
Implementations§
Source§impl GlobalCounters
impl GlobalCounters
Sourcepub fn build(url: &str, interval: Duration) -> Result<Arc<Self>, String>
pub fn build(url: &str, interval: Duration) -> Result<Arc<Self>, String>
Open the shared store and return the reconciler.
§Errors
Returns the underlying error when the store URL is invalid.
Sourcepub fn fleet_remaining(&self, key: &str, budget: u64, window: Duration) -> u64
pub fn fleet_remaining(&self, key: &str, budget: u64, window: Duration) -> u64
Fleet budget still available for key (0 = over budget). Read-only: the
cached remote estimate plus this instance’s unclaimed count, subtracted
from budget. Does not touch the store and does not record the admit
(call record after the local check also passes).
This is deliberately a read then a separate record, not an atomic
reserve/rollback. The per-instance GcraStore
is the hard local cap and is atomic per key; this fleet gate is only an
approximate cross-instance cap. A race where concurrent requests all pass
the gate before any records is bounded by the local burst plus the
documented one-interval overshoot, which is the accepted trade-off for
keeping the hot path lock-free and non-blocking.
Auto Trait Implementations§
impl !Freeze for GlobalCounters
impl !RefUnwindSafe for GlobalCounters
impl !UnwindSafe for GlobalCounters
impl Send for GlobalCounters
impl Sync for GlobalCounters
impl Unpin for GlobalCounters
impl UnsafeUnpin for GlobalCounters
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request