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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: extract 'LeakCheckConfiguration' #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kjgorman
Copy link

馃憢 Hello鈥攖hank you for making this package, I was just about to start copying stuff out of net/http until I found it!

One thing which would be convenient for me is the ability to specify a certain goroutine is "not interesting"鈥攅.g. sometimes my code might be using some other package which starts some internal goroutine which by design runs forever. It would be nice if I could basically add it to the ignore list in the context of that particular test.

This PR attempts to achieve that by factoring out the slice of 'known disinteresting' values to a configuration struct, which can then be customised arbitrarily. The existing surface of the library doesn't change, as the package level functions now delegate to a package global default configuration.

This struct stores the slice of 'RoutinesSafeToIgnore' that are used as filters
in `interestingGoroutines`.

All package public functions for checking now immediately delegate to the
`DefaultCheckConfiguration` which has the previous hard-coded list of values.

This provides an extension point where a consumer of the library can extend the
routines which are safe to ignore (i.e. explicitly allow a certain goroutine to
leak) by either copying the DefaultCheckConfiguration and adding their own
values (ideal), or by simply mutating the default value (less ideal).
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