-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quit event #1523
base: master
Are you sure you want to change the base?
Quit event #1523
Conversation
s.done <- true | ||
close(s.done) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look quite right. As the done channel is non-blocking, it wouldn't wait for the reader to consume the true event, and just immediately close the channel. That of course, indicates the quite event, by waking up the channel, but most likely the client will not retrieve the true
.
I think that is okay though. And we should just remove line 69 (and the buffer size of 1 on the channel).
|
||
func (r *Resolver) Quit(ctx context.Context) (<-chan bool, error) { | ||
logging.Debug("Quit resolver") | ||
return r.done, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you are returning the r.done
channel which is the same for every subscriber to this quit event, at most one of the subscribers would receive the true
value. But probably none of them (see other comment). All of them would wake up, which we could argue is enough. In that case I would change the return channel to <-chan struct{}
though.
If you actually want to return a true
event on the channel, I think something like this would work here:
return r.done, nil | |
res := make (chan bool) | |
go func() { | |
<-r.done | |
res <- true | |
}() | |
return res, nil |
https://www.pivotaltracker.com/story/show/179151639