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.
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
Add buffered write syncer #952
Add buffered write syncer #952
Changes from 59 commits
c1e68d7
df42521
7f5e097
7eec047
3c8ec7b
046355f
afe872f
cce50b1
ef808a2
3af046a
e0a440d
e571e25
4a25c9f
99f4ea8
223dd97
dd3698e
f3079de
2c09dc4
f0f2a28
fb6efc3
0977e02
65775e1
470b7fa
160e84d
ee04403
80433c2
9bda819
dc370da
2ecf1f8
a522baf
4273b8e
d884534
0392f30
ddace4d
e96c0ee
570d2ff
d1e244a
83f6331
ba0b65e
b8a0b28
1c5daa9
f74c558
6f88240
963142b
f753926
1db4692
545d164
c777047
1b0fcfd
02c9d3f
4804188
4ca46e9
b1a95ff
6d58a7d
2312b39
7c32a14
ffba68b
a3fbb8e
39f7316
10b45db
0962b0f
7dedbc0
f8f3a3d
acfd294
f32b796
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
minor nit: we should specify the defaults above the fields as we document the fields:
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.
minor naming: can we name this init or initialize because the bool is called initialize. Or we can name the bool "loaded" and call this "load", but I'm more in favor of init or initialize.
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.
minor optimization on the WriteSyncer:
since BufferedWriteSyncer is already thread-safe, we can optimize this a bit if s.WriteSyncer was wrapped with
zapcore.Lock
.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.
The warning that this will not close the underlying
WriteSyncer
makes me wonder ifClose
is a little surprising. Would this be better named something else likeStop
to make it very clear that it doesn't close the underlying writer?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.
Reasonable. Renaming.
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.
Sounds good.
Stop
makes more sense in the context of this specific writer.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.
Since this will panic if we do it twice, do we want to explicitly call out that
Close
must only be called once, or put some protection here in caseClose
is called twice?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.
Going with a doc for now. Guarding against it is possible but seems unnecessary given that standard usage will probably be:
(we do need to guard against Stop without Start, so going to add that too.)
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.
Can we wait for the background goroutine to stop before returning here? It leads to:
Close
guaranteedSync
can happen after theClose
returns