-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
binarylog: export Sink #3879
binarylog: export Sink #3879
Conversation
b791cb8
to
e38967d
Compare
So the sink can be updated (instead of only being noop)
binarylog/sink.go
Outdated
Close() error | ||
} | ||
|
||
type bufWriteCloserSink struct { |
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 think we should merge the functionality of writerSink
into this one. It is not very easy to read at this point.
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.
They cannot be merged, because test needs writerSink.
I moved it back to internal, right next to the writerSink.
binarylog/sink.go
Outdated
|
||
func (fs *bufWriteCloserSink) Write(e *pb.GrpcLogEntry) error { | ||
// Start the write loop when Write is called. | ||
fs.writeStartOnce.Do(fs.startFlushGoroutine) |
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.
We could simply start this goroutine from the new*
function and get rid of this Once
. And the ticker
would then become a local variable inside the goroutine. It would also make Write
more readable, since we would only be writing stuff here.
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 want to start the flush goroutine unless Write
happens.
|
||
// NewTempFileSink creates a temp file and returns a Sink that writes to this | ||
// file. | ||
func NewTempFileSink() (Sink, error) { |
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.
Would it make more sense to get the name of the file to write to from the user? The way it is right now, the user would just to go over to the tmp
dir and figure out the file for themselves.
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.
That is reasonable, and in that case we would just export NewBufferedSink
from internal. But there's no tool to read the file content anyway, so I would expect users to just implement their own Sink.
I'm leaving this as is for now (I added comment to remind us later). We can decide what to export based on what users want.
So the sink can be updated (instead of only being noop)
fixes #3878