From 248f9e25e46fb5980cb68ecf6b1be69b31730945 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Mon, 25 Jun 2018 18:56:28 +0530 Subject: [PATCH] Move iterators to own package; check in protos and parser to make CLI go gettable. Signed-off-by: Tom Wilkie --- .gitignore | 2 - cmd/logcli/main.go | 4 +- pkg/ingester/chunk.go | 6 +- pkg/ingester/chunk_test.go | 6 +- pkg/ingester/instance.go | 9 +- pkg/ingester/stream.go | 10 +- pkg/{querier => iter}/iterator.go | 4 +- pkg/{querier => iter}/iterator_test.go | 2 +- pkg/logproto/logproto.pb.go | 2246 ++++++++++++++++++++++++ pkg/parser/labels.go | 546 ++++++ pkg/querier/querier.go | 11 +- 11 files changed, 2819 insertions(+), 27 deletions(-) rename pkg/{querier => iter}/iterator.go (98%) rename pkg/{querier => iter}/iterator_test.go (99%) create mode 100644 pkg/logproto/logproto.pb.go create mode 100644 pkg/parser/labels.go diff --git a/.gitignore b/.gitignore index 767376287c1de..4ff530d89f31f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ .uptodate -*.pb.go !vendor/**/*.pb.go vendor/github.com/weaveworks/cortex/pkg/ingester/client/cortex.pb.go vendor/github.com/weaveworks/cortex/pkg/ring/ring.pb.go -pkg/parser/labels.go .pkg .cache cmd/distributor/distributor diff --git a/cmd/logcli/main.go b/cmd/logcli/main.go index cb7400c301e20..0c2023416af30 100644 --- a/cmd/logcli/main.go +++ b/cmd/logcli/main.go @@ -15,9 +15,9 @@ import ( "github.com/prometheus/prometheus/pkg/labels" kingpin "gopkg.in/alecthomas/kingpin.v2" + "github.com/grafana/logish/pkg/iter" "github.com/grafana/logish/pkg/logproto" "github.com/grafana/logish/pkg/parser" - "github.com/grafana/logish/pkg/querier" ) var ( @@ -108,7 +108,7 @@ func query() { if *forward { d = logproto.FORWARD } - iter := querier.NewQueryResponseIterator(&queryResponse, d) + iter := iter.NewQueryResponseIterator(&queryResponse, d) for iter.Next() { ls := labelsCache[iter.Labels()] ls = subtract(commonLabels, ls) diff --git a/pkg/ingester/chunk.go b/pkg/ingester/chunk.go index 1883ad26acbe6..ca4aa00c8133c 100644 --- a/pkg/ingester/chunk.go +++ b/pkg/ingester/chunk.go @@ -7,8 +7,8 @@ import ( "github.com/pkg/errors" + "github.com/grafana/logish/pkg/iter" "github.com/grafana/logish/pkg/logproto" - "github.com/grafana/logish/pkg/querier" ) const ( @@ -24,7 +24,7 @@ type Chunk interface { Bounds() (time.Time, time.Time) SpaceFor(*logproto.Entry) bool Push(*logproto.Entry) error - Iterator(from, through time.Time, direction logproto.Direction) querier.EntryIterator + Iterator(from, through time.Time, direction logproto.Direction) iter.EntryIterator Size() int } @@ -66,7 +66,7 @@ func (c *dumbChunk) Size() int { // Returns an iterator that goes from _most_ recent to _least_ recent (ie, // backwards). -func (c *dumbChunk) Iterator(from, through time.Time, direction logproto.Direction) querier.EntryIterator { +func (c *dumbChunk) Iterator(from, through time.Time, direction logproto.Direction) iter.EntryIterator { i := sort.Search(len(c.entries), func(i int) bool { return !from.After(c.entries[i].Timestamp) }) diff --git a/pkg/ingester/chunk_test.go b/pkg/ingester/chunk_test.go index d1a38f01bb70b..e3b7edf46cfa8 100644 --- a/pkg/ingester/chunk_test.go +++ b/pkg/ingester/chunk_test.go @@ -6,13 +6,13 @@ import ( "testing" "time" + "github.com/grafana/logish/pkg/iter" "github.com/grafana/logish/pkg/logproto" - "github.com/grafana/logish/pkg/querier" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func testIteratorForward(t *testing.T, iter querier.EntryIterator, from, through int64) { +func testIteratorForward(t *testing.T, iter iter.EntryIterator, from, through int64) { i := from for iter.Next() { entry := iter.Entry() @@ -24,7 +24,7 @@ func testIteratorForward(t *testing.T, iter querier.EntryIterator, from, through assert.NoError(t, iter.Error()) } -func testIteratorBackward(t *testing.T, iter querier.EntryIterator, from, through int64) { +func testIteratorBackward(t *testing.T, iter iter.EntryIterator, from, through int64) { i := through - 1 for iter.Next() { entry := iter.Entry() diff --git a/pkg/ingester/instance.go b/pkg/ingester/instance.go index 97d95e2fe9440..1d7233dfb6d58 100644 --- a/pkg/ingester/instance.go +++ b/pkg/ingester/instance.go @@ -8,6 +8,7 @@ import ( "github.com/pkg/errors" + "github.com/grafana/logish/pkg/iter" "github.com/grafana/logish/pkg/logproto" "github.com/grafana/logish/pkg/parser" "github.com/grafana/logish/pkg/querier" @@ -67,7 +68,7 @@ func (i *instance) Query(req *logproto.QueryRequest, queryServer logproto.Querie // TODO: lock smell i.streamsMtx.Lock() ids := i.index.lookup(matchers) - iterators := make([]querier.EntryIterator, len(ids)) + iterators := make([]iter.EntryIterator, len(ids)) for j := range ids { stream, ok := i.streams[ids[j]] if !ok { @@ -78,12 +79,12 @@ func (i *instance) Query(req *logproto.QueryRequest, queryServer logproto.Querie } i.streamsMtx.Unlock() - iterator := querier.NewHeapIterator(iterators, req.Direction) + iterator := iter.NewHeapIterator(iterators, req.Direction) defer iterator.Close() if req.Regex != "" { var err error - iterator, err = querier.NewRegexpFilter(req.Regex, iterator) + iterator, err = iter.NewRegexpFilter(req.Regex, iterator) if err != nil { return err } @@ -109,7 +110,7 @@ func isDone(ctx context.Context) bool { } } -func sendBatches(i querier.EntryIterator, queryServer logproto.Querier_QueryServer, limit uint32) error { +func sendBatches(i iter.EntryIterator, queryServer logproto.Querier_QueryServer, limit uint32) error { sent := uint32(0) for sent < limit && !isDone(queryServer.Context()) { batch, batchSize, err := querier.ReadBatch(i, util.MinUint32(queryBatchSize, limit-sent)) diff --git a/pkg/ingester/stream.go b/pkg/ingester/stream.go index 619aaf507b153..cca0c54317cd3 100644 --- a/pkg/ingester/stream.go +++ b/pkg/ingester/stream.go @@ -6,8 +6,8 @@ import ( "github.com/prometheus/prometheus/pkg/labels" + "github.com/grafana/logish/pkg/iter" "github.com/grafana/logish/pkg/logproto" - "github.com/grafana/logish/pkg/querier" ) const tmpMaxChunks = 3 @@ -47,8 +47,8 @@ func (s *stream) Push(ctx context.Context, entries []logproto.Entry) error { } // Returns an iterator. -func (s *stream) Iterator(from, through time.Time, direction logproto.Direction) querier.EntryIterator { - iterators := make([]querier.EntryIterator, 0, len(s.chunks)) +func (s *stream) Iterator(from, through time.Time, direction logproto.Direction) iter.EntryIterator { + iterators := make([]iter.EntryIterator, 0, len(s.chunks)) for _, c := range s.chunks { iter := c.Iterator(from, through, direction) if iter != nil { @@ -71,8 +71,8 @@ func (s *stream) Iterator(from, through time.Time, direction logproto.Direction) type nonOverlappingIterator struct { labels string i int - iterators []querier.EntryIterator - curr querier.EntryIterator + iterators []iter.EntryIterator + curr iter.EntryIterator } func (i *nonOverlappingIterator) Next() bool { diff --git a/pkg/querier/iterator.go b/pkg/iter/iterator.go similarity index 98% rename from pkg/querier/iterator.go rename to pkg/iter/iterator.go index 73a9eac2373b0..8e591a65cacb7 100644 --- a/pkg/querier/iterator.go +++ b/pkg/iter/iterator.go @@ -1,4 +1,4 @@ -package querier +package iter import ( "container/heap" @@ -201,7 +201,7 @@ type queryClientIterator struct { curr EntryIterator } -func newQueryClientIterator(client logproto.Querier_QueryClient, direction logproto.Direction) EntryIterator { +func NewQueryClientIterator(client logproto.Querier_QueryClient, direction logproto.Direction) EntryIterator { return &queryClientIterator{ client: client, direction: direction, diff --git a/pkg/querier/iterator_test.go b/pkg/iter/iterator_test.go similarity index 99% rename from pkg/querier/iterator_test.go rename to pkg/iter/iterator_test.go index ddf2693f711d9..0506b4f6ceb4d 100644 --- a/pkg/querier/iterator_test.go +++ b/pkg/iter/iterator_test.go @@ -1,4 +1,4 @@ -package querier +package iter import ( "testing" diff --git a/pkg/logproto/logproto.pb.go b/pkg/logproto/logproto.pb.go new file mode 100644 index 0000000000000..9b0673551d56e --- /dev/null +++ b/pkg/logproto/logproto.pb.go @@ -0,0 +1,2246 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: logproto.proto + +/* + Package logproto is a generated protocol buffer package. + + It is generated from these files: + logproto.proto + + It has these top-level messages: + PushRequest + PushResponse + QueryRequest + QueryResponse + LabelRequest + LabelResponse + Stream + Entry +*/ +package logproto + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" +import _ "github.com/gogo/protobuf/types" +import _ "github.com/gogo/protobuf/gogoproto" +import grpc_health_v1 "google.golang.org/grpc/health/grpc_health_v1" + +import time "time" + +import strconv "strconv" + +import strings "strings" +import reflect "reflect" + +import context "golang.org/x/net/context" +import grpc "google.golang.org/grpc" + +import types "github.com/gogo/protobuf/types" + +import io "io" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +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 Direction int32 + +const ( + FORWARD Direction = 0 + BACKWARD Direction = 1 +) + +var Direction_name = map[int32]string{ + 0: "FORWARD", + 1: "BACKWARD", +} +var Direction_value = map[string]int32{ + "FORWARD": 0, + "BACKWARD": 1, +} + +func (Direction) EnumDescriptor() ([]byte, []int) { return fileDescriptorLogproto, []int{0} } + +type PushRequest struct { + Streams []*Stream `protobuf:"bytes,1,rep,name=streams" json:"streams,omitempty"` +} + +func (m *PushRequest) Reset() { *m = PushRequest{} } +func (*PushRequest) ProtoMessage() {} +func (*PushRequest) Descriptor() ([]byte, []int) { return fileDescriptorLogproto, []int{0} } + +func (m *PushRequest) GetStreams() []*Stream { + if m != nil { + return m.Streams + } + return nil +} + +type PushResponse struct { +} + +func (m *PushResponse) Reset() { *m = PushResponse{} } +func (*PushResponse) ProtoMessage() {} +func (*PushResponse) Descriptor() ([]byte, []int) { return fileDescriptorLogproto, []int{1} } + +type QueryRequest struct { + Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` + Limit uint32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` + Start time.Time `protobuf:"bytes,3,opt,name=start,stdtime" json:"start"` + End time.Time `protobuf:"bytes,4,opt,name=end,stdtime" json:"end"` + Direction Direction `protobuf:"varint,5,opt,name=direction,proto3,enum=logproto.Direction" json:"direction,omitempty"` + Regex string `protobuf:"bytes,6,opt,name=regex,proto3" json:"regex,omitempty"` +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (*QueryRequest) ProtoMessage() {} +func (*QueryRequest) Descriptor() ([]byte, []int) { return fileDescriptorLogproto, []int{2} } + +func (m *QueryRequest) GetQuery() string { + if m != nil { + return m.Query + } + return "" +} + +func (m *QueryRequest) GetLimit() uint32 { + if m != nil { + return m.Limit + } + return 0 +} + +func (m *QueryRequest) GetStart() time.Time { + if m != nil { + return m.Start + } + return time.Time{} +} + +func (m *QueryRequest) GetEnd() time.Time { + if m != nil { + return m.End + } + return time.Time{} +} + +func (m *QueryRequest) GetDirection() Direction { + if m != nil { + return m.Direction + } + return FORWARD +} + +func (m *QueryRequest) GetRegex() string { + if m != nil { + return m.Regex + } + return "" +} + +type QueryResponse struct { + Streams []*Stream `protobuf:"bytes,1,rep,name=streams" json:"streams,omitempty"` +} + +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (*QueryResponse) ProtoMessage() {} +func (*QueryResponse) Descriptor() ([]byte, []int) { return fileDescriptorLogproto, []int{3} } + +func (m *QueryResponse) GetStreams() []*Stream { + if m != nil { + return m.Streams + } + return nil +} + +type LabelRequest struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *LabelRequest) Reset() { *m = LabelRequest{} } +func (*LabelRequest) ProtoMessage() {} +func (*LabelRequest) Descriptor() ([]byte, []int) { return fileDescriptorLogproto, []int{4} } + +func (m *LabelRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +type LabelResponse struct { + Values []string `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` +} + +func (m *LabelResponse) Reset() { *m = LabelResponse{} } +func (*LabelResponse) ProtoMessage() {} +func (*LabelResponse) Descriptor() ([]byte, []int) { return fileDescriptorLogproto, []int{5} } + +func (m *LabelResponse) GetValues() []string { + if m != nil { + return m.Values + } + return nil +} + +type Stream struct { + Labels string `protobuf:"bytes,1,opt,name=labels,proto3" json:"labels,omitempty"` + Entries []Entry `protobuf:"bytes,2,rep,name=entries" json:"entries"` +} + +func (m *Stream) Reset() { *m = Stream{} } +func (*Stream) ProtoMessage() {} +func (*Stream) Descriptor() ([]byte, []int) { return fileDescriptorLogproto, []int{6} } + +func (m *Stream) GetLabels() string { + if m != nil { + return m.Labels + } + return "" +} + +func (m *Stream) GetEntries() []Entry { + if m != nil { + return m.Entries + } + return nil +} + +type Entry struct { + Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,stdtime" json:"timestamp"` + Line string `protobuf:"bytes,2,opt,name=line,proto3" json:"line,omitempty"` +} + +func (m *Entry) Reset() { *m = Entry{} } +func (*Entry) ProtoMessage() {} +func (*Entry) Descriptor() ([]byte, []int) { return fileDescriptorLogproto, []int{7} } + +func (m *Entry) GetTimestamp() time.Time { + if m != nil { + return m.Timestamp + } + return time.Time{} +} + +func (m *Entry) GetLine() string { + if m != nil { + return m.Line + } + return "" +} + +func init() { + proto.RegisterType((*PushRequest)(nil), "logproto.PushRequest") + proto.RegisterType((*PushResponse)(nil), "logproto.PushResponse") + proto.RegisterType((*QueryRequest)(nil), "logproto.QueryRequest") + proto.RegisterType((*QueryResponse)(nil), "logproto.QueryResponse") + proto.RegisterType((*LabelRequest)(nil), "logproto.LabelRequest") + proto.RegisterType((*LabelResponse)(nil), "logproto.LabelResponse") + proto.RegisterType((*Stream)(nil), "logproto.Stream") + proto.RegisterType((*Entry)(nil), "logproto.Entry") + proto.RegisterEnum("logproto.Direction", Direction_name, Direction_value) +} +func (x Direction) String() string { + s, ok := Direction_name[int32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} +func (this *PushRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PushRequest) + if !ok { + that2, ok := that.(PushRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Streams) != len(that1.Streams) { + return false + } + for i := range this.Streams { + if !this.Streams[i].Equal(that1.Streams[i]) { + return false + } + } + return true +} +func (this *PushResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PushResponse) + if !ok { + that2, ok := that.(PushResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *QueryRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*QueryRequest) + if !ok { + that2, ok := that.(QueryRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Query != that1.Query { + return false + } + if this.Limit != that1.Limit { + return false + } + if !this.Start.Equal(that1.Start) { + return false + } + if !this.End.Equal(that1.End) { + return false + } + if this.Direction != that1.Direction { + return false + } + if this.Regex != that1.Regex { + return false + } + return true +} +func (this *QueryResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*QueryResponse) + if !ok { + that2, ok := that.(QueryResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Streams) != len(that1.Streams) { + return false + } + for i := range this.Streams { + if !this.Streams[i].Equal(that1.Streams[i]) { + return false + } + } + return true +} +func (this *LabelRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*LabelRequest) + if !ok { + that2, ok := that.(LabelRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + return true +} +func (this *LabelResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*LabelResponse) + if !ok { + that2, ok := that.(LabelResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Values) != len(that1.Values) { + return false + } + for i := range this.Values { + if this.Values[i] != that1.Values[i] { + return false + } + } + return true +} +func (this *Stream) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Stream) + if !ok { + that2, ok := that.(Stream) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Labels != that1.Labels { + return false + } + if len(this.Entries) != len(that1.Entries) { + return false + } + for i := range this.Entries { + if !this.Entries[i].Equal(&that1.Entries[i]) { + return false + } + } + return true +} +func (this *Entry) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Entry) + if !ok { + that2, ok := that.(Entry) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Timestamp.Equal(that1.Timestamp) { + return false + } + if this.Line != that1.Line { + return false + } + return true +} +func (this *PushRequest) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&logproto.PushRequest{") + if this.Streams != nil { + s = append(s, "Streams: "+fmt.Sprintf("%#v", this.Streams)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *PushResponse) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 4) + s = append(s, "&logproto.PushResponse{") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *QueryRequest) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 10) + s = append(s, "&logproto.QueryRequest{") + s = append(s, "Query: "+fmt.Sprintf("%#v", this.Query)+",\n") + s = append(s, "Limit: "+fmt.Sprintf("%#v", this.Limit)+",\n") + s = append(s, "Start: "+fmt.Sprintf("%#v", this.Start)+",\n") + s = append(s, "End: "+fmt.Sprintf("%#v", this.End)+",\n") + s = append(s, "Direction: "+fmt.Sprintf("%#v", this.Direction)+",\n") + s = append(s, "Regex: "+fmt.Sprintf("%#v", this.Regex)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *QueryResponse) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&logproto.QueryResponse{") + if this.Streams != nil { + s = append(s, "Streams: "+fmt.Sprintf("%#v", this.Streams)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *LabelRequest) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&logproto.LabelRequest{") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *LabelResponse) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&logproto.LabelResponse{") + s = append(s, "Values: "+fmt.Sprintf("%#v", this.Values)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Stream) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&logproto.Stream{") + s = append(s, "Labels: "+fmt.Sprintf("%#v", this.Labels)+",\n") + if this.Entries != nil { + vs := make([]*Entry, len(this.Entries)) + for i := range vs { + vs[i] = &this.Entries[i] + } + s = append(s, "Entries: "+fmt.Sprintf("%#v", vs)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Entry) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&logproto.Entry{") + s = append(s, "Timestamp: "+fmt.Sprintf("%#v", this.Timestamp)+",\n") + s = append(s, "Line: "+fmt.Sprintf("%#v", this.Line)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringLogproto(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// Client API for Pusher service + +type PusherClient interface { + Push(ctx context.Context, in *PushRequest, opts ...grpc.CallOption) (*PushResponse, error) + Check(ctx context.Context, in *grpc_health_v1.HealthCheckRequest, opts ...grpc.CallOption) (*grpc_health_v1.HealthCheckResponse, error) +} + +type pusherClient struct { + cc *grpc.ClientConn +} + +func NewPusherClient(cc *grpc.ClientConn) PusherClient { + return &pusherClient{cc} +} + +func (c *pusherClient) Push(ctx context.Context, in *PushRequest, opts ...grpc.CallOption) (*PushResponse, error) { + out := new(PushResponse) + err := grpc.Invoke(ctx, "/logproto.Pusher/Push", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *pusherClient) Check(ctx context.Context, in *grpc_health_v1.HealthCheckRequest, opts ...grpc.CallOption) (*grpc_health_v1.HealthCheckResponse, error) { + out := new(grpc_health_v1.HealthCheckResponse) + err := grpc.Invoke(ctx, "/logproto.Pusher/Check", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for Pusher service + +type PusherServer interface { + Push(context.Context, *PushRequest) (*PushResponse, error) + Check(context.Context, *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) +} + +func RegisterPusherServer(s *grpc.Server, srv PusherServer) { + s.RegisterService(&_Pusher_serviceDesc, srv) +} + +func _Pusher_Push_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PushRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PusherServer).Push(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/logproto.Pusher/Push", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PusherServer).Push(ctx, req.(*PushRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Pusher_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(grpc_health_v1.HealthCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PusherServer).Check(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/logproto.Pusher/Check", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PusherServer).Check(ctx, req.(*grpc_health_v1.HealthCheckRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Pusher_serviceDesc = grpc.ServiceDesc{ + ServiceName: "logproto.Pusher", + HandlerType: (*PusherServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Push", + Handler: _Pusher_Push_Handler, + }, + { + MethodName: "Check", + Handler: _Pusher_Check_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "logproto.proto", +} + +// Client API for Querier service + +type QuerierClient interface { + Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (Querier_QueryClient, error) + Label(ctx context.Context, in *LabelRequest, opts ...grpc.CallOption) (*LabelResponse, error) +} + +type querierClient struct { + cc *grpc.ClientConn +} + +func NewQuerierClient(cc *grpc.ClientConn) QuerierClient { + return &querierClient{cc} +} + +func (c *querierClient) Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (Querier_QueryClient, error) { + stream, err := grpc.NewClientStream(ctx, &_Querier_serviceDesc.Streams[0], c.cc, "/logproto.Querier/Query", opts...) + if err != nil { + return nil, err + } + x := &querierQueryClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Querier_QueryClient interface { + Recv() (*QueryResponse, error) + grpc.ClientStream +} + +type querierQueryClient struct { + grpc.ClientStream +} + +func (x *querierQueryClient) Recv() (*QueryResponse, error) { + m := new(QueryResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *querierClient) Label(ctx context.Context, in *LabelRequest, opts ...grpc.CallOption) (*LabelResponse, error) { + out := new(LabelResponse) + err := grpc.Invoke(ctx, "/logproto.Querier/Label", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for Querier service + +type QuerierServer interface { + Query(*QueryRequest, Querier_QueryServer) error + Label(context.Context, *LabelRequest) (*LabelResponse, error) +} + +func RegisterQuerierServer(s *grpc.Server, srv QuerierServer) { + s.RegisterService(&_Querier_serviceDesc, srv) +} + +func _Querier_Query_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(QueryRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(QuerierServer).Query(m, &querierQueryServer{stream}) +} + +type Querier_QueryServer interface { + Send(*QueryResponse) error + grpc.ServerStream +} + +type querierQueryServer struct { + grpc.ServerStream +} + +func (x *querierQueryServer) Send(m *QueryResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _Querier_Label_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LabelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QuerierServer).Label(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/logproto.Querier/Label", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QuerierServer).Label(ctx, req.(*LabelRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Querier_serviceDesc = grpc.ServiceDesc{ + ServiceName: "logproto.Querier", + HandlerType: (*QuerierServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Label", + Handler: _Querier_Label_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Query", + Handler: _Querier_Query_Handler, + ServerStreams: true, + }, + }, + Metadata: "logproto.proto", +} + +func (m *PushRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PushRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Streams) > 0 { + for _, msg := range m.Streams { + dAtA[i] = 0xa + i++ + i = encodeVarintLogproto(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *PushResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PushResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + +func (m *QueryRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Query) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintLogproto(dAtA, i, uint64(len(m.Query))) + i += copy(dAtA[i:], m.Query) + } + if m.Limit != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintLogproto(dAtA, i, uint64(m.Limit)) + } + dAtA[i] = 0x1a + i++ + i = encodeVarintLogproto(dAtA, i, uint64(types.SizeOfStdTime(m.Start))) + n1, err := types.StdTimeMarshalTo(m.Start, dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + dAtA[i] = 0x22 + i++ + i = encodeVarintLogproto(dAtA, i, uint64(types.SizeOfStdTime(m.End))) + n2, err := types.StdTimeMarshalTo(m.End, dAtA[i:]) + if err != nil { + return 0, err + } + i += n2 + if m.Direction != 0 { + dAtA[i] = 0x28 + i++ + i = encodeVarintLogproto(dAtA, i, uint64(m.Direction)) + } + if len(m.Regex) > 0 { + dAtA[i] = 0x32 + i++ + i = encodeVarintLogproto(dAtA, i, uint64(len(m.Regex))) + i += copy(dAtA[i:], m.Regex) + } + return i, nil +} + +func (m *QueryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Streams) > 0 { + for _, msg := range m.Streams { + dAtA[i] = 0xa + i++ + i = encodeVarintLogproto(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *LabelRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LabelRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintLogproto(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + return i, nil +} + +func (m *LabelResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LabelResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = 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) + } + } + return i, nil +} + +func (m *Stream) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Stream) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Labels) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintLogproto(dAtA, i, uint64(len(m.Labels))) + i += copy(dAtA[i:], m.Labels) + } + if len(m.Entries) > 0 { + for _, msg := range m.Entries { + dAtA[i] = 0x12 + i++ + i = encodeVarintLogproto(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *Entry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Entry) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintLogproto(dAtA, i, uint64(types.SizeOfStdTime(m.Timestamp))) + n3, err := types.StdTimeMarshalTo(m.Timestamp, dAtA[i:]) + if err != nil { + return 0, err + } + i += n3 + if len(m.Line) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintLogproto(dAtA, i, uint64(len(m.Line))) + i += copy(dAtA[i:], m.Line) + } + return i, nil +} + +func encodeVarintLogproto(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *PushRequest) Size() (n int) { + var l int + _ = l + if len(m.Streams) > 0 { + for _, e := range m.Streams { + l = e.Size() + n += 1 + l + sovLogproto(uint64(l)) + } + } + return n +} + +func (m *PushResponse) Size() (n int) { + var l int + _ = l + return n +} + +func (m *QueryRequest) Size() (n int) { + var l int + _ = l + l = len(m.Query) + if l > 0 { + n += 1 + l + sovLogproto(uint64(l)) + } + if m.Limit != 0 { + n += 1 + sovLogproto(uint64(m.Limit)) + } + l = types.SizeOfStdTime(m.Start) + n += 1 + l + sovLogproto(uint64(l)) + l = types.SizeOfStdTime(m.End) + n += 1 + l + sovLogproto(uint64(l)) + if m.Direction != 0 { + n += 1 + sovLogproto(uint64(m.Direction)) + } + l = len(m.Regex) + if l > 0 { + n += 1 + l + sovLogproto(uint64(l)) + } + return n +} + +func (m *QueryResponse) Size() (n int) { + var l int + _ = l + if len(m.Streams) > 0 { + for _, e := range m.Streams { + l = e.Size() + n += 1 + l + sovLogproto(uint64(l)) + } + } + return n +} + +func (m *LabelRequest) Size() (n int) { + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovLogproto(uint64(l)) + } + return n +} + +func (m *LabelResponse) Size() (n int) { + var l int + _ = l + if len(m.Values) > 0 { + for _, s := range m.Values { + l = len(s) + n += 1 + l + sovLogproto(uint64(l)) + } + } + return n +} + +func (m *Stream) Size() (n int) { + var l int + _ = l + l = len(m.Labels) + if l > 0 { + n += 1 + l + sovLogproto(uint64(l)) + } + if len(m.Entries) > 0 { + for _, e := range m.Entries { + l = e.Size() + n += 1 + l + sovLogproto(uint64(l)) + } + } + return n +} + +func (m *Entry) Size() (n int) { + var l int + _ = l + l = types.SizeOfStdTime(m.Timestamp) + n += 1 + l + sovLogproto(uint64(l)) + l = len(m.Line) + if l > 0 { + n += 1 + l + sovLogproto(uint64(l)) + } + return n +} + +func sovLogproto(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozLogproto(x uint64) (n int) { + return sovLogproto(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *PushRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PushRequest{`, + `Streams:` + strings.Replace(fmt.Sprintf("%v", this.Streams), "Stream", "Stream", 1) + `,`, + `}`, + }, "") + return s +} +func (this *PushResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PushResponse{`, + `}`, + }, "") + return s +} +func (this *QueryRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&QueryRequest{`, + `Query:` + fmt.Sprintf("%v", this.Query) + `,`, + `Limit:` + fmt.Sprintf("%v", this.Limit) + `,`, + `Start:` + strings.Replace(strings.Replace(this.Start.String(), "Timestamp", "google_protobuf.Timestamp", 1), `&`, ``, 1) + `,`, + `End:` + strings.Replace(strings.Replace(this.End.String(), "Timestamp", "google_protobuf.Timestamp", 1), `&`, ``, 1) + `,`, + `Direction:` + fmt.Sprintf("%v", this.Direction) + `,`, + `Regex:` + fmt.Sprintf("%v", this.Regex) + `,`, + `}`, + }, "") + return s +} +func (this *QueryResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&QueryResponse{`, + `Streams:` + strings.Replace(fmt.Sprintf("%v", this.Streams), "Stream", "Stream", 1) + `,`, + `}`, + }, "") + return s +} +func (this *LabelRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&LabelRequest{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `}`, + }, "") + return s +} +func (this *LabelResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&LabelResponse{`, + `Values:` + fmt.Sprintf("%v", this.Values) + `,`, + `}`, + }, "") + return s +} +func (this *Stream) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Stream{`, + `Labels:` + fmt.Sprintf("%v", this.Labels) + `,`, + `Entries:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Entries), "Entry", "Entry", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} +func (this *Entry) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Entry{`, + `Timestamp:` + strings.Replace(strings.Replace(this.Timestamp.String(), "Timestamp", "google_protobuf.Timestamp", 1), `&`, ``, 1) + `,`, + `Line:` + fmt.Sprintf("%v", this.Line) + `,`, + `}`, + }, "") + return s +} +func valueToStringLogproto(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *PushRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PushRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PushRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Streams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Streams = append(m.Streams, &Stream{}) + if err := m.Streams[len(m.Streams)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLogproto(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogproto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PushResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PushResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PushResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipLogproto(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogproto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Query = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= (uint32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Start", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := types.StdTimeUnmarshal(&m.Start, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field End", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := types.StdTimeUnmarshal(&m.End, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Direction", wireType) + } + m.Direction = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Direction |= (Direction(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Regex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Regex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLogproto(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogproto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Streams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Streams = append(m.Streams, &Stream{}) + if err := m.Streams[len(m.Streams)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLogproto(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogproto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LabelRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LabelRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LabelRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLogproto(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogproto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LabelResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LabelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LabelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Values = append(m.Values, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLogproto(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogproto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Stream) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Stream: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Stream: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Labels", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Labels = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Entries = append(m.Entries, Entry{}) + if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLogproto(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogproto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Entry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Entry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Entry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Line", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLogproto + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Line = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLogproto(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthLogproto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipLogproto(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLogproto + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLogproto + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLogproto + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthLogproto + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLogproto + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipLogproto(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthLogproto = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowLogproto = fmt.Errorf("proto: integer overflow") +) + +func init() { proto.RegisterFile("logproto.proto", fileDescriptorLogproto) } + +var fileDescriptorLogproto = []byte{ + // 612 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0xf5, 0xb6, 0xf9, 0x68, 0x26, 0x69, 0xa9, 0x16, 0x28, 0x56, 0x0e, 0x6e, 0x64, 0x24, 0x88, + 0x2a, 0xb0, 0x69, 0x90, 0x40, 0x05, 0x2e, 0x4d, 0x0b, 0x42, 0x02, 0x89, 0xd6, 0x20, 0x71, 0xac, + 0x9c, 0x74, 0x71, 0x2c, 0x6c, 0x6f, 0xba, 0x5e, 0x57, 0xf4, 0x86, 0xc4, 0x1f, 0xa8, 0xc4, 0x9f, + 0xe0, 0xa7, 0xf4, 0xd8, 0x23, 0x27, 0xa0, 0xe6, 0xc2, 0xb1, 0x37, 0xae, 0x68, 0x3f, 0x1c, 0x1b, + 0x90, 0x10, 0xbd, 0x58, 0xf3, 0x66, 0xdf, 0x7b, 0x9e, 0x99, 0x9d, 0x85, 0xa5, 0x88, 0x06, 0x53, + 0x46, 0x39, 0x75, 0xe4, 0x17, 0x2f, 0x14, 0xb8, 0xbb, 0x1a, 0x50, 0x1a, 0x44, 0xc4, 0x95, 0x68, + 0x94, 0xbd, 0x71, 0x79, 0x18, 0x93, 0x94, 0xfb, 0xf1, 0x54, 0x51, 0xbb, 0xb7, 0x83, 0x90, 0x4f, + 0xb2, 0x91, 0x33, 0xa6, 0xb1, 0x1b, 0xd0, 0x80, 0x96, 0x4c, 0x81, 0x24, 0x90, 0x91, 0xa6, 0x6f, + 0x28, 0x3f, 0x27, 0xa0, 0x91, 0x9f, 0x04, 0x0e, 0x65, 0x81, 0x1b, 0xb0, 0xe9, 0xd8, 0x9d, 0x10, + 0x3f, 0xe2, 0x13, 0x19, 0xef, 0xa9, 0x78, 0xef, 0x70, 0x5d, 0x67, 0x95, 0xd4, 0xde, 0x80, 0xf6, + 0x4e, 0x96, 0x4e, 0x3c, 0x72, 0x90, 0x91, 0x94, 0xe3, 0x35, 0x68, 0xa6, 0x9c, 0x11, 0x3f, 0x4e, + 0x4d, 0xd4, 0x9b, 0xef, 0xb7, 0x07, 0xcb, 0xce, 0xac, 0x8b, 0x97, 0xf2, 0xc0, 0x2b, 0x08, 0xf6, + 0x12, 0x74, 0x94, 0x34, 0x9d, 0xd2, 0x24, 0x25, 0xf6, 0x4f, 0x04, 0x9d, 0xdd, 0x8c, 0xb0, 0xa3, + 0xc2, 0xec, 0x0a, 0xd4, 0x0f, 0x04, 0x36, 0x51, 0x0f, 0xf5, 0x5b, 0x9e, 0x02, 0x22, 0x1b, 0x85, + 0x71, 0xc8, 0xcd, 0xb9, 0x1e, 0xea, 0x2f, 0x7a, 0x0a, 0xe0, 0x07, 0x50, 0x4f, 0xb9, 0xcf, 0xb8, + 0x39, 0xdf, 0x43, 0xfd, 0xf6, 0xa0, 0xeb, 0xe8, 0x96, 0x8a, 0xc6, 0x9d, 0x57, 0xc5, 0x88, 0x86, + 0x0b, 0x27, 0x5f, 0x56, 0x8d, 0xe3, 0xaf, 0xab, 0xc8, 0x53, 0x12, 0x7c, 0x0f, 0xe6, 0x49, 0xb2, + 0x6f, 0xd6, 0x2e, 0xa0, 0x14, 0x02, 0xbc, 0x0e, 0xad, 0xfd, 0x90, 0x91, 0x31, 0x0f, 0x69, 0x62, + 0xd6, 0x7b, 0xa8, 0xbf, 0x34, 0xb8, 0x5c, 0xb6, 0xbb, 0x5d, 0x1c, 0x79, 0x25, 0x4b, 0x14, 0xcf, + 0x48, 0x40, 0xde, 0x99, 0x0d, 0xd5, 0x92, 0x04, 0xf6, 0x43, 0x58, 0xd4, 0x8d, 0xab, 0x51, 0x5c, + 0x68, 0x8c, 0x36, 0x74, 0x9e, 0xfb, 0x23, 0x12, 0x15, 0x53, 0xc3, 0x50, 0x4b, 0xfc, 0x98, 0xe8, + 0xa1, 0xc9, 0xd8, 0xbe, 0x09, 0x8b, 0x9a, 0xa3, 0x7f, 0xb0, 0x02, 0x8d, 0x43, 0x3f, 0xca, 0x88, + 0xf2, 0x6f, 0x79, 0x1a, 0xd9, 0xbb, 0xd0, 0x50, 0xfe, 0x82, 0x11, 0x09, 0x49, 0xaa, 0x8d, 0x34, + 0xc2, 0x2e, 0x34, 0x49, 0xc2, 0x59, 0x48, 0x52, 0x73, 0x4e, 0x96, 0x76, 0xa9, 0x2c, 0xed, 0x71, + 0xc2, 0xd9, 0xd1, 0xb0, 0x26, 0xa6, 0xe4, 0x15, 0x2c, 0x7b, 0x0f, 0xea, 0x32, 0x8f, 0x87, 0xd0, + 0x9a, 0xed, 0xa9, 0x34, 0xfd, 0xdf, 0x61, 0x97, 0x32, 0xd1, 0x5c, 0x14, 0x26, 0x44, 0xde, 0x7d, + 0xcb, 0x93, 0xf1, 0xda, 0x0d, 0x68, 0xcd, 0x66, 0x8d, 0xdb, 0xd0, 0x7c, 0xf2, 0xc2, 0x7b, 0xbd, + 0xe9, 0x6d, 0x2f, 0x1b, 0xb8, 0x03, 0x0b, 0xc3, 0xcd, 0xad, 0x67, 0x12, 0xa1, 0xc1, 0x47, 0x04, + 0x0d, 0xb1, 0x70, 0x84, 0xe1, 0xfb, 0x50, 0x13, 0x11, 0xbe, 0x5a, 0xd6, 0x5e, 0xd9, 0xe2, 0xee, + 0xca, 0x9f, 0x69, 0xbd, 0xa1, 0x06, 0xde, 0x81, 0xfa, 0xd6, 0x84, 0x8c, 0xdf, 0x62, 0xdb, 0x11, + 0xaf, 0xc2, 0xd1, 0x6f, 0xe1, 0x70, 0xdd, 0x79, 0x2a, 0x23, 0x79, 0x58, 0xd8, 0x5c, 0xff, 0x27, + 0x47, 0x79, 0x0e, 0x3e, 0x20, 0x68, 0x8a, 0xcb, 0x0f, 0x09, 0xc3, 0x8f, 0xa0, 0x2e, 0xf7, 0x00, + 0x57, 0x0a, 0xa8, 0xbe, 0x88, 0xee, 0xb5, 0xbf, 0xf2, 0x45, 0x65, 0x77, 0x90, 0x78, 0x02, 0xf2, + 0x92, 0xab, 0xea, 0xea, 0x66, 0x54, 0xd5, 0xbf, 0x6d, 0x83, 0x6d, 0x0c, 0x6f, 0x9d, 0x9e, 0x59, + 0xc6, 0xe7, 0x33, 0xcb, 0x38, 0x3f, 0xb3, 0xd0, 0xfb, 0xdc, 0x42, 0x9f, 0x72, 0x0b, 0x9d, 0xe4, + 0x16, 0x3a, 0xcd, 0x2d, 0xf4, 0x2d, 0xb7, 0xd0, 0x8f, 0xdc, 0x32, 0xce, 0x73, 0x0b, 0x1d, 0x7f, + 0xb7, 0x8c, 0x51, 0x43, 0x9a, 0xdc, 0xfd, 0x15, 0x00, 0x00, 0xff, 0xff, 0x86, 0x37, 0x4d, 0x36, + 0xa2, 0x04, 0x00, 0x00, +} diff --git a/pkg/parser/labels.go b/pkg/parser/labels.go new file mode 100644 index 0000000000000..4517094b4b0c0 --- /dev/null +++ b/pkg/parser/labels.go @@ -0,0 +1,546 @@ +//line pkg/parser/labels.y:2 +package parser + +import __yyfmt__ "fmt" + +//line pkg/parser/labels.y:2 +import ( + "github.com/prometheus/prometheus/pkg/labels" +) + +//line pkg/parser/labels.y:9 +type labelsSymType struct { + yys int + MatchersExpr []*labels.Matcher + Matchers []*labels.Matcher + Matcher *labels.Matcher + LabelsExpr labels.Labels + Labels labels.Labels + Label labels.Label + str string + int int64 + Identifier string +} + +const IDENTIFIER = 57346 +const STRING = 57347 +const MATCHERS = 57348 +const LABELS = 57349 +const EQ = 57350 +const NEQ = 57351 +const RE = 57352 +const NRE = 57353 +const OPEN_BRACE = 57354 +const CLOSE_BRACE = 57355 +const COMMA = 57356 +const DOT = 57357 + +var labelsToknames = [...]string{ + "$end", + "error", + "$unk", + "IDENTIFIER", + "STRING", + "MATCHERS", + "LABELS", + "EQ", + "NEQ", + "RE", + "NRE", + "OPEN_BRACE", + "CLOSE_BRACE", + "COMMA", + "DOT", +} +var labelsStatenames = [...]string{} + +const labelsEofCode = 1 +const labelsErrCode = 2 +const labelsInitialStackSize = 16 + +//line pkg/parser/labels.y:63 + +//line yacctab:1 +var labelsExca = [...]int{ + -1, 1, + 1, -1, + -2, 0, +} + +const labelsPrivate = 57344 + +const labelsLast = 32 + +var labelsAct = [...]int{ + + 8, 11, 15, 16, 17, 18, 12, 22, 5, 19, + 20, 21, 7, 4, 19, 13, 14, 2, 3, 30, + 27, 26, 12, 29, 25, 24, 9, 23, 28, 10, + 6, 1, +} +var labelsPact = [...]int{ + + 11, -1000, 1, -4, 22, 22, 2, -1000, -6, -1000, + -3, -1000, -1, -1000, 22, 20, 19, 16, 15, 24, + -1000, 22, 14, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, +} +var labelsPgo = [...]int{ + + 0, 31, 30, 12, 29, 1, 0, +} +var labelsR1 = [...]int{ + + 0, 1, 1, 2, 2, 3, 3, 3, 3, 4, + 4, 5, 6, 6, +} +var labelsR2 = [...]int{ + + 0, 4, 4, 1, 3, 3, 3, 3, 3, 1, + 3, 3, 1, 3, +} +var labelsChk = [...]int{ + + -1000, -1, 6, 7, 12, 12, -2, -3, -6, 4, + -4, -5, -6, 13, 14, 8, 9, 10, 11, 15, + 13, 14, 8, -3, 5, 5, 5, 5, 4, -5, + 5, +} +var labelsDef = [...]int{ + + 0, -2, 0, 0, 0, 0, 0, 3, 0, 12, + 0, 9, 0, 1, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 4, 5, 6, 7, 8, 13, 10, + 11, +} +var labelsTok1 = [...]int{ + + 1, +} +var labelsTok2 = [...]int{ + + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, +} +var labelsTok3 = [...]int{ + 0, +} + +var labelsErrorMessages = [...]struct { + state int + token int + msg string +}{} + +//line yaccpar:1 + +/* parser for yacc output */ + +var ( + labelsDebug = 0 + labelsErrorVerbose = false +) + +type labelsLexer interface { + Lex(lval *labelsSymType) int + Error(s string) +} + +type labelsParser interface { + Parse(labelsLexer) int + Lookahead() int +} + +type labelsParserImpl struct { + lval labelsSymType + stack [labelsInitialStackSize]labelsSymType + char int +} + +func (p *labelsParserImpl) Lookahead() int { + return p.char +} + +func labelsNewParser() labelsParser { + return &labelsParserImpl{} +} + +const labelsFlag = -1000 + +func labelsTokname(c int) string { + if c >= 1 && c-1 < len(labelsToknames) { + if labelsToknames[c-1] != "" { + return labelsToknames[c-1] + } + } + return __yyfmt__.Sprintf("tok-%v", c) +} + +func labelsStatname(s int) string { + if s >= 0 && s < len(labelsStatenames) { + if labelsStatenames[s] != "" { + return labelsStatenames[s] + } + } + return __yyfmt__.Sprintf("state-%v", s) +} + +func labelsErrorMessage(state, lookAhead int) string { + const TOKSTART = 4 + + if !labelsErrorVerbose { + return "syntax error" + } + + for _, e := range labelsErrorMessages { + if e.state == state && e.token == lookAhead { + return "syntax error: " + e.msg + } + } + + res := "syntax error: unexpected " + labelsTokname(lookAhead) + + // To match Bison, suggest at most four expected tokens. + expected := make([]int, 0, 4) + + // Look for shiftable tokens. + base := labelsPact[state] + for tok := TOKSTART; tok-1 < len(labelsToknames); tok++ { + if n := base + tok; n >= 0 && n < labelsLast && labelsChk[labelsAct[n]] == tok { + if len(expected) == cap(expected) { + return res + } + expected = append(expected, tok) + } + } + + if labelsDef[state] == -2 { + i := 0 + for labelsExca[i] != -1 || labelsExca[i+1] != state { + i += 2 + } + + // Look for tokens that we accept or reduce. + for i += 2; labelsExca[i] >= 0; i += 2 { + tok := labelsExca[i] + if tok < TOKSTART || labelsExca[i+1] == 0 { + continue + } + if len(expected) == cap(expected) { + return res + } + expected = append(expected, tok) + } + + // If the default action is to accept or reduce, give up. + if labelsExca[i+1] != 0 { + return res + } + } + + for i, tok := range expected { + if i == 0 { + res += ", expecting " + } else { + res += " or " + } + res += labelsTokname(tok) + } + return res +} + +func labelslex1(lex labelsLexer, lval *labelsSymType) (char, token int) { + token = 0 + char = lex.Lex(lval) + if char <= 0 { + token = labelsTok1[0] + goto out + } + if char < len(labelsTok1) { + token = labelsTok1[char] + goto out + } + if char >= labelsPrivate { + if char < labelsPrivate+len(labelsTok2) { + token = labelsTok2[char-labelsPrivate] + goto out + } + } + for i := 0; i < len(labelsTok3); i += 2 { + token = labelsTok3[i+0] + if token == char { + token = labelsTok3[i+1] + goto out + } + } + +out: + if token == 0 { + token = labelsTok2[1] /* unknown char */ + } + if labelsDebug >= 3 { + __yyfmt__.Printf("lex %s(%d)\n", labelsTokname(token), uint(char)) + } + return char, token +} + +func labelsParse(labelslex labelsLexer) int { + return labelsNewParser().Parse(labelslex) +} + +func (labelsrcvr *labelsParserImpl) Parse(labelslex labelsLexer) int { + var labelsn int + var labelsVAL labelsSymType + var labelsDollar []labelsSymType + _ = labelsDollar // silence set and not used + labelsS := labelsrcvr.stack[:] + + Nerrs := 0 /* number of errors */ + Errflag := 0 /* error recovery flag */ + labelsstate := 0 + labelsrcvr.char = -1 + labelstoken := -1 // labelsrcvr.char translated into internal numbering + defer func() { + // Make sure we report no lookahead when not parsing. + labelsstate = -1 + labelsrcvr.char = -1 + labelstoken = -1 + }() + labelsp := -1 + goto labelsstack + +ret0: + return 0 + +ret1: + return 1 + +labelsstack: + /* put a state and value onto the stack */ + if labelsDebug >= 4 { + __yyfmt__.Printf("char %v in %v\n", labelsTokname(labelstoken), labelsStatname(labelsstate)) + } + + labelsp++ + if labelsp >= len(labelsS) { + nyys := make([]labelsSymType, len(labelsS)*2) + copy(nyys, labelsS) + labelsS = nyys + } + labelsS[labelsp] = labelsVAL + labelsS[labelsp].yys = labelsstate + +labelsnewstate: + labelsn = labelsPact[labelsstate] + if labelsn <= labelsFlag { + goto labelsdefault /* simple state */ + } + if labelsrcvr.char < 0 { + labelsrcvr.char, labelstoken = labelslex1(labelslex, &labelsrcvr.lval) + } + labelsn += labelstoken + if labelsn < 0 || labelsn >= labelsLast { + goto labelsdefault + } + labelsn = labelsAct[labelsn] + if labelsChk[labelsn] == labelstoken { /* valid shift */ + labelsrcvr.char = -1 + labelstoken = -1 + labelsVAL = labelsrcvr.lval + labelsstate = labelsn + if Errflag > 0 { + Errflag-- + } + goto labelsstack + } + +labelsdefault: + /* default state action */ + labelsn = labelsDef[labelsstate] + if labelsn == -2 { + if labelsrcvr.char < 0 { + labelsrcvr.char, labelstoken = labelslex1(labelslex, &labelsrcvr.lval) + } + + /* look through exception table */ + xi := 0 + for { + if labelsExca[xi+0] == -1 && labelsExca[xi+1] == labelsstate { + break + } + xi += 2 + } + for xi += 2; ; xi += 2 { + labelsn = labelsExca[xi+0] + if labelsn < 0 || labelsn == labelstoken { + break + } + } + labelsn = labelsExca[xi+1] + if labelsn < 0 { + goto ret0 + } + } + if labelsn == 0 { + /* error ... attempt to resume parsing */ + switch Errflag { + case 0: /* brand new error */ + labelslex.Error(labelsErrorMessage(labelsstate, labelstoken)) + Nerrs++ + if labelsDebug >= 1 { + __yyfmt__.Printf("%s", labelsStatname(labelsstate)) + __yyfmt__.Printf(" saw %s\n", labelsTokname(labelstoken)) + } + fallthrough + + case 1, 2: /* incompletely recovered error ... try again */ + Errflag = 3 + + /* find a state where "error" is a legal shift action */ + for labelsp >= 0 { + labelsn = labelsPact[labelsS[labelsp].yys] + labelsErrCode + if labelsn >= 0 && labelsn < labelsLast { + labelsstate = labelsAct[labelsn] /* simulate a shift of "error" */ + if labelsChk[labelsstate] == labelsErrCode { + goto labelsstack + } + } + + /* the current p has no shift on "error", pop stack */ + if labelsDebug >= 2 { + __yyfmt__.Printf("error recovery pops state %d\n", labelsS[labelsp].yys) + } + labelsp-- + } + /* there is no state on the stack with an error shift ... abort */ + goto ret1 + + case 3: /* no shift yet; clobber input char */ + if labelsDebug >= 2 { + __yyfmt__.Printf("error recovery discards %s\n", labelsTokname(labelstoken)) + } + if labelstoken == labelsEofCode { + goto ret1 + } + labelsrcvr.char = -1 + labelstoken = -1 + goto labelsnewstate /* try again in the same state */ + } + } + + /* reduction by production labelsn */ + if labelsDebug >= 2 { + __yyfmt__.Printf("reduce %v in:\n\t%v\n", labelsn, labelsStatname(labelsstate)) + } + + labelsnt := labelsn + labelspt := labelsp + _ = labelspt // guard against "declared and not used" + + labelsp -= labelsR2[labelsn] + // labelsp is now the index of $0. Perform the default action. Iff the + // reduced production is ε, $1 is possibly out of range. + if labelsp+1 >= len(labelsS) { + nyys := make([]labelsSymType, len(labelsS)*2) + copy(nyys, labelsS) + labelsS = nyys + } + labelsVAL = labelsS[labelsp+1] + + /* consult goto table to find next state */ + labelsn = labelsR1[labelsn] + labelsg := labelsPgo[labelsn] + labelsj := labelsg + labelsS[labelsp].yys + 1 + + if labelsj >= labelsLast { + labelsstate = labelsAct[labelsg] + } else { + labelsstate = labelsAct[labelsj] + if labelsChk[labelsstate] != -labelsn { + labelsstate = labelsAct[labelsg] + } + } + // dummy call; replaced with literal code + switch labelsnt { + + case 1: + labelsDollar = labelsS[labelspt-4 : labelspt+1] + //line pkg/parser/labels.y:35 + { + labelslex.(*lexer).matcher = labelsDollar[3].Matchers + } + case 2: + labelsDollar = labelsS[labelspt-4 : labelspt+1] + //line pkg/parser/labels.y:36 + { + labelslex.(*lexer).labels = labelsDollar[3].Labels + } + case 3: + labelsDollar = labelsS[labelspt-1 : labelspt+1] + //line pkg/parser/labels.y:39 + { + labelsVAL.Matchers = []*labels.Matcher{labelsDollar[1].Matcher} + } + case 4: + labelsDollar = labelsS[labelspt-3 : labelspt+1] + //line pkg/parser/labels.y:40 + { + labelsVAL.Matchers = append(labelsDollar[1].Matchers, labelsDollar[3].Matcher) + } + case 5: + labelsDollar = labelsS[labelspt-3 : labelspt+1] + //line pkg/parser/labels.y:44 + { + labelsVAL.Matcher = mustNewMatcher(labels.MatchEqual, labelsDollar[1].Identifier, labelsDollar[3].str) + } + case 6: + labelsDollar = labelsS[labelspt-3 : labelspt+1] + //line pkg/parser/labels.y:45 + { + labelsVAL.Matcher = mustNewMatcher(labels.MatchNotEqual, labelsDollar[1].Identifier, labelsDollar[3].str) + } + case 7: + labelsDollar = labelsS[labelspt-3 : labelspt+1] + //line pkg/parser/labels.y:46 + { + labelsVAL.Matcher = mustNewMatcher(labels.MatchRegexp, labelsDollar[1].Identifier, labelsDollar[3].str) + } + case 8: + labelsDollar = labelsS[labelspt-3 : labelspt+1] + //line pkg/parser/labels.y:47 + { + labelsVAL.Matcher = mustNewMatcher(labels.MatchNotRegexp, labelsDollar[1].Identifier, labelsDollar[3].str) + } + case 9: + labelsDollar = labelsS[labelspt-1 : labelspt+1] + //line pkg/parser/labels.y:51 + { + labelsVAL.Labels = labels.Labels{labelsDollar[1].Label} + } + case 10: + labelsDollar = labelsS[labelspt-3 : labelspt+1] + //line pkg/parser/labels.y:52 + { + labelsVAL.Labels = append(labelsDollar[1].Labels, labelsDollar[3].Label) + } + case 11: + labelsDollar = labelsS[labelspt-3 : labelspt+1] + //line pkg/parser/labels.y:56 + { + labelsVAL.Label = labels.Label{Name: labelsDollar[1].Identifier, Value: labelsDollar[3].str} + } + case 12: + labelsDollar = labelsS[labelspt-1 : labelspt+1] + //line pkg/parser/labels.y:60 + { + labelsVAL.Identifier = labelsDollar[1].str + } + case 13: + labelsDollar = labelsS[labelspt-3 : labelspt+1] + //line pkg/parser/labels.y:61 + { + labelsVAL.Identifier = labelsDollar[1].Identifier + "." + labelsDollar[3].str + } + } + goto labelsstack /* stack new state and value */ +} diff --git a/pkg/querier/querier.go b/pkg/querier/querier.go index df1372ade4363..67a6ce8feba79 100644 --- a/pkg/querier/querier.go +++ b/pkg/querier/querier.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc/health/grpc_health_v1" "github.com/grafana/logish/pkg/ingester/client" + "github.com/grafana/logish/pkg/iter" "github.com/grafana/logish/pkg/logproto" ) @@ -97,11 +98,11 @@ func (q *Querier) Query(ctx context.Context, req *logproto.QueryRequest) (*logpr return nil, err } - iterators := make([]EntryIterator, len(clients)) + iterators := make([]iter.EntryIterator, len(clients)) for i := range clients { - iterators[i] = newQueryClientIterator(clients[i].(logproto.Querier_QueryClient), req.Direction) + iterators[i] = iter.NewQueryClientIterator(clients[i].(logproto.Querier_QueryClient), req.Direction) } - iterator := NewHeapIterator(iterators, req.Direction) + iterator := iter.NewHeapIterator(iterators, req.Direction) defer iterator.Close() resp, _, err := ReadBatch(iterator, req.Limit) @@ -126,7 +127,7 @@ func (q *Querier) Label(ctx context.Context, req *logproto.LabelRequest) (*logpr }, nil } -func ReadBatch(i EntryIterator, size uint32) (*logproto.QueryResponse, uint32, error) { +func ReadBatch(i iter.EntryIterator, size uint32) (*logproto.QueryResponse, uint32, error) { streams := map[string]*logproto.Stream{} respSize := uint32(0) for ; respSize < size && i.Next(); respSize++ { @@ -156,7 +157,7 @@ func (*Querier) Check(ctx context.Context, req *grpc_health_v1.HealthCheckReques } type iteratorBatcher struct { - iterator EntryIterator + iterator iter.EntryIterator queryServer logproto.Querier_QueryServer }