pub struct Budget {
pub key: String,
pub capacity: f64,
pub refill_per_sec: f64,
pub cost: f64,
pub daily_limit: Option<u64>,
}Expand description
The budget a single request spends against, as the router names it.
Fields§
§key: StringIdentifies the upstream (and the API key within it), e.g.
"dexscreener" or "rpc:3f9a…". The token-bucket row and the daily
quota counter are keyed by exactly this string.
capacity: f64Token-bucket size: the burst the key may spend at once, and the level every bucket refills toward.
refill_per_sec: f64Sustained refill rate, tokens per second.
cost: f64Tokens this one request spends. 1.0 is a plain request; heavier
endpoints can charge more. A cost above capacity can never be
served and reports exhausted with the wait until a full bucket
would cover it.
daily_limit: Option<u64>Per-UTC-day request quota, counted through Usage with
Period::Day. None is untracked: no quota, no database write.
Trait Implementations§
impl StructuralPartialEq for Budget
Auto Trait Implementations§
impl Freeze for Budget
impl RefUnwindSafe for Budget
impl Send for Budget
impl Sync for Budget
impl Unpin for Budget
impl UnsafeUnpin for Budget
impl UnwindSafe for Budget
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