Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: common/logdog/butlerproto/proto.go

Issue 1610993002: LogDog: Add collector service implementation. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: common/logdog/butlerproto/proto.go
diff --git a/common/logdog/butlerproto/proto.go b/common/logdog/butlerproto/proto.go
index ccd1d7b942fbd088589f2d502adebf2c2a3058b2..6fd57a67ab037f1a29718723b30cb0e1075b4b7f 100644
--- a/common/logdog/butlerproto/proto.go
+++ b/common/logdog/butlerproto/proto.go
@@ -126,16 +126,13 @@ func (r *Reader) Read(ir io.Reader) error {
return fmt.Errorf("butlerproto: failed to read Bundle data: %s", err)
}
- if r.Metadata.ProtoVersion != protocol.Version {
- return fmt.Errorf("butlerproto: unknown protobuf version (%q != %q)",
- r.Metadata.ProtoVersion, protocol.Version)
+ if r.Metadata.ProtoVersion == protocol.Version {
dnj (Google) 2016/01/21 04:36:24 Instead of rejecting messages without a known vers
+ bundle := protocol.ButlerLogBundle{}
+ if err := proto.Unmarshal(data, &bundle); err != nil {
+ return fmt.Errorf("butlerproto: failed to unmarshal Bundle frame: %s", err)
+ }
+ r.Bundle = &bundle
}
-
- bundle := protocol.ButlerLogBundle{}
- if err := proto.Unmarshal(data, &bundle); err != nil {
- return fmt.Errorf("butlerproto: failed to unmarshal Bundle frame: %s", err)
- }
- r.Bundle = &bundle
return nil
default:
@@ -169,6 +166,10 @@ func (r *limitErrorReader) Read(p []byte) (int, error) {
type Writer struct {
protoBase
+ // ProtoVersion is the protocol version string to use. If empty, the current
dnj (Google) 2016/01/21 04:36:24 Useful for testing: "hey, pretend that you wrote t
+ // ProtoVersion will be used.
+ ProtoVersion string
+
// Compress, if true, allows the Writer to choose to compress data when
// applicable.
Compress bool
@@ -185,9 +186,13 @@ func (w *Writer) writeData(fw recordio.Writer, t protocol.ButlerMetadata_Content
return fmt.Errorf("butlerproto: serialized size exceeds soft cap (%d > %d)", len(data), w.getMaxSize())
}
+ pv := w.ProtoVersion
+ if pv == "" {
+ pv = protocol.Version
+ }
md := protocol.ButlerMetadata{
Type: t,
- ProtoVersion: protocol.Version,
+ ProtoVersion: pv,
}
// If we're configured to compress and the data is below our threshold,

Powered by Google App Engine
This is Rietveld 408576698