Make NewCustomCommitWriteCloser preserve io.Seeker interface#11279
Make NewCustomCommitWriteCloser preserve io.Seeker interface#11279
Conversation
6043a73 to
3e165cb
Compare
vanja-p
left a comment
There was a problem hiding this comment.
I like this in general, partially because I've wanted to make CustomCommitWriteCloser keep the ReadFrom method if it's there. On the other hand, if we wanted to keep ReadFrom as well, we would need 4 implementations of customCommitWriteCloser.
Here are 2 alternatives:
- Since
Seekreturns an error, could the existing, concreteCustomCommitWriteCloseralways have aSeekmethod, and return an error if the underlying writer doesn't support it? We would have to changecachetools.GetBlobto not do the initialSeek. - We could have a
ioutil.GetSeekerfunction, which acceptsx any. If x is anio.Seekerit returns that. If not, it does a type match against all the concrete types inioutil, and returns the underlying reader or writer if it implementsio.Seeker? Thencachetools.GetBlob(andUploadFromReaderWithCompression) would call that instead of doing a type check.
|
@vanja-p I think we should optimize for reduced complexity of the ioutil package interface, rather than reduced complexity of the ioutil package implementation, because it is such a high-utility interface with lots of callers.
I prefer having 4 implementations to both of the above alternatives, since the complexity is hidden in the ioutil package. |
vanja-p
left a comment
There was a problem hiding this comment.
I have a few other comments pending, but SGTM.
0a07bab to
9c44811
Compare
9c44811 to
c8926ae
Compare
Fixes a bug that certain bytestream reads are not retryable, e.g. this one: https://github.com/buildbuddy-io/buildbuddy/blob/e463a996e68a675008b88d96f6da49c6c87d8ff4/server/cache/dirtools/dirtools.go#L1049
Fixes a bug that certain bytestream reads are not retryable, e.g. this one:
buildbuddy/server/cache/dirtools/dirtools.go
Line 1049 in e463a99