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

x/sync: add ordered shutdown package #42193

Closed
ash2k opened this issue Oct 25, 2020 · 2 comments
Closed

x/sync: add ordered shutdown package #42193

ash2k opened this issue Oct 25, 2020 · 2 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@ash2k
Copy link
Contributor

ash2k commented Oct 25, 2020

I built a package that allows to create groups of goroutines on program start and then shut them down in the reverse creation order, group by group. This is very handy to make sure program shuts down cleanly, waiting for all goroutines to finish.

Please have a look at the code https://github.com/ash2k/stager

I've used it in quite a few projects over the years and I thought maybe it'll be useful to the community too. I propose to include it as a package in https://github.com/golang/sync/ repository.

@gopherbot gopherbot added this to the Unreleased milestone Oct 25, 2020
@mvdan
Copy link
Member

mvdan commented Oct 25, 2020

shut them down in the reverse creation order [...] waiting for all goroutines to finish

I imagine you could accomplish the same via defers and a synchronization method like a waitgroup, so it's unclear to me that this is truly needed in x/sync. It's entirely fine for people to use the third party package if they so desire. See https://golang.org/doc/faq#x_in_std.

@mvdan mvdan added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 27, 2020
@ash2k
Copy link
Contributor Author

ash2k commented Oct 27, 2020

Ok, no worries. I just see that errgroup is there and it's even simpler than what I'm suggesting. 🤷

@ash2k ash2k closed this as completed Oct 31, 2020
@golang golang locked and limited conversation to collaborators Oct 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants