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

sync: Add ServiceGroup implementation #15

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sebastianst
Copy link
Contributor

We're often in a situation where we want to start several services in goroutines and then wait for either all of them to return with a nil error or the first to return a non-nil error. So far, we usually either use a bare error channel in such situations or the errors.Gatherer together with WaitDoneOrFail. However, the Gatherer has a rather bloated implementation with several mutexes and other synchronization state and its multi-error feature doesn't help in such situations because there will only be one error once the first routine fails.

So I propose to add a lightweight implementation ServiceGroup that covers this exact use case. It is an eagerly-finishing version of the golang.org/x/sync/errgroup.Group, which always waits for all routines to return.

Don't merge yet, untested and intended as a base for discussion.

Signed-off-by: Sebastian Stammler <seb@perun.network>
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.

None yet

1 participant