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

Use a JoinSet to manage the processor's tasks instead of a Vec #45

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

spencewenski
Copy link
Contributor

With a Vec, the handles are awaited in the order they are inserted. This means that if a tasks exits with an error, it won't be logged until the tasks ahead of it in the Vec complete, which is typically not until the entire application exits.

Tokio provides an alternative structure to track tasks -- a JoinSet. When iterating over a JoinSet, task results are returned in the order that the tasks are completed instead of the order they're spawned. This could potentially be used to optionally shutdown the entire processor if any of its tasks exit with an error (this would be a new config).

With a `Vec`, the handles are awaited in the order they are inserted.
This means that if a tasks exits with an error, it won't be logged until
the tasks ahead of it in the `Vec` complete, which is typically not
until the entire application exits.

Tokio provides an alternative structure to track tasks -- a `JoinSet`.
When iterating over a `JoinSet`, task results are returned in the order
that the tasks are completed instead of the order they're spawned. This
could potentially be used to optionally shutdown the entire processor if
any of its tasks exit with an error (this would be a new config).
Copy link
Owner

@film42 film42 left a comment

Choose a reason for hiding this comment

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

LGTM!

@film42 film42 merged commit 7dc968e into film42:master Apr 26, 2024
1 check passed
@film42
Copy link
Owner

film42 commented Apr 26, 2024

Released as version v0.10.5 🎉 !

@spencewenski spencewenski deleted the processor-joinset branch April 26, 2024 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants