feat(pool): add EachCtx for cancellable fan-out#352
Open
TBX3D wants to merge 1 commit into
Open
Conversation
Each has no way to observe cancellation, so a fan-out scanner (full port sweep, directory brute-force) keeps draining its whole queue even after ctrl-c or -max-time fires. EachCtx takes a context and stops feeding workers once it's cancelled, while still handing the ctx to the callback so an in-flight item can bail out too. Each is now a thin wrapper over EachCtx with context.Background(), so existing callers are unaffected until they opt in.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #352 +/- ##
=======================================
Coverage ? 54.76%
=======================================
Files ? 81
Lines ? 6880
Branches ? 0
=======================================
Hits ? 3768
Misses ? 2842
Partials ? 270 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
pr summary2 files changed (+71 -4)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each has no way to stop early: once -max-time expires or ctrl-c fires, in-flight workers keep draining the whole queue before the pool returns. EachCtx takes a context and stops handing out new items once it's cancelled, while workers already running finish their current item rather than being killed mid-write. Each is now a thin wrapper over EachCtx with context.Background().