Skip to content

Commit 760dda4

Browse files
PawelJastrzebskieaufavor
authored andcommitted
pingora-limits - Rate Estimator hashes & slots configuration
--- fix cargo fmt check Includes-commit: 19eeddc Includes-commit: 4198702 Replicated-from: #380
1 parent 6d917b4 commit 760dda4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.bleep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6923a7f31ed6fff1ddaf00ffb8dd56311042c395
1+
9b92c0fed7b703c61415414c69ff196e9deb11eb

pingora-limits/src/rate.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,19 @@ const SLOTS: usize = 1024; // This value can be lower if interval is short (key
4343
impl Rate {
4444
/// Create a new `Rate` with the given interval.
4545
pub fn new(interval: std::time::Duration) -> Self {
46+
Rate::new_with_estimator_config(interval, HASHES, SLOTS)
47+
}
48+
49+
/// Create a new `Rate` with the given interval and Estimator config with the given amount of hashes and columns (slots).
50+
#[inline]
51+
pub fn new_with_estimator_config(
52+
interval: std::time::Duration,
53+
hashes: usize,
54+
slots: usize,
55+
) -> Self {
4656
Rate {
47-
red_slot: Estimator::new(HASHES, SLOTS),
48-
blue_slot: Estimator::new(HASHES, SLOTS),
57+
red_slot: Estimator::new(hashes, slots),
58+
blue_slot: Estimator::new(hashes, slots),
4959
red_or_blue: AtomicBool::new(true),
5060
start: Instant::now(),
5161
reset_interval_ms: interval.as_millis() as u64, // should be small not to overflow

0 commit comments

Comments
 (0)