pub trait MultiDecider: MultiDeciderImpl {
    fn check_n_at(
        &mut self,
        n: u32,
        at: Instant
    ) -> Result<(), NegativeMultiDecision> { ... } fn check_n(&mut self, n: u32) -> Result<(), NegativeMultiDecision> { ... } }
Expand description

The “batch” decision trait, allowing a Decider to make a decision about multiple cells at once.

Provided Methods

Tests if n cells can be accommodated at the given time stamp. If (and only if) all cells in the batch can be accomodated, the MultiDecider updates the internal state to account for all cells and returns Ok(()).

If the entire batch of cells would not be conforming but the MultiDecider has the capacity to accomodate the cells at any point in time, check_n_at returns error NegativeMultiDecision::BatchNonConforming, holding the number of cells and NonConformance information.

If n exceeds the bucket capacity, check_n_at returns NegativeMultiDecision::InsufficientCapacity, indicating that a batch of this many cells can never succeed.

Tests if n cells can be accommodated at the current time (Instant::now()), using check_n_at

Implementors

This crate’s GCRA implementation also allows checking multiple cells at once, assuming that (counter the traffic-shaping properties of GCRA) if a sufficiently long pause (n*t) has occurred between cells, the algorithm can accommodate n cells.

As this assumption does not necessarily hold in all circumstances, users of this trait on GCRA limiters should ensure that this is ok.