pub fn update_buckets(&mut self, bytes: Option<TokenBucket>, ops: Option<TokenBucket>) {
        // TODO: We should reconcile the create and update paths, such that they use the same data
        // format. Currently, the TokenBucket config data is used for create, but the live
        // TokenBucket objects are used for update.
        // We have to call make_bucket instead of directly assigning the bytes and/or ops
        // because the RateLimiter validates the TokenBucket config data (e.g. it nullifies
        // an unusable bucket with size 0). This is needed, because passing a 0-sized bucket is
        // the only method the user has to disable rate limiting. I.e. if the user passes `null`
        // as the token bucket config, the old config is left unchanged.

        if let Some(b) = bytes {
            self.bandwidth = Self::make_bucket(b.size, b.one_time_burst, b.refill_time);
        }

        if let Some(b) = ops {
            self.ops = Self::make_bucket(b.size, b.one_time_burst, b.refill_time);
        }
    }
/// Updates the parameters of the token buckets associated with this RateLimiter.
// TODO: Please note that, right now, the buckets become full after being updated.
Updates the parameters of the token buckets associated with this RateLimiter.
TODO: Please note that, right now, the buckets become full after being updated.
Updates the parameters of the token buckets associated with this RateLimiter . TODO : Please note that right now the buckets become full after being updated .
pub fn update_buckets(&mut self, bytes: Option<TokenBucket>, ops: Option<TokenBucket>) {
        // TODO: We should reconcile the create and update paths, such that they use the same data
        // format. Currently, the TokenBucket config data is used for create, but the live
        // TokenBucket objects are used for update.
        // We have to call make_bucket instead of directly assigning the bytes and/or ops
        // because the RateLimiter validates the TokenBucket config data (e.g. it nullifies
        // an unusable bucket with size 0). This is needed, because passing a 0-sized bucket is
        // the only method the user has to disable rate limiting. I.e. if the user passes `null`
        // as the token bucket config, the old config is left unchanged.
        if let Some(b) = bytes {
            self.bandwidth = Self::make_bucket(b.size, b.one_time_burst, b.refill_time);
        }
        if let Some(b) = ops {
            self.ops = Self::make_bucket(b.size, b.one_time_burst, b.refill_time);
        }
    }
pub fn update_buckets ( & mut self , bytes : Option < TokenBucket > , ops : Option < TokenBucket > ) { // TODO: We should reconcile the create and update paths, such that they use the same data // format. Currently, the TokenBucket config data is used for create, but the live // TokenBucket objects are used for update. // We have to call make_bucket instead of directly assigning the bytes and/or ops // because the RateLimiter validates the TokenBucket config data (e.g. it nullifies // an unusable bucket with size 0). This is needed, because passing a 0-sized bucket is // the only method the user has to disable rate limiting. I.e. if the user passes `null` // as the token bucket config, the old config is left unchanged. if let Some ( b ) = bytes { self . bandwidth = Self :: make_bucket ( b . size , b . one_time_burst , b . refill_time ) ; } if let Some ( b ) = ops { self . ops = Self :: make_bucket ( b . size , b . one_time_burst , b . refill_time ) ; } }
Updates the parameters of the token buckets associated with this RateLimiter.
Updates the parameters of the token buckets associated with this RateLimiter .
&mut self
bytes
Option<TokenBucket>
ops
Option<TokenBucket>
&mut self
bytes
Option<TokenBucket>
ops
Option<TokenBucket>