pub struct CuTracker { /* private fields */ }Expand description
Per-provider CU consumption tracker.
Implementations§
Source§impl CuTracker
impl CuTracker
Sourcepub fn new(
url: impl Into<String>,
cost_table: CuCostTable,
config: CuBudgetConfig,
) -> Self
pub fn new( url: impl Into<String>, cost_table: CuCostTable, config: CuBudgetConfig, ) -> Self
Create a new tracker for the given provider.
Sourcepub fn cost_for(&self, method: &str) -> u32
pub fn cost_for(&self, method: &str) -> u32
Get the CU cost that would be charged for this method.
Sourcepub fn usage_fraction(&self) -> f64
pub fn usage_fraction(&self) -> f64
Usage fraction (0.0-1.0). Returns 0.0 if unlimited.
Sourcepub fn is_exhausted(&self) -> bool
pub fn is_exhausted(&self) -> bool
Whether the budget is exhausted.
Sourcepub fn should_throttle(&self) -> bool
pub fn should_throttle(&self) -> bool
Whether we should throttle (near limit + throttling enabled).
Sourcepub fn per_method_usage(&self) -> HashMap<String, u64>
pub fn per_method_usage(&self) -> HashMap<String, u64>
Get per-method breakdown of CU consumption.
Sourcepub fn snapshot(&self) -> CuSnapshot
pub fn snapshot(&self) -> CuSnapshot
Produce a snapshot for reporting.
Auto Trait Implementations§
impl !Freeze for CuTracker
impl RefUnwindSafe for CuTracker
impl Send for CuTracker
impl Sync for CuTracker
impl Unpin for CuTracker
impl UnsafeUnpin for CuTracker
impl UnwindSafe for CuTracker
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