Skip to content

Commit 831e31c

Browse files
authored
fix: flush controller periodically case (#577)
1 parent c1ed3d9 commit 831e31c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bottlecap/src/lifecycle/flush_control.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl FlushControl {
7575
.expect("unable to poll clock, unrecoverable")
7676
.as_secs();
7777
match &self.flush_strategy {
78-
FlushStrategy::Default => {
78+
FlushStrategy::Default | FlushStrategy::Periodically(_) => {
7979
if now - self.last_flush > (TWENTY_SECONDS / 1000) {
8080
self.last_flush = now;
8181
true
@@ -118,6 +118,7 @@ mod tests {
118118
let mut flush_control = super::FlushControl::new(FlushStrategy::Default);
119119
assert!(flush_control.should_flush_end());
120120
}
121+
121122
#[test]
122123
fn should_flush_default_periodic() {
123124
const LOOKBACK_COUNT: usize = 20;
@@ -128,6 +129,15 @@ mod tests {
128129
assert!(!flush_control.should_flush_end());
129130
}
130131

132+
#[test]
133+
fn should_flush_custom_periodic() {
134+
let mut flush_control =
135+
super::FlushControl::new(FlushStrategy::Periodically(PeriodicStrategy {
136+
interval: 1,
137+
}));
138+
assert!(flush_control.should_periodic_flush());
139+
}
140+
131141
#[tokio::test]
132142
async fn get_flush_interval() {
133143
let flush_control = FlushControl::new(FlushStrategy::Default);

0 commit comments

Comments
 (0)