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

Ability to shutdown global pool #92

Open
polds opened this issue Dec 10, 2024 · 2 comments
Open

Ability to shutdown global pool #92

polds opened this issue Dec 10, 2024 · 2 comments

Comments

@polds
Copy link

polds commented Dec 10, 2024

Hey, we've been trying to adopt https://github.com/uber-go/goleak to catch left open goroutines and since the upgrade to V2 with the global pool this check fails because Pool doesn't ever shutdown its global pool. It'd be nice if we could have a method to shutdown this down with the obvious caveat it's no longer usable, but where we can correctly manage lifecycles it'd be great to have this.

@alitto
Copy link
Owner

alitto commented Dec 10, 2024

Hey @polds
This is a good point. Perhaps the most straightforward way to expose the default pool shutdown would be to do so via a package level function like pond.Stop() and pond.StopAndWait(). Another option would be to expose the whole pool object via a package-level variable like pond.DefaultPool, but I prefer the first option.
Do you think that would be enough to pass the validation performed by goleak?

@polds
Copy link
Author

polds commented Dec 10, 2024

I think adding pond.Stop() and pond.StopAndWait() would work. For our use cases we have explicit shutdown methods that can teardown all dependencies so calling this and eventually returning to the goleak test should allow it to pass.

I agree about pond.Stop()/StopAndWait() but I'd probably mention that it shuts down the default pool and not all pools. The API as-is might make someone think it would shutdown all pools.

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

No branches or pull requests

2 participants