Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions rust-arroyo/src/processing/strategies/healthcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct HealthCheck<Next> {
path: PathBuf,
interval: Duration,
deadline: SystemTime,
iterations_since_last_submit: u64,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using a u64, but maybe we can get away with a u32

}

impl<Next> HealthCheck<Next> {
Expand All @@ -26,6 +27,7 @@ impl<Next> HealthCheck<Next> {
path: path.into(),
interval,
deadline,
iterations_since_last_submit: 0,
}
}

Expand All @@ -50,12 +52,21 @@ where
Next: ProcessingStrategy<TPayload> + 'static,
{
fn poll(&mut self) -> Result<Option<CommitRequest>, StrategyError> {
self.maybe_touch_file();
let poll_result = self.next_step.poll();
if let Ok(Some(_commit_request)) = poll_result.as_ref() {
self.maybe_touch_file();
}

if self.iterations_since_last_submit > 0 {
self.maybe_touch_file();
}

self.next_step.poll()
self.iterations_since_last_submit += 1;
poll_result
}

fn submit(&mut self, message: Message<TPayload>) -> Result<(), SubmitError<TPayload>> {
self.iterations_since_last_submit = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we should check if submit was successful before reseting this counter

self.next_step.submit(message)
}

Expand Down
Loading