[draft] cmd/tap: use internal/group for managing the various goroutine components of a tap instance#1295
Draft
davecheney wants to merge 3 commits intomainfrom
Draft
[draft] cmd/tap: use internal/group for managing the various goroutine components of a tap instance#1295davecheney wants to merge 3 commits intomainfrom
davecheney wants to merge 3 commits intomainfrom
Conversation
runResyncWorker takes a context for lifecycle management, however if that context is cancelled -- err != nil -- then the rsync worker will sleep for a second, hit WaitForReady, which returns immediately because the context is cancelled, then claimResyncJob will also return immediately with context.Cancelled, err != nil, so the worker sleeps for a second and tries again, etc. Fix the loop by explicitly checking for the context.Cancelled case and exiting the worker. No test yet, mia culpa.
Naming is hard, group.G, group.Group, both aren't great. I also considered work.Group, but none really light my fire. As a saving grace, this is internal to indigo so we can iterate on the name later.
jcalabro
reviewed
Jan 27, 2026
Member
jcalabro
left a comment
There was a problem hiding this comment.
I like! Can we just import github.com/pkg/group rather than copy+pasting though?
Contributor
Author
This was just sample code I wrote for a talk, I'd rather not adopt another open source project, so for the moment, copying it into an internal package means nobody has to commit to is as something others can use directly. |
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.
This is a worked example of switching from using
goto a group like structure to manage the lifecycle of the various workers inside a tap instance.Because of the way some components, kick off their own child goroutines, this required stacking groups -- not something I'd done before -- but worked surprisingly well. I think the size of the change could be reduced by a preparatory PR which moves more of the worker creation into tap.Run.