Skip to content
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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Quit event #1523

wants to merge 13 commits into from

Conversation

MDrakos
Copy link
Member

@MDrakos MDrakos commented Aug 26, 2021

@MDrakos MDrakos requested a review from mdrohmann August 26, 2021 21:35
Comment on lines 69 to 70
s.done <- true
close(s.done)
Copy link
Collaborator

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
Copy link
Collaborator

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:

Suggested change
return r.done, nil
res := make (chan bool)
go func() {
<-r.done
res <- true
}()
return res, nil

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