Add CancelOnError option to ContextPool
This adds the WithCancelOnError() configuration method to ContextPool and ResultContextPool, and changes the default behavior to not cancel the pool's context on error.
ContextPool initially canceled by default because otherwise, it's no different than an ErrorPool that captures a context from its environment. However, doing this by default is surprising and should be explicitly opt-in.
Codecov Report
Merging #23 (f13fcd7) into main (df84427) will increase coverage by
0.01%. The diff coverage is100.00%.
@@ Coverage Diff @@
## main #23 +/- ##
==========================================
+ Coverage 99.42% 99.44% +0.01%
==========================================
Files 10 10
Lines 350 358 +8
==========================================
+ Hits 348 356 +8
Misses 2 2
| Impacted Files | Coverage Δ | |
|---|---|---|
| pool/context_pool.go | 100.00% <100.00%> (ø) |
|
| pool/result_context_pool.go | 100.00% <100.00%> (ø) |
|
| waitgroup.go | 100.00% <0.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Another idea - if we eventually add various cancel behaviours, should we offer a consistent naming scheme like CancelXYZ?
eg
-
CancelOnError()(renamedFailFast) -
CancelAfterErrors(n int) -
Cancel()
That makes sense to me. Additionally, WithCancelOnError() is a little more verbose, but much more clear to readers what it actually does. I'd need to take a look at the docs for WithFastFail().