Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(reduce): Refactor for timeout=0 #363

Merged
merged 3 commits into from
May 15, 2024
Merged
Changes from 1 commit
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
26 changes: 14 additions & 12 deletions rust-arroyo/src/processing/strategies/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,22 @@ impl<T: Send + Sync, TResult: Send + Sync> ProcessingStrategy<T> for Reduce<T, T

fn join(&mut self, timeout: Option<Duration>) -> Result<Option<CommitRequest>, StrategyError> {
let deadline = timeout.map(Deadline::new);
if self.message_carried_over.is_some() {
while self.message_carried_over.is_some() {
let next_commit = self.next_step.poll()?;
self.commit_request_carried_over =
merge_commit_request(self.commit_request_carried_over.take(), next_commit);
self.flush(true)?;

if deadline.map_or(false, |d| d.has_elapsed()) {
tracing::warn!("Timeout reached while waiting for tasks to finish");
break;
}

loop {
if deadline.map_or(false, |d| d.has_elapsed()) {
tracing::warn!("Timeout {:?} reached while waiting for tasks to finish", timeout);
break;
}
} else {

let next_commit = self.next_step.poll()?;
self.commit_request_carried_over =
merge_commit_request(self.commit_request_carried_over.take(), next_commit);

self.flush(true)?;

if !self.message_carried_over.is_some() {
break;
}
}

let next_commit = self.next_step.join(deadline.map(|d| d.remaining()))?;
Expand Down
Loading