-
Notifications
You must be signed in to change notification settings - Fork 12
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
improvement: Add Drain() method to tcpjson.AsyncWriter #142
Conversation
for { | ||
select { |
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.
I don't believe we need this select block as the one below also includes selecting on <-stop
and no where do we actually close the buffer chan
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.
It's an edge case, but this is attempting to handle where, at the start of the iteration, stop
has been closed but there are still items in the buffer. In that case, the second select with both cases will nondeterministically choose one. Without the explicit check at the top, we could run for an unbound time after Close
has been called.
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.
Ok got it, that makes sense then. Do you mind adding a short comment above this select to mention that this is guarding that edge case?
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.
Yup, 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 will get used during a process's shutdown when it wants to ensure that all logs have been sent to the TCP receiver.
This change is