Skip to content

[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
dfc/tap-group
Draft

[draft] cmd/tap: use internal/group for managing the various goroutine components of a tap instance#1295
davecheney wants to merge 3 commits intomainfrom
dfc/tap-group

Conversation

@davecheney
Copy link
Contributor

This is a worked example of switching from using go to 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.

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.
Copy link
Member

@jcalabro jcalabro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like! Can we just import github.com/pkg/group rather than copy+pasting though?

@davecheney davecheney changed the title [draft] cmd/tap: use internal/group for managing the various coroutine components of a tap instance [draft] cmd/tap: use internal/group for managing the various goroutine components of a tap instance Jan 27, 2026
@davecheney
Copy link
Contributor Author

I like! Can we just import github.com/pkg/group rather than copy+pasting though?

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.

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.

2 participants