From d047ea7cdd6f25da0b1888b188f59f1d756918b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20P=C5=82otka?= Date: Thu, 22 Aug 2019 10:21:12 +0100 Subject: [PATCH] Fixed some misspells, added couple of useful linters. (#1446) Signed-off-by: Bartek Plotka --- CHANGELOG.md | 2 +- Makefile | 26 +- docs/components/query.md | 2 +- .../contributing/how-to-contribute-to-docs.md | 2 +- pkg/promclient/promclient_e2e_test.go | 2 +- pkg/receive/handler.go | 2 +- pkg/store/prompb/remote.pb.go | 459 ++++++++------- pkg/store/storepb/rpc.pb.go | 532 ++++++++++-------- pkg/store/storepb/rpc.proto | 6 +- pkg/store/storepb/types.pb.go | 331 ++++++----- .../manifests/prometheus-pv-0.yaml | 2 +- 11 files changed, 784 insertions(+), 582 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf7ea8d52e..0959ed4a25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -273,7 +273,7 @@ Note that this is required to have SRV resolution working on [Golang 1.11+ with * [ENHANCEMENT] When closing the db any running compaction will be cancelled so it doesn't block. * [CHANGE] *breaking* Renamed flag `--sync-delay` to `--consistency-delay` [#1053](https://github.com/thanos-io/thanos/pull/1053) - For ruler essentially whole TSDB CHANGELOG applies beween v0.4.0-v0.6.1: https://github.com/prometheus/tsdb/blob/master/CHANGELOG.md + For ruler essentially whole TSDB CHANGELOG applies between v0.4.0-v0.6.1: https://github.com/prometheus/tsdb/blob/master/CHANGELOG.md Note that this was added on TSDB and Prometheus: [FEATURE] Time-ovelapping blocks are now allowed. #370 Whoever due to nature of Thanos compaction (distributed systems), for safety reason this is disabled for Thanos compactor for now. diff --git a/Makefile b/Makefile index 487811300d..af44bef969 100644 --- a/Makefile +++ b/Makefile @@ -30,10 +30,11 @@ HUGO ?= $(GOBIN)/hugo-$(HUGO_VERSION) GOBINDATA_VERSION ?= a9c83481b38ebb1c4eb8f0168fd4b10ca1d3c523 GOBINDATA ?= $(GOBIN)/go-bindata-$(GOBINDATA_VERSION) GIT ?= $(shell which git) -# golangci-lint which includes errcheck, goimports -# and more. v1.16.0 -GOLANGCILINT_VERSION ?= 97ea1cbb21bbf5e4d0e8bcc0f9243385e9262dcc -GOLANGCILINT ?= $(GOBIN)/golangci-lint-$(GOLANGCILINT_VERSION) + +GOLANGCILINT_VERSION ?= d2b1eea2c6171a1a1141a448a745335ce2e928a1 +GOLANGCILINT ?= $(GOBIN)/golangci-lint-$(GOLANGCILINT_VERSION) +MISSPELL_VERSION ?= c0b55c8239520f6b5aa15a0207ca8b28027ba49e +MISSPELL ?= $(GOBIN)/misspell-$(MISSPELL_VERSION) WEB_DIR ?= website WEBSITE_BASE_URL ?= https://thanos.io @@ -229,11 +230,17 @@ web: web-pre-process $(HUGO) @cd $(WEB_DIR) && HUGO_ENV=production $(HUGO) --config hugo.yaml --minify -v -b $(WEBSITE_BASE_URL) .PHONY: lint -lint: check-git $(GOLANGCILINT) - @echo ">> checking formatting" - @$(GOLANGCILINT) run -v --disable-all -E goimports ./... +# PROTIP: +# Add +# --cpu-profile-path string Path to CPU profile output file +# --mem-profile-path string Path to memory profile output file +# +# to debug big allocations during linting. +lint: check-git $(GOLANGCILINT) $(MISSPELL) @echo ">> linting all of the Go files" - @$(GOLANGCILINT) run -v ./... + @$(GOLANGCILINT) run -v --enable goimports --enable goconst --skip-dirs vendor + @echo ">> detecting misspells" + @find . -type f | grep -v vendor/ | grep -vE '\./\..*' | xargs $(MISSPELL) -error .PHONY: web-serve web-serve: web-pre-process $(HUGO) @@ -264,6 +271,9 @@ $(GOBINDATA): $(GOLANGCILINT): $(call fetch_go_bin_version,github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCILINT_VERSION)) +$(MISSPELL): + $(call fetch_go_bin_version,github.com/client9/misspell/cmd/misspell,$(MISSPELL_VERSION)) + $(PROTOC): @mkdir -p $(TMP_GOPATH) @echo ">> fetching protoc@${PROTOC_VERSION}" diff --git a/docs/components/query.md b/docs/components/query.md index 82122f108c..c6d7a86c89 100644 --- a/docs/components/query.md +++ b/docs/components/query.md @@ -149,7 +149,7 @@ It is possible to expose thanos-query UI and optionally API on a sub-path. The sub-path can be defined either statically or dynamically via an HTTP header. Static path prefix definition follows the pattern used in Prometheus, where `web.route-prefix` option defines HTTP request path prefix (endpoints prefix) -and `web.external-prefix` prefixes the URLs in HTML code and the HTTP redirect responces. +and `web.external-prefix` prefixes the URLs in HTML code and the HTTP redirect responses. Additionally, Thanos supports dynamic prefix configuration, which [is not yet implemented by Prometheus](https://github.com/prometheus/prometheus/issues/3156). diff --git a/docs/contributing/how-to-contribute-to-docs.md b/docs/contributing/how-to-contribute-to-docs.md index 27ee6e985a..b8669e25bd 100644 --- a/docs/contributing/how-to-contribute-to-docs.md +++ b/docs/contributing/how-to-contribute-to-docs.md @@ -24,7 +24,7 @@ in GitHub as markdown just fine: title: type: ... weight: -menu: # This also is refered in permalinks. +menu: # This also is referred in permalinks. --- ``` diff --git a/pkg/promclient/promclient_e2e_test.go b/pkg/promclient/promclient_e2e_test.go index 9df921e241..a88a134e7c 100644 --- a/pkg/promclient/promclient_e2e_test.go +++ b/pkg/promclient/promclient_e2e_test.go @@ -125,7 +125,7 @@ func TestSnapshot_e2e(t *testing.T) { func TestRule_UnmarshalScalarResponse(t *testing.T) { var ( scalarJSONResult = []byte(`[1541196373.677,"1"]`) - invalidLengthScalarJSONResult = []byte(`[1541196373.677,"1", "nonsence"]`) + invalidLengthScalarJSONResult = []byte(`[1541196373.677,"1", "nonsense"]`) invalidDataScalarJSONResult = []byte(`["foo","bar"]`) vectorResult model.Vector diff --git a/pkg/receive/handler.go b/pkg/receive/handler.go index ca23a1ad8f..82385f8855 100644 --- a/pkg/receive/handler.go +++ b/pkg/receive/handler.go @@ -240,7 +240,7 @@ func (h *Handler) receive(w http.ResponseWriter, r *http.Request) { var rep replica replicaRaw := r.Header.Get(h.options.ReplicaHeader) - // If the header is emtpy, we assume the request is not yet replicated. + // If the header is empty, we assume the request is not yet replicated. if replicaRaw != "" { if rep.n, err = strconv.ParseUint(replicaRaw, 10, 64); err != nil { http.Error(w, "could not parse replica header", http.StatusBadRequest) diff --git a/pkg/store/prompb/remote.pb.go b/pkg/store/prompb/remote.pb.go index 1a3cf351ee..26b2b8061b 100644 --- a/pkg/store/prompb/remote.pb.go +++ b/pkg/store/prompb/remote.pb.go @@ -8,6 +8,7 @@ import ( fmt "fmt" io "io" math "math" + math_bits "math/bits" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -76,7 +77,7 @@ func (m *WriteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_WriteRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -116,7 +117,7 @@ func (m *ReadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_ReadRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -157,7 +158,7 @@ func (m *ReadResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_ReadResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -200,7 +201,7 @@ func (m *Query) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Query.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -240,7 +241,7 @@ func (m *QueryResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_QueryResult.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -281,7 +282,7 @@ func (m *Sample) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Sample.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -322,7 +323,7 @@ func (m *TimeSeries) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_TimeSeries.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -363,7 +364,7 @@ func (m *Label) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Label.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -406,7 +407,7 @@ func (m *LabelMatcher) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_LabelMatcher.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -449,7 +450,7 @@ func (m *ReadHints) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_ReadHints.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -525,7 +526,7 @@ var fileDescriptor_eefc82927d57d89b = []byte{ func (m *WriteRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -533,32 +534,40 @@ func (m *WriteRequest) Marshal() (dAtA []byte, err error) { } func (m *WriteRequest) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WriteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } if len(m.Timeseries) > 0 { - for _, msg := range m.Timeseries { - dAtA[i] = 0xa - i++ - i = encodeVarintRemote(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Timeseries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Timeseries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRemote(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0xa } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil + return len(dAtA) - i, nil } func (m *ReadRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -566,32 +575,40 @@ func (m *ReadRequest) Marshal() (dAtA []byte, err error) { } func (m *ReadRequest) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ReadRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } if len(m.Queries) > 0 { - for _, msg := range m.Queries { - dAtA[i] = 0xa - i++ - i = encodeVarintRemote(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Queries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Queries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRemote(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0xa } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil + return len(dAtA) - i, nil } func (m *ReadResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -599,32 +616,40 @@ func (m *ReadResponse) Marshal() (dAtA []byte, err error) { } func (m *ReadResponse) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ReadResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } if len(m.Results) > 0 { - for _, msg := range m.Results { - dAtA[i] = 0xa - i++ - i = encodeVarintRemote(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Results[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRemote(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0xa } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil + return len(dAtA) - i, nil } func (m *Query) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -632,52 +657,62 @@ func (m *Query) Marshal() (dAtA []byte, err error) { } func (m *Query) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Query) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.StartTimestampMs != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintRemote(dAtA, i, uint64(m.StartTimestampMs)) - } - if m.EndTimestampMs != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintRemote(dAtA, i, uint64(m.EndTimestampMs)) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if len(m.Matchers) > 0 { - for _, msg := range m.Matchers { - dAtA[i] = 0x1a - i++ - i = encodeVarintRemote(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) + if m.Hints != nil { + { + size, err := m.Hints.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } - i += n + i -= size + i = encodeVarintRemote(dAtA, i, uint64(size)) } - } - if m.Hints != nil { + i-- dAtA[i] = 0x22 - i++ - i = encodeVarintRemote(dAtA, i, uint64(m.Hints.Size())) - n1, err := m.Hints.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + } + if len(m.Matchers) > 0 { + for iNdEx := len(m.Matchers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Matchers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRemote(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } - i += n1 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.EndTimestampMs != 0 { + i = encodeVarintRemote(dAtA, i, uint64(m.EndTimestampMs)) + i-- + dAtA[i] = 0x10 } - return i, nil + if m.StartTimestampMs != 0 { + i = encodeVarintRemote(dAtA, i, uint64(m.StartTimestampMs)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } func (m *QueryResult) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -685,32 +720,40 @@ func (m *QueryResult) Marshal() (dAtA []byte, err error) { } func (m *QueryResult) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } if len(m.Timeseries) > 0 { - for _, msg := range m.Timeseries { - dAtA[i] = 0xa - i++ - i = encodeVarintRemote(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Timeseries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Timeseries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRemote(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0xa } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil + return len(dAtA) - i, nil } func (m *Sample) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -718,31 +761,37 @@ func (m *Sample) Marshal() (dAtA []byte, err error) { } func (m *Sample) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Sample) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.Value != 0 { - dAtA[i] = 0x9 - i++ - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) - i += 8 + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if m.Timestamp != 0 { - dAtA[i] = 0x10 - i++ i = encodeVarintRemote(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x10 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.Value != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i-- + dAtA[i] = 0x9 } - return i, nil + return len(dAtA) - i, nil } func (m *TimeSeries) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -750,44 +799,54 @@ func (m *TimeSeries) Marshal() (dAtA []byte, err error) { } func (m *TimeSeries) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TimeSeries) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Labels) > 0 { - for _, msg := range m.Labels { - dAtA[i] = 0xa - i++ - i = encodeVarintRemote(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Samples) > 0 { - for _, msg := range m.Samples { - dAtA[i] = 0x12 - i++ - i = encodeVarintRemote(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Samples) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Samples[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRemote(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0x12 } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Labels) > 0 { + for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Labels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRemote(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } - return i, nil + return len(dAtA) - i, nil } func (m *Label) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -795,32 +854,40 @@ func (m *Label) Marshal() (dAtA []byte, err error) { } func (m *Label) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Label) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Name) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintRemote(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Value) > 0 { - dAtA[i] = 0x12 - i++ + i -= len(m.Value) + copy(dAtA[i:], m.Value) i = encodeVarintRemote(dAtA, i, uint64(len(m.Value))) - i += copy(dAtA[i:], m.Value) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintRemote(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *LabelMatcher) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -828,37 +895,45 @@ func (m *LabelMatcher) Marshal() (dAtA []byte, err error) { } func (m *LabelMatcher) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LabelMatcher) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.Type != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintRemote(dAtA, i, uint64(m.Type)) - } - if len(m.Name) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintRemote(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Value) > 0 { - dAtA[i] = 0x1a - i++ + i -= len(m.Value) + copy(dAtA[i:], m.Value) i = encodeVarintRemote(dAtA, i, uint64(len(m.Value))) - i += copy(dAtA[i:], m.Value) + i-- + dAtA[i] = 0x1a } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintRemote(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if m.Type != 0 { + i = encodeVarintRemote(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 } - return i, nil + return len(dAtA) - i, nil } func (m *ReadHints) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -866,45 +941,54 @@ func (m *ReadHints) Marshal() (dAtA []byte, err error) { } func (m *ReadHints) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ReadHints) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.StepMs != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintRemote(dAtA, i, uint64(m.StepMs)) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if len(m.Func) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintRemote(dAtA, i, uint64(len(m.Func))) - i += copy(dAtA[i:], m.Func) + if m.EndMs != 0 { + i = encodeVarintRemote(dAtA, i, uint64(m.EndMs)) + i-- + dAtA[i] = 0x20 } if m.StartMs != 0 { - dAtA[i] = 0x18 - i++ i = encodeVarintRemote(dAtA, i, uint64(m.StartMs)) + i-- + dAtA[i] = 0x18 } - if m.EndMs != 0 { - dAtA[i] = 0x20 - i++ - i = encodeVarintRemote(dAtA, i, uint64(m.EndMs)) + if len(m.Func) > 0 { + i -= len(m.Func) + copy(dAtA[i:], m.Func) + i = encodeVarintRemote(dAtA, i, uint64(len(m.Func))) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.StepMs != 0 { + i = encodeVarintRemote(dAtA, i, uint64(m.StepMs)) + i-- + dAtA[i] = 0x8 } - return i, nil + return len(dAtA) - i, nil } func encodeVarintRemote(dAtA []byte, offset int, v uint64) int { + offset -= sovRemote(v) + base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 offset++ } dAtA[offset] = uint8(v) - return offset + 1 + return base } func (m *WriteRequest) Size() (n int) { if m == nil { @@ -1117,14 +1201,7 @@ func (m *ReadHints) Size() (n int) { } func sovRemote(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n + return (math_bits.Len64(x|1) + 6) / 7 } func sozRemote(x uint64) (n int) { return sovRemote(uint64((x << 1) ^ uint64((int64(x) >> 63)))) diff --git a/pkg/store/storepb/rpc.pb.go b/pkg/store/storepb/rpc.pb.go index c629d7621a..229f81c2ba 100644 --- a/pkg/store/storepb/rpc.pb.go +++ b/pkg/store/storepb/rpc.pb.go @@ -8,10 +8,13 @@ import ( fmt "fmt" io "io" math "math" + math_bits "math/bits" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" ) // Reference imports to suppress errors if they are not otherwise used. @@ -153,7 +156,7 @@ func (m *InfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_InfoRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -199,7 +202,7 @@ func (m *InfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_InfoResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -239,7 +242,7 @@ func (m *LabelSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_LabelSet.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -266,7 +269,7 @@ type SeriesRequest struct { Aggregates []Aggr `protobuf:"varint,5,rep,packed,name=aggregates,proto3,enum=thanos.Aggr" json:"aggregates,omitempty"` // Deprecated. Use partial_response_strategy instead. PartialResponseDisabled bool `protobuf:"varint,6,opt,name=partial_response_disabled,json=partialResponseDisabled,proto3" json:"partial_response_disabled,omitempty"` - // TODO(bwplotka): Move Thanos components to use strategy instead. Inlcuding QueryAPI. + // TODO(bwplotka): Move Thanos components to use strategy instead. Including QueryAPI. PartialResponseStrategy PartialResponseStrategy `protobuf:"varint,7,opt,name=partial_response_strategy,json=partialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partial_response_strategy,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -287,7 +290,7 @@ func (m *SeriesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return xxx_messageInfo_SeriesRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -330,7 +333,7 @@ func (m *SeriesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return xxx_messageInfo_SeriesResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -458,7 +461,7 @@ func _SeriesResponse_OneofSizer(msg proto.Message) (n int) { type LabelNamesRequest struct { PartialResponseDisabled bool `protobuf:"varint,1,opt,name=partial_response_disabled,json=partialResponseDisabled,proto3" json:"partial_response_disabled,omitempty"` - // TODO(bwplotka): Move Thanos components to use strategy instead. Inlcuding QueryAPI. + // TODO(bwplotka): Move Thanos components to use strategy instead. Including QueryAPI. PartialResponseStrategy PartialResponseStrategy `protobuf:"varint,2,opt,name=partial_response_strategy,json=partialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partial_response_strategy,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -479,7 +482,7 @@ func (m *LabelNamesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return xxx_messageInfo_LabelNamesRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -520,7 +523,7 @@ func (m *LabelNamesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return xxx_messageInfo_LabelNamesResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -542,7 +545,7 @@ var xxx_messageInfo_LabelNamesResponse proto.InternalMessageInfo type LabelValuesRequest struct { Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"` PartialResponseDisabled bool `protobuf:"varint,2,opt,name=partial_response_disabled,json=partialResponseDisabled,proto3" json:"partial_response_disabled,omitempty"` - // TODO(bwplotka): Move Thanos components to use strategy instead. Inlcuding QueryAPI. + // TODO(bwplotka): Move Thanos components to use strategy instead. Including QueryAPI. PartialResponseStrategy PartialResponseStrategy `protobuf:"varint,3,opt,name=partial_response_strategy,json=partialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partial_response_strategy,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -563,7 +566,7 @@ func (m *LabelValuesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return xxx_messageInfo_LabelValuesRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -604,7 +607,7 @@ func (m *LabelValuesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return xxx_messageInfo_LabelValuesResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -798,6 +801,23 @@ type StoreServer interface { LabelValues(context.Context, *LabelValuesRequest) (*LabelValuesResponse, error) } +// UnimplementedStoreServer can be embedded to have forward compatible implementations. +type UnimplementedStoreServer struct { +} + +func (*UnimplementedStoreServer) Info(ctx context.Context, req *InfoRequest) (*InfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Info not implemented") +} +func (*UnimplementedStoreServer) Series(req *SeriesRequest, srv Store_SeriesServer) error { + return status.Errorf(codes.Unimplemented, "method Series not implemented") +} +func (*UnimplementedStoreServer) LabelNames(ctx context.Context, req *LabelNamesRequest) (*LabelNamesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LabelNames not implemented") +} +func (*UnimplementedStoreServer) LabelValues(ctx context.Context, req *LabelValuesRequest) (*LabelValuesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LabelValues not implemented") +} + func RegisterStoreServer(s *grpc.Server, srv StoreServer) { s.RegisterService(&_Store_serviceDesc, srv) } @@ -907,7 +927,7 @@ var _Store_serviceDesc = grpc.ServiceDesc{ func (m *InfoRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -915,20 +935,26 @@ func (m *InfoRequest) Marshal() (dAtA []byte, err error) { } func (m *InfoRequest) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - return i, nil + return len(dAtA) - i, nil } func (m *InfoResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -936,59 +962,69 @@ func (m *InfoResponse) Marshal() (dAtA []byte, err error) { } func (m *InfoResponse) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Labels) > 0 { - for _, msg := range m.Labels { - dAtA[i] = 0xa - i++ - i = encodeVarintRpc(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.LabelSets) > 0 { + for iNdEx := len(m.LabelSets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LabelSets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRpc(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0x2a } } - if m.MinTime != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.MinTime)) + if m.StoreType != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.StoreType)) + i-- + dAtA[i] = 0x20 } if m.MaxTime != 0 { - dAtA[i] = 0x18 - i++ i = encodeVarintRpc(dAtA, i, uint64(m.MaxTime)) + i-- + dAtA[i] = 0x18 } - if m.StoreType != 0 { - dAtA[i] = 0x20 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.StoreType)) + if m.MinTime != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.MinTime)) + i-- + dAtA[i] = 0x10 } - if len(m.LabelSets) > 0 { - for _, msg := range m.LabelSets { - dAtA[i] = 0x2a - i++ - i = encodeVarintRpc(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if len(m.Labels) > 0 { + for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Labels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRpc(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0xa } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil + return len(dAtA) - i, nil } func (m *LabelSet) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -996,32 +1032,40 @@ func (m *LabelSet) Marshal() (dAtA []byte, err error) { } func (m *LabelSet) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LabelSet) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } if len(m.Labels) > 0 { - for _, msg := range m.Labels { - dAtA[i] = 0xa - i++ - i = encodeVarintRpc(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Labels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRpc(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0xa } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil + return len(dAtA) - i, nil } func (m *SeriesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1029,36 +1073,33 @@ func (m *SeriesRequest) Marshal() (dAtA []byte, err error) { } func (m *SeriesRequest) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SeriesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.MinTime != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.MinTime)) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if m.MaxTime != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.MaxTime)) + if m.PartialResponseStrategy != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) + i-- + dAtA[i] = 0x38 } - if len(m.Matchers) > 0 { - for _, msg := range m.Matchers { - dAtA[i] = 0x1a - i++ - i = encodeVarintRpc(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n + if m.PartialResponseDisabled { + i-- + if m.PartialResponseDisabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 } - } - if m.MaxResolutionWindow != 0 { - dAtA[i] = 0x20 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.MaxResolutionWindow)) + i-- + dAtA[i] = 0x30 } if len(m.Aggregates) > 0 { dAtA2 := make([]byte, len(m.Aggregates)*10) @@ -1072,36 +1113,48 @@ func (m *SeriesRequest) MarshalTo(dAtA []byte) (int, error) { dAtA2[j1] = uint8(num) j1++ } - dAtA[i] = 0x2a - i++ + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) i = encodeVarintRpc(dAtA, i, uint64(j1)) - i += copy(dAtA[i:], dAtA2[:j1]) + i-- + dAtA[i] = 0x2a } - if m.PartialResponseDisabled { - dAtA[i] = 0x30 - i++ - if m.PartialResponseDisabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + if m.MaxResolutionWindow != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.MaxResolutionWindow)) + i-- + dAtA[i] = 0x20 + } + if len(m.Matchers) > 0 { + for iNdEx := len(m.Matchers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Matchers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } - i++ } - if m.PartialResponseStrategy != 0 { - dAtA[i] = 0x38 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) + if m.MaxTime != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.MaxTime)) + i-- + dAtA[i] = 0x10 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.MinTime != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.MinTime)) + i-- + dAtA[i] = 0x8 } - return i, nil + return len(dAtA) - i, nil } func (m *SeriesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1109,49 +1162,68 @@ func (m *SeriesResponse) Marshal() (dAtA []byte, err error) { } func (m *SeriesResponse) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SeriesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } if m.Result != nil { - nn3, err := m.Result.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + { + size := m.Result.Size() + i -= size + if _, err := m.Result.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } } - i += nn3 - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) } - return i, nil + return len(dAtA) - i, nil } func (m *SeriesResponse_Series) MarshalTo(dAtA []byte) (int, error) { - i := 0 + return m.MarshalToSizedBuffer(dAtA[:m.Size()]) +} + +func (m *SeriesResponse_Series) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) if m.Series != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.Series.Size())) - n4, err := m.Series.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + { + size, err := m.Series.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRpc(dAtA, i, uint64(size)) } - i += n4 + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *SeriesResponse_Warning) MarshalTo(dAtA []byte) (int, error) { - i := 0 - dAtA[i] = 0x12 - i++ + return m.MarshalToSizedBuffer(dAtA[:m.Size()]) +} + +func (m *SeriesResponse_Warning) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.Warning) + copy(dAtA[i:], m.Warning) i = encodeVarintRpc(dAtA, i, uint64(len(m.Warning))) - i += copy(dAtA[i:], m.Warning) - return i, nil + i-- + dAtA[i] = 0x12 + return len(dAtA) - i, nil } func (m *LabelNamesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1159,35 +1231,41 @@ func (m *LabelNamesRequest) Marshal() (dAtA []byte, err error) { } func (m *LabelNamesRequest) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LabelNamesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.PartialResponseStrategy != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) + i-- + dAtA[i] = 0x10 + } if m.PartialResponseDisabled { - dAtA[i] = 0x8 - i++ + i-- if m.PartialResponseDisabled { dAtA[i] = 1 } else { dAtA[i] = 0 } - i++ - } - if m.PartialResponseStrategy != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + i-- + dAtA[i] = 0x8 } - return i, nil + return len(dAtA) - i, nil } func (m *LabelNamesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1195,50 +1273,44 @@ func (m *LabelNamesResponse) Marshal() (dAtA []byte, err error) { } func (m *LabelNamesResponse) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LabelNamesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Names) > 0 { - for _, s := range m.Names { - dAtA[i] = 0xa - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Warnings) > 0 { - for _, s := range m.Warnings { + for iNdEx := len(m.Warnings) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Warnings[iNdEx]) + copy(dAtA[i:], m.Warnings[iNdEx]) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Warnings[iNdEx]))) + i-- dAtA[i] = 0x12 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Names) > 0 { + for iNdEx := len(m.Names) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Names[iNdEx]) + copy(dAtA[i:], m.Names[iNdEx]) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Names[iNdEx]))) + i-- + dAtA[i] = 0xa + } } - return i, nil + return len(dAtA) - i, nil } func (m *LabelValuesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1246,41 +1318,48 @@ func (m *LabelValuesRequest) Marshal() (dAtA []byte, err error) { } func (m *LabelValuesRequest) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LabelValuesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Label) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintRpc(dAtA, i, uint64(len(m.Label))) - i += copy(dAtA[i:], m.Label) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.PartialResponseStrategy != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) + i-- + dAtA[i] = 0x18 } if m.PartialResponseDisabled { - dAtA[i] = 0x10 - i++ + i-- if m.PartialResponseDisabled { dAtA[i] = 1 } else { dAtA[i] = 0 } - i++ - } - if m.PartialResponseStrategy != 0 { - dAtA[i] = 0x18 - i++ - i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) + i-- + dAtA[i] = 0x10 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Label) > 0 { + i -= len(m.Label) + copy(dAtA[i:], m.Label) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Label))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *LabelValuesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1288,54 +1367,50 @@ func (m *LabelValuesResponse) Marshal() (dAtA []byte, err error) { } func (m *LabelValuesResponse) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LabelValuesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Values) > 0 { - for _, s := range m.Values { - dAtA[i] = 0xa - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Warnings) > 0 { - for _, s := range m.Warnings { + for iNdEx := len(m.Warnings) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Warnings[iNdEx]) + copy(dAtA[i:], m.Warnings[iNdEx]) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Warnings[iNdEx]))) + i-- dAtA[i] = 0x12 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Values) > 0 { + for iNdEx := len(m.Values) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Values[iNdEx]) + copy(dAtA[i:], m.Values[iNdEx]) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Values[iNdEx]))) + i-- + dAtA[i] = 0xa + } } - return i, nil + return len(dAtA) - i, nil } func encodeVarintRpc(dAtA []byte, offset int, v uint64) int { + offset -= sovRpc(v) + base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 offset++ } dAtA[offset] = uint8(v) - return offset + 1 + return base } func (m *InfoRequest) Size() (n int) { if m == nil { @@ -1566,14 +1641,7 @@ func (m *LabelValuesResponse) Size() (n int) { } func sovRpc(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n + return (math_bits.Len64(x|1) + 6) / 7 } func sozRpc(x uint64) (n int) { return sovRpc(uint64((x << 1) ^ uint64((int64(x) >> 63)))) diff --git a/pkg/store/storepb/rpc.proto b/pkg/store/storepb/rpc.proto index f26e2b3d0f..35ea869454 100644 --- a/pkg/store/storepb/rpc.proto +++ b/pkg/store/storepb/rpc.proto @@ -79,7 +79,7 @@ message SeriesRequest { // Deprecated. Use partial_response_strategy instead. bool partial_response_disabled = 6; - // TODO(bwplotka): Move Thanos components to use strategy instead. Inlcuding QueryAPI. + // TODO(bwplotka): Move Thanos components to use strategy instead. Including QueryAPI. PartialResponseStrategy partial_response_strategy = 7; } @@ -105,7 +105,7 @@ message SeriesResponse { message LabelNamesRequest { bool partial_response_disabled = 1; - // TODO(bwplotka): Move Thanos components to use strategy instead. Inlcuding QueryAPI. + // TODO(bwplotka): Move Thanos components to use strategy instead. Including QueryAPI. PartialResponseStrategy partial_response_strategy = 2; } @@ -119,7 +119,7 @@ message LabelValuesRequest { bool partial_response_disabled = 2; - // TODO(bwplotka): Move Thanos components to use strategy instead. Inlcuding QueryAPI. + // TODO(bwplotka): Move Thanos components to use strategy instead. Including QueryAPI. PartialResponseStrategy partial_response_strategy = 3; } diff --git a/pkg/store/storepb/types.pb.go b/pkg/store/storepb/types.pb.go index 0ccf739ecf..86a8b06237 100644 --- a/pkg/store/storepb/types.pb.go +++ b/pkg/store/storepb/types.pb.go @@ -7,6 +7,7 @@ import ( fmt "fmt" io "io" math "math" + math_bits "math/bits" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -98,7 +99,7 @@ func (m *Label) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Label.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -139,7 +140,7 @@ func (m *Chunk) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Chunk.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -180,7 +181,7 @@ func (m *Series) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Series.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -227,7 +228,7 @@ func (m *AggrChunk) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_AggrChunk.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -270,7 +271,7 @@ func (m *LabelMatcher) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_LabelMatcher.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -335,7 +336,7 @@ var fileDescriptor_d938547f84707355 = []byte{ func (m *Label) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -343,32 +344,40 @@ func (m *Label) Marshal() (dAtA []byte, err error) { } func (m *Label) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Label) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Name) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintTypes(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Value) > 0 { - dAtA[i] = 0x12 - i++ + i -= len(m.Value) + copy(dAtA[i:], m.Value) i = encodeVarintTypes(dAtA, i, uint64(len(m.Value))) - i += copy(dAtA[i:], m.Value) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *Chunk) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -376,31 +385,38 @@ func (m *Chunk) Marshal() (dAtA []byte, err error) { } func (m *Chunk) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Chunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.Type != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.Type)) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Data) > 0 { - dAtA[i] = 0x12 - i++ + i -= len(m.Data) + copy(dAtA[i:], m.Data) i = encodeVarintTypes(dAtA, i, uint64(len(m.Data))) - i += copy(dAtA[i:], m.Data) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.Type != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 } - return i, nil + return len(dAtA) - i, nil } func (m *Series) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -408,44 +424,54 @@ func (m *Series) Marshal() (dAtA []byte, err error) { } func (m *Series) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Series) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Labels) > 0 { - for _, msg := range m.Labels { - dAtA[i] = 0xa - i++ - i = encodeVarintTypes(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Chunks) > 0 { - for _, msg := range m.Chunks { - dAtA[i] = 0x12 - i++ - i = encodeVarintTypes(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Chunks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Chunks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0x12 } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Labels) > 0 { + for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Labels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } - return i, nil + return len(dAtA) - i, nil } func (m *AggrChunk) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -453,90 +479,108 @@ func (m *AggrChunk) Marshal() (dAtA []byte, err error) { } func (m *AggrChunk) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AggrChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.MinTime != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.MinTime)) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if m.MaxTime != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.MaxTime)) + if m.Counter != nil { + { + size, err := m.Counter.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 } - if m.Raw != nil { - dAtA[i] = 0x1a - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.Raw.Size())) - n1, err := m.Raw.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.Max != nil { + { + size, err := m.Max.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i += n1 + i-- + dAtA[i] = 0x3a } - if m.Count != nil { - dAtA[i] = 0x22 - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.Count.Size())) - n2, err := m.Count.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.Min != nil { + { + size, err := m.Min.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i += n2 + i-- + dAtA[i] = 0x32 } if m.Sum != nil { - dAtA[i] = 0x2a - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.Sum.Size())) - n3, err := m.Sum.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + { + size, err := m.Sum.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i += n3 + i-- + dAtA[i] = 0x2a } - if m.Min != nil { - dAtA[i] = 0x32 - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.Min.Size())) - n4, err := m.Min.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.Count != nil { + { + size, err := m.Count.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i += n4 + i-- + dAtA[i] = 0x22 } - if m.Max != nil { - dAtA[i] = 0x3a - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.Max.Size())) - n5, err := m.Max.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.Raw != nil { + { + size, err := m.Raw.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i += n5 + i-- + dAtA[i] = 0x1a } - if m.Counter != nil { - dAtA[i] = 0x42 - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.Counter.Size())) - n6, err := m.Counter.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n6 + if m.MaxTime != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.MaxTime)) + i-- + dAtA[i] = 0x10 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.MinTime != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.MinTime)) + i-- + dAtA[i] = 0x8 } - return i, nil + return len(dAtA) - i, nil } func (m *LabelMatcher) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -544,41 +588,51 @@ func (m *LabelMatcher) Marshal() (dAtA []byte, err error) { } func (m *LabelMatcher) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LabelMatcher) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.Type != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.Type)) - } - if len(m.Name) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintTypes(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Value) > 0 { - dAtA[i] = 0x1a - i++ + i -= len(m.Value) + copy(dAtA[i:], m.Value) i = encodeVarintTypes(dAtA, i, uint64(len(m.Value))) - i += copy(dAtA[i:], m.Value) + i-- + dAtA[i] = 0x1a } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if m.Type != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 } - return i, nil + return len(dAtA) - i, nil } func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 offset++ } dAtA[offset] = uint8(v) - return offset + 1 + return base } func (m *Label) Size() (n int) { if m == nil { @@ -709,14 +763,7 @@ func (m *LabelMatcher) Size() (n int) { } func sovTypes(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n + return (math_bits.Len64(x|1) + 6) / 7 } func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) diff --git a/tutorials/kubernetes-demo/manifests/prometheus-pv-0.yaml b/tutorials/kubernetes-demo/manifests/prometheus-pv-0.yaml index 368bcb8835..fc6ad10455 100644 --- a/tutorials/kubernetes-demo/manifests/prometheus-pv-0.yaml +++ b/tutorials/kubernetes-demo/manifests/prometheus-pv-0.yaml @@ -1,4 +1,4 @@ -# Prepare 2 volumes for replicas. It is required only for demo purposes as we artifically generate metrics. +# Prepare 2 volumes for replicas. It is required only for demo purposes as we artificially generate metrics. kind: PersistentVolume apiVersion: v1 metadata: