pub struct BudgetChecker { /* private fields */ }Expand description
Cross-partition budget checker with per-cycle caching.
Reads budget usage/limits once per scan cycle (not per candidate). This is MANDATORY for performance — without it, 50K blocked executions would produce 50K budget reads per cycle.
Implementations§
Source§impl BudgetChecker
impl BudgetChecker
pub fn new(config: PartitionConfig) -> Self
Sourcepub async fn check_budget(
&mut self,
client: &Client,
budget_id: &str,
) -> Result<&BudgetCheckResult, SchedulerError>
pub async fn check_budget( &mut self, client: &Client, budget_id: &str, ) -> Result<&BudgetCheckResult, SchedulerError>
Check a budget by ID. Reads from Valkey on first call per budget, caches for subsequent candidates in the same cycle.
Fail-closed: transport errors propagate as
SchedulerError::ValkeyContext rather than being cached as
Ok. Caching an Err would be wrong — a transient blip would then
pin every candidate in this cycle to the same denial. Successful
results (including HardBreach) are still cached so 50K blocked
candidates sharing a budget do one read per cycle, not 50K.
Auto Trait Implementations§
impl Freeze for BudgetChecker
impl RefUnwindSafe for BudgetChecker
impl Send for BudgetChecker
impl Sync for BudgetChecker
impl Unpin for BudgetChecker
impl UnsafeUnpin for BudgetChecker
impl UnwindSafe for BudgetChecker
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
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