From 5d8f93a22a36a93a8009a39e99a7bc2c9b9befaa Mon Sep 17 00:00:00 2001 From: Krasi Georgiev Date: Wed, 1 Nov 2017 22:03:46 +0000 Subject: [PATCH] now using only github.com/gogo/protobuf bumped all grpc-gateway packages to v1.2.2 updated and run the denproto.sh script --- NOTICE | 2 +- documentation/dev/api/swagger.json | 2 +- .../example_write_adapter/server.go | 2 +- prompb/remote.pb.go | 18 -------- prompb/rpc.pb.go | 45 +------------------ prompb/rpc.pb.gw.go | 4 +- prompb/types.pb.go | 35 +++------------ scripts/genproto.sh | 21 +++++---- storage/remote/client.go | 2 +- .../grpc-gateway/runtime/context.go | 2 +- vendor/vendor.json | 23 +++++----- 11 files changed, 37 insertions(+), 119 deletions(-) diff --git a/NOTICE b/NOTICE index 47de2415e..483c255b1 100644 --- a/NOTICE +++ b/NOTICE @@ -52,7 +52,7 @@ Copyright jQuery Foundation and other contributors Licensed under the MIT License Go support for Protocol Buffers - Google's data interchange format -http://github.com/golang/protobuf/ +http://github.com/gogo/protobuf/ Copyright 2010 The Go Authors See source code for license details. diff --git a/documentation/dev/api/swagger.json b/documentation/dev/api/swagger.json index 48e0f31d1..59c07fb83 100644 --- a/documentation/dev/api/swagger.json +++ b/documentation/dev/api/swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "title": "prompb/rpc.proto", + "title": "rpc.proto", "version": "version not set" }, "schemes": [ diff --git a/documentation/examples/remote_storage/example_write_adapter/server.go b/documentation/examples/remote_storage/example_write_adapter/server.go index ec9218797..f33a1de6c 100644 --- a/documentation/examples/remote_storage/example_write_adapter/server.go +++ b/documentation/examples/remote_storage/example_write_adapter/server.go @@ -18,7 +18,7 @@ import ( "io/ioutil" "net/http" - "github.com/golang/protobuf/proto" + "github.com/gogo/protobuf/proto" "github.com/golang/snappy" "github.com/prometheus/common/model" diff --git a/prompb/remote.pb.go b/prompb/remote.pb.go index d3fd751d9..c8570a162 100644 --- a/prompb/remote.pb.go +++ b/prompb/remote.pb.go @@ -308,24 +308,6 @@ func (m *QueryResult) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func encodeFixed64Remote(dAtA []byte, offset int, v uint64) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - dAtA[offset+4] = uint8(v >> 32) - dAtA[offset+5] = uint8(v >> 40) - dAtA[offset+6] = uint8(v >> 48) - dAtA[offset+7] = uint8(v >> 56) - return offset + 8 -} -func encodeFixed32Remote(dAtA []byte, offset int, v uint32) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - return offset + 4 -} func encodeVarintRemote(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) diff --git a/prompb/rpc.pb.go b/prompb/rpc.pb.go index d3807e785..00c685ae0 100644 --- a/prompb/rpc.pb.go +++ b/prompb/rpc.pb.go @@ -1,25 +1,6 @@ -// Code generated by protoc-gen-gogo. +// Code generated by protoc-gen-gogo. DO NOT EDIT. // source: rpc.proto -// DO NOT EDIT! -/* - Package prompb is a generated protocol buffer package. - - It is generated from these files: - rpc.proto - types.proto - - It has these top-level messages: - TSDBSnapshotRequest - TSDBSnapshotResponse - SeriesDeleteRequest - SeriesDeleteResponse - Sample - TimeSeries - Label - Labels - LabelMatcher -*/ package prompb import proto "github.com/gogo/protobuf/proto" @@ -45,12 +26,6 @@ var _ = fmt.Errorf var _ = math.Inf var _ = time.Kitchen -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package - type TSDBSnapshotRequest struct { } @@ -315,24 +290,6 @@ func (m *SeriesDeleteResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func encodeFixed64Rpc(dAtA []byte, offset int, v uint64) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - dAtA[offset+4] = uint8(v >> 32) - dAtA[offset+5] = uint8(v >> 40) - dAtA[offset+6] = uint8(v >> 48) - dAtA[offset+7] = uint8(v >> 56) - return offset + 8 -} -func encodeFixed32Rpc(dAtA []byte, offset int, v uint32) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - return offset + 4 -} func encodeVarintRpc(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) diff --git a/prompb/rpc.pb.gw.go b/prompb/rpc.pb.gw.go index f184e76ac..51c84721f 100644 --- a/prompb/rpc.pb.gw.go +++ b/prompb/rpc.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway -// source: prompb/rpc.proto +// source: rpc.proto // DO NOT EDIT! /* @@ -13,7 +13,7 @@ import ( "io" "net/http" - "github.com/golang/protobuf/proto" + "github.com/gogo/protobuf/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/utilities" "golang.org/x/net/context" diff --git a/prompb/types.pb.go b/prompb/types.pb.go index 5b3140615..35ebf008b 100644 --- a/prompb/types.pb.go +++ b/prompb/types.pb.go @@ -1,6 +1,5 @@ -// Code generated by protoc-gen-gogo. +// Code generated by protoc-gen-gogo. DO NOT EDIT. // source: types.proto -// DO NOT EDIT! package prompb @@ -8,6 +7,8 @@ import proto "github.com/gogo/protobuf/proto" import fmt "fmt" import math "math" +import encoding_binary "encoding/binary" + import io "io" // Reference imports to suppress errors if they are not otherwise used. @@ -189,7 +190,8 @@ func (m *Sample) MarshalTo(dAtA []byte) (int, error) { if m.Value != 0 { dAtA[i] = 0x9 i++ - i = encodeFixed64Types(dAtA, i, uint64(math.Float64bits(float64(m.Value)))) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i += 8 } if m.Timestamp != 0 { dAtA[i] = 0x10 @@ -336,24 +338,6 @@ func (m *LabelMatcher) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func encodeFixed64Types(dAtA []byte, offset int, v uint64) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - dAtA[offset+4] = uint8(v >> 32) - dAtA[offset+5] = uint8(v >> 40) - dAtA[offset+6] = uint8(v >> 48) - dAtA[offset+7] = uint8(v >> 56) - return offset + 8 -} -func encodeFixed32Types(dAtA []byte, offset int, v uint32) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - return offset + 4 -} func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -486,15 +470,8 @@ func (m *Sample) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 - v = uint64(dAtA[iNdEx-8]) - v |= uint64(dAtA[iNdEx-7]) << 8 - v |= uint64(dAtA[iNdEx-6]) << 16 - v |= uint64(dAtA[iNdEx-5]) << 24 - v |= uint64(dAtA[iNdEx-4]) << 32 - v |= uint64(dAtA[iNdEx-3]) << 40 - v |= uint64(dAtA[iNdEx-2]) << 48 - v |= uint64(dAtA[iNdEx-1]) << 56 m.Value = float64(math.Float64frombits(v)) case 2: if wireType != 0 { diff --git a/scripts/genproto.sh b/scripts/genproto.sh index 6afa108b7..190118af7 100755 --- a/scripts/genproto.sh +++ b/scripts/genproto.sh @@ -31,20 +31,19 @@ for dir in ${DIRS}; do -I="${GRPC_GATEWAY_ROOT}/third_party/googleapis" \ *.proto + protoc -I. \ + -I="${GOGOPROTO_PATH}" \ + -I="${PROM_PATH}" \ + -I="${GRPC_GATEWAY_ROOT}/third_party/googleapis" \ + --grpc-gateway_out=logtostderr=true:. \ + --swagger_out=logtostderr=true:../documentation/dev/api/ \ + rpc.proto + mv ../documentation/dev/api/rpc.swagger.json ../documentation/dev/api/swagger.json + sed -i.bak -E 's/import _ \"gogoproto\"//g' *.pb.go sed -i.bak -E 's/import _ \"google\/protobuf\"//g' *.pb.go + sed -i.bak -E 's/golang\/protobuf/gogo\/protobuf/g' *.go rm -f *.bak goimports -w *.pb.go popd done - -protoc -I. \ - -I="${GOGOPROTO_PATH}" \ - -I="${PROM_PATH}" \ - -I="${GRPC_GATEWAY_ROOT}/third_party/googleapis" \ - --grpc-gateway_out=logtostderr=true:. \ - --swagger_out=logtostderr=true:./documentation/dev/api/ \ - prompb/rpc.proto - -mv documentation/dev/api/prompb/rpc.swagger.json documentation/dev/api/swagger.json -rm -rf documentation/dev/api/prompb \ No newline at end of file diff --git a/storage/remote/client.go b/storage/remote/client.go index 82e217690..bba984bc8 100644 --- a/storage/remote/client.go +++ b/storage/remote/client.go @@ -23,7 +23,7 @@ import ( "net/http" "time" - "github.com/golang/protobuf/proto" + "github.com/gogo/protobuf/proto" "github.com/golang/snappy" "github.com/prometheus/common/model" "golang.org/x/net/context/ctxhttp" diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/context.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/context.go index 98eeb44c9..ded3b2e61 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/context.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/context.go @@ -94,7 +94,7 @@ func AnnotateContext(ctx context.Context, req *http.Request) (context.Context, e if len(pairs) == 0 { return ctx, nil } - return metadata.NewContext(ctx, metadata.Pairs(pairs...)), nil + return metadata.NewOutgoingContext(ctx, metadata.Pairs(pairs...)), nil } // ServerMetadata consists of metadata sent from gRPC server. diff --git a/vendor/vendor.json b/vendor/vendor.json index 141e19a53..0f5b66b0b 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -608,25 +608,28 @@ "revisionTime": "2017-06-07T03:48:29Z" }, { - "checksumSHA1": "/SPy/naO5hgJ9w7uWZurcUm2I88=", - "origin": "github.com/cockroachdb/cockroach/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime", + "checksumSHA1": "InNAv3jGuD6SW4qJDBtGQpj0oRI=", "path": "github.com/grpc-ecosystem/grpc-gateway/runtime", - "revision": "2ad234c172af14e85f3be9546f6c64c768d4eccd", - "revisionTime": "2017-04-04T23:42:07Z" + "revision": "589b126116b5fc961939b3e156c29e4d9d58222f", + "revisionTime": "2017-04-17T16:01:37Z", + "version": "=v1.2.2", + "versionExact": "v1.2.2" }, { "checksumSHA1": "et8uiXNw6yM96U/UZgn2vKtyr3Q=", - "origin": "github.com/cockroachdb/cockroach/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/internal", "path": "github.com/grpc-ecosystem/grpc-gateway/runtime/internal", - "revision": "2ad234c172af14e85f3be9546f6c64c768d4eccd", - "revisionTime": "2017-04-04T23:42:07Z" + "revision": "589b126116b5fc961939b3e156c29e4d9d58222f", + "revisionTime": "2017-04-17T16:01:37Z", + "version": "=v1.2.2", + "versionExact": "v1.2.2" }, { "checksumSHA1": "vqiK5r5dntV7JNZ+ZsGlD0Samos=", - "origin": "github.com/cockroachdb/cockroach/vendor/github.com/grpc-ecosystem/grpc-gateway/utilities", "path": "github.com/grpc-ecosystem/grpc-gateway/utilities", - "revision": "2ad234c172af14e85f3be9546f6c64c768d4eccd", - "revisionTime": "2017-04-04T23:42:07Z" + "revision": "589b126116b5fc961939b3e156c29e4d9d58222f", + "revisionTime": "2017-04-17T16:01:37Z", + "version": "=v1.2.2", + "versionExact": "v1.2.2" }, { "checksumSHA1": "/DReHn5j0caPm3thgFD9DmOmibQ=",