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

improvement: Add Drain() method to tcpjson.AsyncWriter #142

Merged
merged 5 commits into from
Apr 22, 2021

Conversation

bmoylan
Copy link
Contributor

@bmoylan bmoylan commented Apr 21, 2021

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 Reviewable

for {
select {
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, done

Copy link
Contributor

@tabboud tabboud left a comment

Choose a reason for hiding this comment

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

👍

@bulldozer-bot bulldozer-bot bot merged commit 7ac5a9c into develop Apr 22, 2021
@bulldozer-bot bulldozer-bot bot deleted the bm/drain branch April 22, 2021 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants