[pbs-devel] [PATCH proxmox 7/7] RateLimiter: add update_rate method

Dietmar Maurer dietmar at proxmox.com
Tue Nov 9 07:52:50 CET 2021


---
 proxmox-http/src/client/rate_limiter.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/proxmox-http/src/client/rate_limiter.rs b/proxmox-http/src/client/rate_limiter.rs
index 677dfb1..e669410 100644
--- a/proxmox-http/src/client/rate_limiter.rs
+++ b/proxmox-http/src/client/rate_limiter.rs
@@ -34,6 +34,12 @@ impl RateLimiter {
         }
     }
 
+    /// Update rate and bucket size
+    pub fn update_rate(&mut self, rate: u64, bucket_size: u64) {
+        self.rate = rate;
+        self.bucket_size = bucket_size;
+    }
+
     /// Returns the average rate (since `start_time`)
     pub fn average_rate(&self, current_time: Instant) -> f64 {
         let time_diff = current_time.saturating_duration_since(self.start_time).as_secs_f64();
-- 
2.30.2






More information about the pbs-devel mailing list