pkg/beholder: add Emitter.Close; track goroutines#1628
Merged
Conversation
|
3d43cb0 to
4221639
Compare
4221639 to
5973751
Compare
pavel-raykov
previously approved these changes
Oct 21, 2025
jmank88
commented
Oct 21, 2025
pkcll
reviewed
Oct 21, 2025
| } | ||
|
|
||
| func (d *DualSourceEmitter) Close() error { | ||
| close(d.stopCh) |
Contributor
There was a problem hiding this comment.
Do you need to guard against Close being called multiple times to prevent panic here?
Contributor
Author
There was a problem hiding this comment.
Close isn't meant to be called more than once, and I would worry about covering that up with a defensive check 🤔 I guess we could return an error
5973751 to
850b659
Compare
pavel-raykov
approved these changes
Oct 21, 2025
pkcll
approved these changes
Oct 21, 2025
kirqz23
reviewed
Oct 21, 2025
| return errors.New("already closed") | ||
| } | ||
| close(d.stopCh) | ||
| d.wg.Wait() |
Contributor
There was a problem hiding this comment.
Yeah, waiting first and then closing is probably better to avoid race condition
kirqz23
approved these changes
Oct 21, 2025
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.
I noticed that the
DualSourceEmitteris launching goroutines without tracking them. This PR extends the interface to implementio.Closer. Alternatively, we could only do that with the concrete types, but we would be trading some no-op boilerplate for opaque casting, so this seems safer.