Collector implementation

This commit is contained in:
2026-03-14 20:07:22 +01:00
parent 4393ae2726
commit 6ca296b2e8
16 changed files with 3052 additions and 0 deletions

82
proto/logtail.proto Normal file
View File

@@ -0,0 +1,82 @@
syntax = "proto3";
package logtail;
option go_package = "git.ipng.ch/ipng/nginx-logtail/proto/logtailpb";
// Filter restricts results to entries matching all specified fields.
// Unset fields match everything.
message Filter {
optional string website = 1;
optional string client_prefix = 2;
optional string http_request_uri = 3;
optional int32 http_response = 4;
}
enum GroupBy {
WEBSITE = 0;
CLIENT_PREFIX = 1;
REQUEST_URI = 2;
HTTP_RESPONSE = 3;
}
enum Window {
W1M = 0; // last 1 minute
W5M = 1; // last 5 minutes
W15M = 2; // last 15 minutes
W60M = 3; // last 60 minutes
W6H = 4; // last 6 hours
W24H = 5; // last 24 hours
}
// TopN
message TopNRequest {
Filter filter = 1;
GroupBy group_by = 2;
int32 n = 3;
Window window = 4;
}
message TopNEntry {
string label = 1;
int64 count = 2;
}
message TopNResponse {
repeated TopNEntry entries = 1;
string source = 2; // hostname of the responding node
}
// Trend — one total count per bucket, for sparklines
message TrendRequest {
Filter filter = 1;
Window window = 2;
}
message TrendPoint {
int64 timestamp_unix = 1;
int64 count = 2;
}
message TrendResponse {
repeated TrendPoint points = 1;
string source = 2;
}
// StreamSnapshots — pushed by collector after every minute rotation
message SnapshotRequest {}
message Snapshot {
string source = 1;
int64 timestamp = 2;
repeated TopNEntry entries = 3; // top-50K for this 1-minute bucket, sorted desc
}
service LogtailService {
rpc TopN (TopNRequest) returns (TopNResponse);
rpc Trend (TrendRequest) returns (TrendResponse);
rpc StreamSnapshots (SnapshotRequest) returns (stream Snapshot);
}

View File

@@ -0,0 +1,759 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.11
// protoc v3.21.12
// source: logtail.proto
package logtailpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type GroupBy int32
const (
GroupBy_WEBSITE GroupBy = 0
GroupBy_CLIENT_PREFIX GroupBy = 1
GroupBy_REQUEST_URI GroupBy = 2
GroupBy_HTTP_RESPONSE GroupBy = 3
)
// Enum value maps for GroupBy.
var (
GroupBy_name = map[int32]string{
0: "WEBSITE",
1: "CLIENT_PREFIX",
2: "REQUEST_URI",
3: "HTTP_RESPONSE",
}
GroupBy_value = map[string]int32{
"WEBSITE": 0,
"CLIENT_PREFIX": 1,
"REQUEST_URI": 2,
"HTTP_RESPONSE": 3,
}
)
func (x GroupBy) Enum() *GroupBy {
p := new(GroupBy)
*p = x
return p
}
func (x GroupBy) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (GroupBy) Descriptor() protoreflect.EnumDescriptor {
return file_logtail_proto_enumTypes[0].Descriptor()
}
func (GroupBy) Type() protoreflect.EnumType {
return &file_logtail_proto_enumTypes[0]
}
func (x GroupBy) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use GroupBy.Descriptor instead.
func (GroupBy) EnumDescriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{0}
}
type Window int32
const (
Window_W1M Window = 0 // last 1 minute
Window_W5M Window = 1 // last 5 minutes
Window_W15M Window = 2 // last 15 minutes
Window_W60M Window = 3 // last 60 minutes
Window_W6H Window = 4 // last 6 hours
Window_W24H Window = 5 // last 24 hours
)
// Enum value maps for Window.
var (
Window_name = map[int32]string{
0: "W1M",
1: "W5M",
2: "W15M",
3: "W60M",
4: "W6H",
5: "W24H",
}
Window_value = map[string]int32{
"W1M": 0,
"W5M": 1,
"W15M": 2,
"W60M": 3,
"W6H": 4,
"W24H": 5,
}
)
func (x Window) Enum() *Window {
p := new(Window)
*p = x
return p
}
func (x Window) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Window) Descriptor() protoreflect.EnumDescriptor {
return file_logtail_proto_enumTypes[1].Descriptor()
}
func (Window) Type() protoreflect.EnumType {
return &file_logtail_proto_enumTypes[1]
}
func (x Window) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Window.Descriptor instead.
func (Window) EnumDescriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{1}
}
// Filter restricts results to entries matching all specified fields.
// Unset fields match everything.
type Filter struct {
state protoimpl.MessageState `protogen:"open.v1"`
Website *string `protobuf:"bytes,1,opt,name=website,proto3,oneof" json:"website,omitempty"`
ClientPrefix *string `protobuf:"bytes,2,opt,name=client_prefix,json=clientPrefix,proto3,oneof" json:"client_prefix,omitempty"`
HttpRequestUri *string `protobuf:"bytes,3,opt,name=http_request_uri,json=httpRequestUri,proto3,oneof" json:"http_request_uri,omitempty"`
HttpResponse *int32 `protobuf:"varint,4,opt,name=http_response,json=httpResponse,proto3,oneof" json:"http_response,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Filter) Reset() {
*x = Filter{}
mi := &file_logtail_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Filter) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Filter) ProtoMessage() {}
func (x *Filter) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Filter.ProtoReflect.Descriptor instead.
func (*Filter) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{0}
}
func (x *Filter) GetWebsite() string {
if x != nil && x.Website != nil {
return *x.Website
}
return ""
}
func (x *Filter) GetClientPrefix() string {
if x != nil && x.ClientPrefix != nil {
return *x.ClientPrefix
}
return ""
}
func (x *Filter) GetHttpRequestUri() string {
if x != nil && x.HttpRequestUri != nil {
return *x.HttpRequestUri
}
return ""
}
func (x *Filter) GetHttpResponse() int32 {
if x != nil && x.HttpResponse != nil {
return *x.HttpResponse
}
return 0
}
type TopNRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Filter *Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"`
GroupBy GroupBy `protobuf:"varint,2,opt,name=group_by,json=groupBy,proto3,enum=logtail.GroupBy" json:"group_by,omitempty"`
N int32 `protobuf:"varint,3,opt,name=n,proto3" json:"n,omitempty"`
Window Window `protobuf:"varint,4,opt,name=window,proto3,enum=logtail.Window" json:"window,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TopNRequest) Reset() {
*x = TopNRequest{}
mi := &file_logtail_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TopNRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TopNRequest) ProtoMessage() {}
func (x *TopNRequest) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TopNRequest.ProtoReflect.Descriptor instead.
func (*TopNRequest) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{1}
}
func (x *TopNRequest) GetFilter() *Filter {
if x != nil {
return x.Filter
}
return nil
}
func (x *TopNRequest) GetGroupBy() GroupBy {
if x != nil {
return x.GroupBy
}
return GroupBy_WEBSITE
}
func (x *TopNRequest) GetN() int32 {
if x != nil {
return x.N
}
return 0
}
func (x *TopNRequest) GetWindow() Window {
if x != nil {
return x.Window
}
return Window_W1M
}
type TopNEntry struct {
state protoimpl.MessageState `protogen:"open.v1"`
Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"`
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TopNEntry) Reset() {
*x = TopNEntry{}
mi := &file_logtail_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TopNEntry) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TopNEntry) ProtoMessage() {}
func (x *TopNEntry) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TopNEntry.ProtoReflect.Descriptor instead.
func (*TopNEntry) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{2}
}
func (x *TopNEntry) GetLabel() string {
if x != nil {
return x.Label
}
return ""
}
func (x *TopNEntry) GetCount() int64 {
if x != nil {
return x.Count
}
return 0
}
type TopNResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Entries []*TopNEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"` // hostname of the responding node
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TopNResponse) Reset() {
*x = TopNResponse{}
mi := &file_logtail_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TopNResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TopNResponse) ProtoMessage() {}
func (x *TopNResponse) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TopNResponse.ProtoReflect.Descriptor instead.
func (*TopNResponse) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{3}
}
func (x *TopNResponse) GetEntries() []*TopNEntry {
if x != nil {
return x.Entries
}
return nil
}
func (x *TopNResponse) GetSource() string {
if x != nil {
return x.Source
}
return ""
}
type TrendRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Filter *Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"`
Window Window `protobuf:"varint,2,opt,name=window,proto3,enum=logtail.Window" json:"window,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TrendRequest) Reset() {
*x = TrendRequest{}
mi := &file_logtail_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TrendRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TrendRequest) ProtoMessage() {}
func (x *TrendRequest) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TrendRequest.ProtoReflect.Descriptor instead.
func (*TrendRequest) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{4}
}
func (x *TrendRequest) GetFilter() *Filter {
if x != nil {
return x.Filter
}
return nil
}
func (x *TrendRequest) GetWindow() Window {
if x != nil {
return x.Window
}
return Window_W1M
}
type TrendPoint struct {
state protoimpl.MessageState `protogen:"open.v1"`
TimestampUnix int64 `protobuf:"varint,1,opt,name=timestamp_unix,json=timestampUnix,proto3" json:"timestamp_unix,omitempty"`
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TrendPoint) Reset() {
*x = TrendPoint{}
mi := &file_logtail_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TrendPoint) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TrendPoint) ProtoMessage() {}
func (x *TrendPoint) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TrendPoint.ProtoReflect.Descriptor instead.
func (*TrendPoint) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{5}
}
func (x *TrendPoint) GetTimestampUnix() int64 {
if x != nil {
return x.TimestampUnix
}
return 0
}
func (x *TrendPoint) GetCount() int64 {
if x != nil {
return x.Count
}
return 0
}
type TrendResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Points []*TrendPoint `protobuf:"bytes,1,rep,name=points,proto3" json:"points,omitempty"`
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TrendResponse) Reset() {
*x = TrendResponse{}
mi := &file_logtail_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TrendResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TrendResponse) ProtoMessage() {}
func (x *TrendResponse) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TrendResponse.ProtoReflect.Descriptor instead.
func (*TrendResponse) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{6}
}
func (x *TrendResponse) GetPoints() []*TrendPoint {
if x != nil {
return x.Points
}
return nil
}
func (x *TrendResponse) GetSource() string {
if x != nil {
return x.Source
}
return ""
}
type SnapshotRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SnapshotRequest) Reset() {
*x = SnapshotRequest{}
mi := &file_logtail_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SnapshotRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SnapshotRequest) ProtoMessage() {}
func (x *SnapshotRequest) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SnapshotRequest.ProtoReflect.Descriptor instead.
func (*SnapshotRequest) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{7}
}
type Snapshot struct {
state protoimpl.MessageState `protogen:"open.v1"`
Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"`
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Entries []*TopNEntry `protobuf:"bytes,3,rep,name=entries,proto3" json:"entries,omitempty"` // top-50K for this 1-minute bucket, sorted desc
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Snapshot) Reset() {
*x = Snapshot{}
mi := &file_logtail_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Snapshot) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Snapshot) ProtoMessage() {}
func (x *Snapshot) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Snapshot.ProtoReflect.Descriptor instead.
func (*Snapshot) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{8}
}
func (x *Snapshot) GetSource() string {
if x != nil {
return x.Source
}
return ""
}
func (x *Snapshot) GetTimestamp() int64 {
if x != nil {
return x.Timestamp
}
return 0
}
func (x *Snapshot) GetEntries() []*TopNEntry {
if x != nil {
return x.Entries
}
return nil
}
var File_logtail_proto protoreflect.FileDescriptor
const file_logtail_proto_rawDesc = "" +
"\n" +
"\rlogtail.proto\x12\alogtail\"\xef\x01\n" +
"\x06Filter\x12\x1d\n" +
"\awebsite\x18\x01 \x01(\tH\x00R\awebsite\x88\x01\x01\x12(\n" +
"\rclient_prefix\x18\x02 \x01(\tH\x01R\fclientPrefix\x88\x01\x01\x12-\n" +
"\x10http_request_uri\x18\x03 \x01(\tH\x02R\x0ehttpRequestUri\x88\x01\x01\x12(\n" +
"\rhttp_response\x18\x04 \x01(\x05H\x03R\fhttpResponse\x88\x01\x01B\n" +
"\n" +
"\b_websiteB\x10\n" +
"\x0e_client_prefixB\x13\n" +
"\x11_http_request_uriB\x10\n" +
"\x0e_http_response\"\x9a\x01\n" +
"\vTopNRequest\x12'\n" +
"\x06filter\x18\x01 \x01(\v2\x0f.logtail.FilterR\x06filter\x12+\n" +
"\bgroup_by\x18\x02 \x01(\x0e2\x10.logtail.GroupByR\agroupBy\x12\f\n" +
"\x01n\x18\x03 \x01(\x05R\x01n\x12'\n" +
"\x06window\x18\x04 \x01(\x0e2\x0f.logtail.WindowR\x06window\"7\n" +
"\tTopNEntry\x12\x14\n" +
"\x05label\x18\x01 \x01(\tR\x05label\x12\x14\n" +
"\x05count\x18\x02 \x01(\x03R\x05count\"T\n" +
"\fTopNResponse\x12,\n" +
"\aentries\x18\x01 \x03(\v2\x12.logtail.TopNEntryR\aentries\x12\x16\n" +
"\x06source\x18\x02 \x01(\tR\x06source\"`\n" +
"\fTrendRequest\x12'\n" +
"\x06filter\x18\x01 \x01(\v2\x0f.logtail.FilterR\x06filter\x12'\n" +
"\x06window\x18\x02 \x01(\x0e2\x0f.logtail.WindowR\x06window\"I\n" +
"\n" +
"TrendPoint\x12%\n" +
"\x0etimestamp_unix\x18\x01 \x01(\x03R\rtimestampUnix\x12\x14\n" +
"\x05count\x18\x02 \x01(\x03R\x05count\"T\n" +
"\rTrendResponse\x12+\n" +
"\x06points\x18\x01 \x03(\v2\x13.logtail.TrendPointR\x06points\x12\x16\n" +
"\x06source\x18\x02 \x01(\tR\x06source\"\x11\n" +
"\x0fSnapshotRequest\"n\n" +
"\bSnapshot\x12\x16\n" +
"\x06source\x18\x01 \x01(\tR\x06source\x12\x1c\n" +
"\ttimestamp\x18\x02 \x01(\x03R\ttimestamp\x12,\n" +
"\aentries\x18\x03 \x03(\v2\x12.logtail.TopNEntryR\aentries*M\n" +
"\aGroupBy\x12\v\n" +
"\aWEBSITE\x10\x00\x12\x11\n" +
"\rCLIENT_PREFIX\x10\x01\x12\x0f\n" +
"\vREQUEST_URI\x10\x02\x12\x11\n" +
"\rHTTP_RESPONSE\x10\x03*A\n" +
"\x06Window\x12\a\n" +
"\x03W1M\x10\x00\x12\a\n" +
"\x03W5M\x10\x01\x12\b\n" +
"\x04W15M\x10\x02\x12\b\n" +
"\x04W60M\x10\x03\x12\a\n" +
"\x03W6H\x10\x04\x12\b\n" +
"\x04W24H\x10\x052\xbf\x01\n" +
"\x0eLogtailService\x123\n" +
"\x04TopN\x12\x14.logtail.TopNRequest\x1a\x15.logtail.TopNResponse\x126\n" +
"\x05Trend\x12\x15.logtail.TrendRequest\x1a\x16.logtail.TrendResponse\x12@\n" +
"\x0fStreamSnapshots\x12\x18.logtail.SnapshotRequest\x1a\x11.logtail.Snapshot0\x01B0Z.git.ipng.ch/ipng/nginx-logtail/proto/logtailpbb\x06proto3"
var (
file_logtail_proto_rawDescOnce sync.Once
file_logtail_proto_rawDescData []byte
)
func file_logtail_proto_rawDescGZIP() []byte {
file_logtail_proto_rawDescOnce.Do(func() {
file_logtail_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_logtail_proto_rawDesc), len(file_logtail_proto_rawDesc)))
})
return file_logtail_proto_rawDescData
}
var file_logtail_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_logtail_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_logtail_proto_goTypes = []any{
(GroupBy)(0), // 0: logtail.GroupBy
(Window)(0), // 1: logtail.Window
(*Filter)(nil), // 2: logtail.Filter
(*TopNRequest)(nil), // 3: logtail.TopNRequest
(*TopNEntry)(nil), // 4: logtail.TopNEntry
(*TopNResponse)(nil), // 5: logtail.TopNResponse
(*TrendRequest)(nil), // 6: logtail.TrendRequest
(*TrendPoint)(nil), // 7: logtail.TrendPoint
(*TrendResponse)(nil), // 8: logtail.TrendResponse
(*SnapshotRequest)(nil), // 9: logtail.SnapshotRequest
(*Snapshot)(nil), // 10: logtail.Snapshot
}
var file_logtail_proto_depIdxs = []int32{
2, // 0: logtail.TopNRequest.filter:type_name -> logtail.Filter
0, // 1: logtail.TopNRequest.group_by:type_name -> logtail.GroupBy
1, // 2: logtail.TopNRequest.window:type_name -> logtail.Window
4, // 3: logtail.TopNResponse.entries:type_name -> logtail.TopNEntry
2, // 4: logtail.TrendRequest.filter:type_name -> logtail.Filter
1, // 5: logtail.TrendRequest.window:type_name -> logtail.Window
7, // 6: logtail.TrendResponse.points:type_name -> logtail.TrendPoint
4, // 7: logtail.Snapshot.entries:type_name -> logtail.TopNEntry
3, // 8: logtail.LogtailService.TopN:input_type -> logtail.TopNRequest
6, // 9: logtail.LogtailService.Trend:input_type -> logtail.TrendRequest
9, // 10: logtail.LogtailService.StreamSnapshots:input_type -> logtail.SnapshotRequest
5, // 11: logtail.LogtailService.TopN:output_type -> logtail.TopNResponse
8, // 12: logtail.LogtailService.Trend:output_type -> logtail.TrendResponse
10, // 13: logtail.LogtailService.StreamSnapshots:output_type -> logtail.Snapshot
11, // [11:14] is the sub-list for method output_type
8, // [8:11] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
}
func init() { file_logtail_proto_init() }
func file_logtail_proto_init() {
if File_logtail_proto != nil {
return
}
file_logtail_proto_msgTypes[0].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_logtail_proto_rawDesc), len(file_logtail_proto_rawDesc)),
NumEnums: 2,
NumMessages: 9,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_logtail_proto_goTypes,
DependencyIndexes: file_logtail_proto_depIdxs,
EnumInfos: file_logtail_proto_enumTypes,
MessageInfos: file_logtail_proto_msgTypes,
}.Build()
File_logtail_proto = out.File
file_logtail_proto_goTypes = nil
file_logtail_proto_depIdxs = nil
}

View File

@@ -0,0 +1,201 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.1
// - protoc v3.21.12
// source: logtail.proto
package logtailpb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
LogtailService_TopN_FullMethodName = "/logtail.LogtailService/TopN"
LogtailService_Trend_FullMethodName = "/logtail.LogtailService/Trend"
LogtailService_StreamSnapshots_FullMethodName = "/logtail.LogtailService/StreamSnapshots"
)
// LogtailServiceClient is the client API for LogtailService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type LogtailServiceClient interface {
TopN(ctx context.Context, in *TopNRequest, opts ...grpc.CallOption) (*TopNResponse, error)
Trend(ctx context.Context, in *TrendRequest, opts ...grpc.CallOption) (*TrendResponse, error)
StreamSnapshots(ctx context.Context, in *SnapshotRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Snapshot], error)
}
type logtailServiceClient struct {
cc grpc.ClientConnInterface
}
func NewLogtailServiceClient(cc grpc.ClientConnInterface) LogtailServiceClient {
return &logtailServiceClient{cc}
}
func (c *logtailServiceClient) TopN(ctx context.Context, in *TopNRequest, opts ...grpc.CallOption) (*TopNResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(TopNResponse)
err := c.cc.Invoke(ctx, LogtailService_TopN_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *logtailServiceClient) Trend(ctx context.Context, in *TrendRequest, opts ...grpc.CallOption) (*TrendResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(TrendResponse)
err := c.cc.Invoke(ctx, LogtailService_Trend_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *logtailServiceClient) StreamSnapshots(ctx context.Context, in *SnapshotRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Snapshot], error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &LogtailService_ServiceDesc.Streams[0], LogtailService_StreamSnapshots_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &grpc.GenericClientStream[SnapshotRequest, Snapshot]{ClientStream: 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
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type LogtailService_StreamSnapshotsClient = grpc.ServerStreamingClient[Snapshot]
// LogtailServiceServer is the server API for LogtailService service.
// All implementations must embed UnimplementedLogtailServiceServer
// for forward compatibility.
type LogtailServiceServer interface {
TopN(context.Context, *TopNRequest) (*TopNResponse, error)
Trend(context.Context, *TrendRequest) (*TrendResponse, error)
StreamSnapshots(*SnapshotRequest, grpc.ServerStreamingServer[Snapshot]) error
mustEmbedUnimplementedLogtailServiceServer()
}
// UnimplementedLogtailServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedLogtailServiceServer struct{}
func (UnimplementedLogtailServiceServer) TopN(context.Context, *TopNRequest) (*TopNResponse, error) {
return nil, status.Error(codes.Unimplemented, "method TopN not implemented")
}
func (UnimplementedLogtailServiceServer) Trend(context.Context, *TrendRequest) (*TrendResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Trend not implemented")
}
func (UnimplementedLogtailServiceServer) StreamSnapshots(*SnapshotRequest, grpc.ServerStreamingServer[Snapshot]) error {
return status.Error(codes.Unimplemented, "method StreamSnapshots not implemented")
}
func (UnimplementedLogtailServiceServer) mustEmbedUnimplementedLogtailServiceServer() {}
func (UnimplementedLogtailServiceServer) testEmbeddedByValue() {}
// UnsafeLogtailServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to LogtailServiceServer will
// result in compilation errors.
type UnsafeLogtailServiceServer interface {
mustEmbedUnimplementedLogtailServiceServer()
}
func RegisterLogtailServiceServer(s grpc.ServiceRegistrar, srv LogtailServiceServer) {
// If the following call panics, it indicates UnimplementedLogtailServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&LogtailService_ServiceDesc, srv)
}
func _LogtailService_TopN_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TopNRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LogtailServiceServer).TopN(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LogtailService_TopN_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LogtailServiceServer).TopN(ctx, req.(*TopNRequest))
}
return interceptor(ctx, in, info, handler)
}
func _LogtailService_Trend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TrendRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LogtailServiceServer).Trend(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LogtailService_Trend_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LogtailServiceServer).Trend(ctx, req.(*TrendRequest))
}
return interceptor(ctx, in, info, handler)
}
func _LogtailService_StreamSnapshots_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(SnapshotRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(LogtailServiceServer).StreamSnapshots(m, &grpc.GenericServerStream[SnapshotRequest, Snapshot]{ServerStream: stream})
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type LogtailService_StreamSnapshotsServer = grpc.ServerStreamingServer[Snapshot]
// LogtailService_ServiceDesc is the grpc.ServiceDesc for LogtailService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var LogtailService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "logtail.LogtailService",
HandlerType: (*LogtailServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "TopN",
Handler: _LogtailService_TopN_Handler,
},
{
MethodName: "Trend",
Handler: _LogtailService_Trend_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "StreamSnapshots",
Handler: _LogtailService_StreamSnapshots_Handler,
ServerStreams: true,
},
},
Metadata: "logtail.proto",
}