feat: added metric service

This commit is contained in:
Marvin Zhang
2024-07-02 17:59:40 +08:00
parent ffcb44ff9e
commit 7eb8c08e0e
7 changed files with 311 additions and 408 deletions

View File

@@ -1,86 +1,66 @@
package server package server
import ( import (
"errors" "context"
"github.com/apex/log" "github.com/apex/log"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/grpc" "github.com/crawlab-team/crawlab/grpc"
"io" "go.mongodb.org/mongo-driver/bson"
"sync" "sync"
"time"
) )
type MetricsServerV2 struct { type MetricsServerV2 struct {
grpc.UnimplementedMetricsServiceV2Server grpc.UnimplementedMetricsServiceV2Server
mu *sync.Mutex
streams map[string]*grpc.MetricsServiceV2_ConnectServer
channels map[string]chan []*grpc.Metric
} }
func (svr MetricsServerV2) Connect(stream grpc.MetricsServiceV2_ConnectServer) (err error) { func (svr MetricsServerV2) Send(_ context.Context, req *grpc.MetricsServiceV2SendRequest) (res *grpc.Response, err error) {
// receive first message log.Info("[MetricsServerV2] received metric from node: " + req.NodeKey)
req, err := stream.Recv() n, err := service.NewModelServiceV2[models.NodeV2]().GetOne(bson.M{"key": req.NodeKey}, nil)
if err != nil { if err != nil {
log.Errorf("[MetricsServerV2] receive error: %v", err) log.Errorf("[MetricsServerV2] error getting node: %v", err)
return err return HandleError(err)
} }
metric := models.MetricV2{
// save stream and channel Type: req.Type,
svr.mu.Lock() NodeId: n.Id,
svr.streams[req.NodeKey] = &stream CpuUsagePercent: req.CpuUsagePercent,
svr.channels[req.NodeKey] = make(chan []*grpc.Metric) TotalMemory: req.TotalMemory,
svr.mu.Unlock() AvailableMemory: req.AvailableMemory,
UsedMemory: req.UsedMemory,
log.Info("[MetricsServerV2] connected: " + req.NodeKey) UsedMemoryPercent: req.UsedMemoryPercent,
TotalDisk: req.TotalDisk,
for { AvailableDisk: req.AvailableDisk,
// receive metrics UsedDisk: req.UsedDisk,
req, err = stream.Recv() UsedDiskPercent: req.UsedDiskPercent,
if errors.Is(err, io.EOF) { DiskReadBytesRate: req.DiskReadBytesRate,
log.Errorf("[MetricsServerV2] receive EOF: %v", err) DiskWriteBytesRate: req.DiskWriteBytesRate,
return NetworkBytesSentRate: req.NetworkBytesSentRate,
} NetworkBytesRecvRate: req.NetworkBytesRecvRate,
// send metrics to channel
svr.channels[req.NodeKey] <- req.Metrics
// keep this scope alive because once this scope exits - the stream is closed
select {
case <-stream.Context().Done():
log.Info("[MetricsServerV2] disconnected: " + req.NodeKey)
delete(svr.streams, req.NodeKey)
delete(svr.channels, req.NodeKey)
return nil
}
} }
metric.CreatedAt = time.Unix(req.Timestamp, 0)
_, err = service.NewModelServiceV2[models.MetricV2]().InsertOne(metric)
if err != nil {
log.Errorf("[MetricsServerV2] error inserting metric: %v", err)
return HandleError(err)
}
return HandleSuccess()
} }
func (svr MetricsServerV2) GetStream(nodeKey string) (stream *grpc.MetricsServiceV2_ConnectServer, ok bool) { func newMetricsServerV2() *MetricsServerV2 {
svr.mu.Lock() return &MetricsServerV2{}
defer svr.mu.Unlock()
stream, ok = svr.streams[nodeKey]
return stream, ok
}
func (svr MetricsServerV2) GetChannel(nodeKey string) (ch chan []*grpc.Metric, ok bool) {
svr.mu.Lock()
defer svr.mu.Unlock()
ch, ok = svr.channels[nodeKey]
return ch, ok
}
func NewMetricsServerV2() *MetricsServerV2 {
return &MetricsServerV2{
mu: new(sync.Mutex),
streams: make(map[string]*grpc.MetricsServiceV2_ConnectServer),
channels: make(map[string]chan []*grpc.Metric),
}
} }
var metricsServerV2 *MetricsServerV2 var metricsServerV2 *MetricsServerV2
var metricsServerV2Once = &sync.Once{}
func GetMetricsServerV2() *MetricsServerV2 { func GetMetricsServerV2() *MetricsServerV2 {
if metricsServerV2 != nil { if metricsServerV2 != nil {
return metricsServerV2 return metricsServerV2
} }
metricsServerV2 = NewMetricsServerV2() metricsServerV2Once.Do(func() {
metricsServerV2 = newMetricsServerV2()
})
return metricsServerV2 return metricsServerV2
} }

View File

@@ -25,6 +25,7 @@ var (
*new(models.DependencyTaskV2), *new(models.DependencyTaskV2),
*new(models.EnvironmentV2), *new(models.EnvironmentV2),
*new(models.GitV2), *new(models.GitV2),
*new(models.MetricV2),
*new(models.NodeV2), *new(models.NodeV2),
*new(models.NotificationSettingV2), *new(models.NotificationSettingV2),
*new(models.PermissionV2), *new(models.PermissionV2),

View File

@@ -157,4 +157,24 @@ func CreateIndexesV2() {
Options: (&options.IndexOptions{}).SetExpireAfterSeconds(60 * 60 * 24), Options: (&options.IndexOptions{}).SetExpireAfterSeconds(60 * 60 * 24),
}, },
}) })
// metrics
mongo.GetMongoCol(service.GetCollectionNameByInstance(models.MetricV2{})).MustCreateIndexes([]mongo2.IndexModel{
{
Keys: bson.D{
{"created_ts", -1},
},
Options: (&options.IndexOptions{}).SetExpireAfterSeconds(60 * 60 * 24 * 30),
},
{
Keys: bson.D{
{"node_id", 1},
},
},
{
Keys: bson.D{
{"type", 1},
},
},
})
} }

View File

@@ -0,0 +1,23 @@
package models
import "go.mongodb.org/mongo-driver/bson/primitive"
type MetricV2 struct {
any `collection:"metrics"`
BaseModelV2[MetricV2] `bson:",inline"`
Type string `json:"type" bson:"type"`
NodeId primitive.ObjectID `json:"node_id" bson:"node_id"`
CpuUsagePercent float32 `json:"cpu_usage_percent" bson:"cpu_usage_percent"`
TotalMemory uint64 `json:"total_memory" bson:"total_memory"`
AvailableMemory uint64 `json:"available_memory" bson:"available_memory"`
UsedMemory uint64 `json:"used_memory" bson:"used_memory"`
UsedMemoryPercent float32 `json:"used_memory_percent" bson:"used_memory_percent"`
TotalDisk uint64 `json:"total_disk" bson:"total_disk"`
AvailableDisk uint64 `json:"available_disk" bson:"available_disk"`
UsedDisk uint64 `json:"used_disk" bson:"used_disk"`
UsedDiskPercent float32 `json:"used_disk_percent" bson:"used_disk_percent"`
DiskReadBytesRate float32 `json:"disk_read_bytes_rate" bson:"disk_read_bytes_rate"`
DiskWriteBytesRate float32 `json:"disk_write_bytes_rate" bson:"disk_write_bytes_rate"`
NetworkBytesSentRate float32 `json:"network_bytes_sent_rate" bson:"network_bytes_sent_rate"`
NetworkBytesRecvRate float32 `json:"network_bytes_recv_rate" bson:"network_bytes_recv_rate"`
}

View File

@@ -20,65 +20,31 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
type MetricsServiceV2Code int32 type MetricsServiceV2SendRequest struct {
const (
MetricsServiceV2Code_SYNC_METRICS MetricsServiceV2Code = 0
)
// Enum value maps for MetricsServiceV2Code.
var (
MetricsServiceV2Code_name = map[int32]string{
0: "SYNC_METRICS",
}
MetricsServiceV2Code_value = map[string]int32{
"SYNC_METRICS": 0,
}
)
func (x MetricsServiceV2Code) Enum() *MetricsServiceV2Code {
p := new(MetricsServiceV2Code)
*p = x
return p
}
func (x MetricsServiceV2Code) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (MetricsServiceV2Code) Descriptor() protoreflect.EnumDescriptor {
return file_services_metrics_service_v2_proto_enumTypes[0].Descriptor()
}
func (MetricsServiceV2Code) Type() protoreflect.EnumType {
return &file_services_metrics_service_v2_proto_enumTypes[0]
}
func (x MetricsServiceV2Code) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use MetricsServiceV2Code.Descriptor instead.
func (MetricsServiceV2Code) EnumDescriptor() ([]byte, []int) {
return file_services_metrics_service_v2_proto_rawDescGZIP(), []int{0}
}
type Metric struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
Subsystem string `protobuf:"bytes,2,opt,name=subsystem,proto3" json:"subsystem,omitempty"` NodeKey string `protobuf:"bytes,2,opt,name=node_key,json=nodeKey,proto3" json:"node_key,omitempty"`
Module string `protobuf:"bytes,3,opt,name=module,proto3" json:"module,omitempty"` Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` CpuUsagePercent float32 `protobuf:"fixed32,4,opt,name=cpu_usage_percent,json=cpuUsagePercent,proto3" json:"cpu_usage_percent,omitempty"`
Value float32 `protobuf:"fixed32,5,opt,name=value,proto3" json:"value,omitempty"` TotalMemory uint64 `protobuf:"varint,5,opt,name=total_memory,json=totalMemory,proto3" json:"total_memory,omitempty"`
Help string `protobuf:"bytes,6,opt,name=help,proto3" json:"help,omitempty"` AvailableMemory uint64 `protobuf:"varint,6,opt,name=available_memory,json=availableMemory,proto3" json:"available_memory,omitempty"`
Labels []byte `protobuf:"bytes,7,opt,name=labels,proto3" json:"labels,omitempty"` UsedMemory uint64 `protobuf:"varint,7,opt,name=used_memory,json=usedMemory,proto3" json:"used_memory,omitempty"`
UsedMemoryPercent float32 `protobuf:"fixed32,8,opt,name=used_memory_percent,json=usedMemoryPercent,proto3" json:"used_memory_percent,omitempty"`
TotalDisk uint64 `protobuf:"varint,9,opt,name=total_disk,json=totalDisk,proto3" json:"total_disk,omitempty"`
AvailableDisk uint64 `protobuf:"varint,10,opt,name=available_disk,json=availableDisk,proto3" json:"available_disk,omitempty"`
UsedDisk uint64 `protobuf:"varint,11,opt,name=used_disk,json=usedDisk,proto3" json:"used_disk,omitempty"`
UsedDiskPercent float32 `protobuf:"fixed32,12,opt,name=used_disk_percent,json=usedDiskPercent,proto3" json:"used_disk_percent,omitempty"`
DiskReadBytesRate float32 `protobuf:"fixed32,15,opt,name=disk_read_bytes_rate,json=diskReadBytesRate,proto3" json:"disk_read_bytes_rate,omitempty"`
DiskWriteBytesRate float32 `protobuf:"fixed32,16,opt,name=disk_write_bytes_rate,json=diskWriteBytesRate,proto3" json:"disk_write_bytes_rate,omitempty"`
NetworkBytesSentRate float32 `protobuf:"fixed32,17,opt,name=network_bytes_sent_rate,json=networkBytesSentRate,proto3" json:"network_bytes_sent_rate,omitempty"`
NetworkBytesRecvRate float32 `protobuf:"fixed32,18,opt,name=network_bytes_recv_rate,json=networkBytesRecvRate,proto3" json:"network_bytes_recv_rate,omitempty"`
} }
func (x *Metric) Reset() { func (x *MetricsServiceV2SendRequest) Reset() {
*x = Metric{} *x = MetricsServiceV2SendRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_services_metrics_service_v2_proto_msgTypes[0] mi := &file_services_metrics_service_v2_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -86,13 +52,13 @@ func (x *Metric) Reset() {
} }
} }
func (x *Metric) String() string { func (x *MetricsServiceV2SendRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*Metric) ProtoMessage() {} func (*MetricsServiceV2SendRequest) ProtoMessage() {}
func (x *Metric) ProtoReflect() protoreflect.Message { func (x *MetricsServiceV2SendRequest) ProtoReflect() protoreflect.Message {
mi := &file_services_metrics_service_v2_proto_msgTypes[0] mi := &file_services_metrics_service_v2_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -104,160 +70,121 @@ func (x *Metric) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use Metric.ProtoReflect.Descriptor instead. // Deprecated: Use MetricsServiceV2SendRequest.ProtoReflect.Descriptor instead.
func (*Metric) Descriptor() ([]byte, []int) { func (*MetricsServiceV2SendRequest) Descriptor() ([]byte, []int) {
return file_services_metrics_service_v2_proto_rawDescGZIP(), []int{0} return file_services_metrics_service_v2_proto_rawDescGZIP(), []int{0}
} }
func (x *Metric) GetNamespace() string { func (x *MetricsServiceV2SendRequest) GetType() string {
if x != nil { if x != nil {
return x.Namespace return x.Type
} }
return "" return ""
} }
func (x *Metric) GetSubsystem() string { func (x *MetricsServiceV2SendRequest) GetNodeKey() string {
if x != nil {
return x.Subsystem
}
return ""
}
func (x *Metric) GetModule() string {
if x != nil {
return x.Module
}
return ""
}
func (x *Metric) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Metric) GetValue() float32 {
if x != nil {
return x.Value
}
return 0
}
func (x *Metric) GetHelp() string {
if x != nil {
return x.Help
}
return ""
}
func (x *Metric) GetLabels() []byte {
if x != nil {
return x.Labels
}
return nil
}
type MetricsServiceV2ConnectRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
NodeKey string `protobuf:"bytes,1,opt,name=node_key,json=nodeKey,proto3" json:"node_key,omitempty"`
Metrics []*Metric `protobuf:"bytes,2,rep,name=metrics,proto3" json:"metrics,omitempty"`
}
func (x *MetricsServiceV2ConnectRequest) Reset() {
*x = MetricsServiceV2ConnectRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_services_metrics_service_v2_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MetricsServiceV2ConnectRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MetricsServiceV2ConnectRequest) ProtoMessage() {}
func (x *MetricsServiceV2ConnectRequest) ProtoReflect() protoreflect.Message {
mi := &file_services_metrics_service_v2_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use MetricsServiceV2ConnectRequest.ProtoReflect.Descriptor instead.
func (*MetricsServiceV2ConnectRequest) Descriptor() ([]byte, []int) {
return file_services_metrics_service_v2_proto_rawDescGZIP(), []int{1}
}
func (x *MetricsServiceV2ConnectRequest) GetNodeKey() string {
if x != nil { if x != nil {
return x.NodeKey return x.NodeKey
} }
return "" return ""
} }
func (x *MetricsServiceV2ConnectRequest) GetMetrics() []*Metric { func (x *MetricsServiceV2SendRequest) GetTimestamp() int64 {
if x != nil { if x != nil {
return x.Metrics return x.Timestamp
} }
return nil return 0
} }
type MetricsServiceV2ConnectResponse struct { func (x *MetricsServiceV2SendRequest) GetCpuUsagePercent() float32 {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code MetricsServiceV2Code `protobuf:"varint,1,opt,name=code,proto3,enum=grpc.MetricsServiceV2Code" json:"code,omitempty"`
}
func (x *MetricsServiceV2ConnectResponse) Reset() {
*x = MetricsServiceV2ConnectResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_services_metrics_service_v2_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MetricsServiceV2ConnectResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MetricsServiceV2ConnectResponse) ProtoMessage() {}
func (x *MetricsServiceV2ConnectResponse) ProtoReflect() protoreflect.Message {
mi := &file_services_metrics_service_v2_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use MetricsServiceV2ConnectResponse.ProtoReflect.Descriptor instead.
func (*MetricsServiceV2ConnectResponse) Descriptor() ([]byte, []int) {
return file_services_metrics_service_v2_proto_rawDescGZIP(), []int{2}
}
func (x *MetricsServiceV2ConnectResponse) GetCode() MetricsServiceV2Code {
if x != nil { if x != nil {
return x.Code return x.CpuUsagePercent
} }
return MetricsServiceV2Code_SYNC_METRICS return 0
}
func (x *MetricsServiceV2SendRequest) GetTotalMemory() uint64 {
if x != nil {
return x.TotalMemory
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetAvailableMemory() uint64 {
if x != nil {
return x.AvailableMemory
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetUsedMemory() uint64 {
if x != nil {
return x.UsedMemory
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetUsedMemoryPercent() float32 {
if x != nil {
return x.UsedMemoryPercent
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetTotalDisk() uint64 {
if x != nil {
return x.TotalDisk
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetAvailableDisk() uint64 {
if x != nil {
return x.AvailableDisk
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetUsedDisk() uint64 {
if x != nil {
return x.UsedDisk
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetUsedDiskPercent() float32 {
if x != nil {
return x.UsedDiskPercent
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetDiskReadBytesRate() float32 {
if x != nil {
return x.DiskReadBytesRate
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetDiskWriteBytesRate() float32 {
if x != nil {
return x.DiskWriteBytesRate
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetNetworkBytesSentRate() float32 {
if x != nil {
return x.NetworkBytesSentRate
}
return 0
}
func (x *MetricsServiceV2SendRequest) GetNetworkBytesRecvRate() float32 {
if x != nil {
return x.NetworkBytesRecvRate
}
return 0
} }
var File_services_metrics_service_v2_proto protoreflect.FileDescriptor var File_services_metrics_service_v2_proto protoreflect.FileDescriptor
@@ -265,41 +192,56 @@ var File_services_metrics_service_v2_proto protoreflect.FileDescriptor
var file_services_metrics_service_v2_proto_rawDesc = []byte{ var file_services_metrics_service_v2_proto_rawDesc = []byte{
0x0a, 0x21, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x0a, 0x21, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69,
0x63, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, 0x32, 0x2e, 0x70, 0x72, 0x63, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, 0x32, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x04, 0x67, 0x72, 0x70, 0x63, 0x22, 0xb2, 0x01, 0x0a, 0x06, 0x4d, 0x65, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x67, 0x72, 0x70, 0x63, 0x1a, 0x15, 0x65, 0x6e, 0x74, 0x69, 0x74,
0x74, 0x72, 0x69, 0x63, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x79, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x22, 0x96, 0x05, 0x0a, 0x1b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76,
0x63, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x18, 0x69, 0x63, 0x65, 0x56, 0x32, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x12, 0x16, 0x0a, 0x06, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x74, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6b, 0x65, 0x79,
0x52, 0x06, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x4b, 0x65, 0x79, 0x12,
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2a, 0x0a,
0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x65, 0x6c, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x11, 0x63, 0x70, 0x75, 0x5f, 0x75, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x63, 0x65,
0x52, 0x04, 0x68, 0x65, 0x6c, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0f, 0x63, 0x70, 0x75, 0x55, 0x73, 0x61,
0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x22, 0x63, 0x67, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x6f, 0x74,
0x0a, 0x1e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x61, 0x6c, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52,
0x56, 0x32, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x29, 0x0a, 0x10,
0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79,
0x28, 0x09, 0x52, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x07, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c,
0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x67, 0x65, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x73, 0x65, 0x64, 0x5f,
0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x75, 0x73,
0x69, 0x63, 0x73, 0x22, 0x51, 0x0a, 0x1f, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x2e, 0x0a, 0x13, 0x75, 0x73, 0x65, 0x64,
0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x32, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x18,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x08, 0x20, 0x01, 0x28, 0x02, 0x52, 0x11, 0x75, 0x73, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x6f, 0x72,
0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x79, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61,
0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x32, 0x43, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x64, 0x69, 0x73, 0x6b, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x6f,
0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0x28, 0x0a, 0x14, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x74, 0x61, 0x6c, 0x44, 0x69, 0x73, 0x6b, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x76, 0x61, 0x69, 0x6c,
0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x32, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x69, 0x73, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52,
0x0a, 0x0c, 0x53, 0x59, 0x4e, 0x43, 0x5f, 0x4d, 0x45, 0x54, 0x52, 0x49, 0x43, 0x53, 0x10, 0x00, 0x0d, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x44, 0x69, 0x73, 0x6b, 0x12, 0x1b,
0x32, 0x70, 0x0a, 0x10, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x64, 0x5f, 0x64, 0x69, 0x73, 0x6b, 0x18, 0x0b, 0x20, 0x01, 0x28,
0x63, 0x65, 0x56, 0x32, 0x12, 0x5c, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x04, 0x52, 0x08, 0x75, 0x73, 0x65, 0x64, 0x44, 0x69, 0x73, 0x6b, 0x12, 0x2a, 0x0a, 0x11, 0x75,
0x24, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x73, 0x65, 0x64, 0x5f, 0x64, 0x69, 0x73, 0x6b, 0x5f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74,
0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x32, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0f, 0x75, 0x73, 0x65, 0x64, 0x44, 0x69, 0x73, 0x6b,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x74, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x0a, 0x14, 0x64, 0x69, 0x73, 0x6b, 0x5f,
0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x32, 0x43, 0x6f, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x72, 0x61, 0x74, 0x65, 0x18,
0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x0f, 0x20, 0x01, 0x28, 0x02, 0x52, 0x11, 0x64, 0x69, 0x73, 0x6b, 0x52, 0x65, 0x61, 0x64, 0x42,
0x30, 0x01, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x3b, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x79, 0x74, 0x65, 0x73, 0x52, 0x61, 0x74, 0x65, 0x12, 0x31, 0x0a, 0x15, 0x64, 0x69, 0x73, 0x6b,
0x6f, 0x74, 0x6f, 0x33, 0x5f, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x72, 0x61, 0x74,
0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x02, 0x52, 0x12, 0x64, 0x69, 0x73, 0x6b, 0x57, 0x72, 0x69,
0x74, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x52, 0x61, 0x74, 0x65, 0x12, 0x35, 0x0a, 0x17, 0x6e,
0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x73, 0x65, 0x6e,
0x74, 0x5f, 0x72, 0x61, 0x74, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x02, 0x52, 0x14, 0x6e, 0x65,
0x74, 0x77, 0x6f, 0x72, 0x6b, 0x42, 0x79, 0x74, 0x65, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x52, 0x61,
0x74, 0x65, 0x12, 0x35, 0x0a, 0x17, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x62, 0x79,
0x74, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x63, 0x76, 0x5f, 0x72, 0x61, 0x74, 0x65, 0x18, 0x12, 0x20,
0x01, 0x28, 0x02, 0x52, 0x14, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x42, 0x79, 0x74, 0x65,
0x73, 0x52, 0x65, 0x63, 0x76, 0x52, 0x61, 0x74, 0x65, 0x32, 0x4f, 0x0a, 0x10, 0x4d, 0x65, 0x74,
0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x32, 0x12, 0x3b, 0x0a,
0x04, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x21, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x74,
0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x32, 0x53, 0x65, 0x6e,
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x3b,
0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -314,24 +256,19 @@ func file_services_metrics_service_v2_proto_rawDescGZIP() []byte {
return file_services_metrics_service_v2_proto_rawDescData return file_services_metrics_service_v2_proto_rawDescData
} }
var file_services_metrics_service_v2_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_services_metrics_service_v2_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_services_metrics_service_v2_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_services_metrics_service_v2_proto_goTypes = []any{ var file_services_metrics_service_v2_proto_goTypes = []any{
(MetricsServiceV2Code)(0), // 0: grpc.MetricsServiceV2Code (*MetricsServiceV2SendRequest)(nil), // 0: grpc.MetricsServiceV2SendRequest
(*Metric)(nil), // 1: grpc.Metric (*Response)(nil), // 1: grpc.Response
(*MetricsServiceV2ConnectRequest)(nil), // 2: grpc.MetricsServiceV2ConnectRequest
(*MetricsServiceV2ConnectResponse)(nil), // 3: grpc.MetricsServiceV2ConnectResponse
} }
var file_services_metrics_service_v2_proto_depIdxs = []int32{ var file_services_metrics_service_v2_proto_depIdxs = []int32{
1, // 0: grpc.MetricsServiceV2ConnectRequest.metrics:type_name -> grpc.Metric 0, // 0: grpc.MetricsServiceV2.Send:input_type -> grpc.MetricsServiceV2SendRequest
0, // 1: grpc.MetricsServiceV2ConnectResponse.code:type_name -> grpc.MetricsServiceV2Code 1, // 1: grpc.MetricsServiceV2.Send:output_type -> grpc.Response
2, // 2: grpc.MetricsServiceV2.Connect:input_type -> grpc.MetricsServiceV2ConnectRequest 1, // [1:2] is the sub-list for method output_type
3, // 3: grpc.MetricsServiceV2.Connect:output_type -> grpc.MetricsServiceV2ConnectResponse 0, // [0:1] is the sub-list for method input_type
3, // [3:4] is the sub-list for method output_type 0, // [0:0] is the sub-list for extension type_name
2, // [2:3] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension extendee
2, // [2:2] is the sub-list for extension type_name 0, // [0:0] is the sub-list for field type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
} }
func init() { file_services_metrics_service_v2_proto_init() } func init() { file_services_metrics_service_v2_proto_init() }
@@ -339,33 +276,10 @@ func file_services_metrics_service_v2_proto_init() {
if File_services_metrics_service_v2_proto != nil { if File_services_metrics_service_v2_proto != nil {
return return
} }
file_entity_response_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_services_metrics_service_v2_proto_msgTypes[0].Exporter = func(v any, i int) any { file_services_metrics_service_v2_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*Metric); i { switch v := v.(*MetricsServiceV2SendRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_metrics_service_v2_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*MetricsServiceV2ConnectRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_metrics_service_v2_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*MetricsServiceV2ConnectResponse); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -382,14 +296,13 @@ func file_services_metrics_service_v2_proto_init() {
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_services_metrics_service_v2_proto_rawDesc, RawDescriptor: file_services_metrics_service_v2_proto_rawDesc,
NumEnums: 1, NumEnums: 0,
NumMessages: 3, NumMessages: 1,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },
GoTypes: file_services_metrics_service_v2_proto_goTypes, GoTypes: file_services_metrics_service_v2_proto_goTypes,
DependencyIndexes: file_services_metrics_service_v2_proto_depIdxs, DependencyIndexes: file_services_metrics_service_v2_proto_depIdxs,
EnumInfos: file_services_metrics_service_v2_proto_enumTypes,
MessageInfos: file_services_metrics_service_v2_proto_msgTypes, MessageInfos: file_services_metrics_service_v2_proto_msgTypes,
}.Build() }.Build()
File_services_metrics_service_v2_proto = out.File File_services_metrics_service_v2_proto = out.File

View File

@@ -19,14 +19,14 @@ import (
const _ = grpc.SupportPackageIsVersion8 const _ = grpc.SupportPackageIsVersion8
const ( const (
MetricsServiceV2_Connect_FullMethodName = "/grpc.MetricsServiceV2/Connect" MetricsServiceV2_Send_FullMethodName = "/grpc.MetricsServiceV2/Send"
) )
// MetricsServiceV2Client is the client API for MetricsServiceV2 service. // MetricsServiceV2Client is the client API for MetricsServiceV2 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. // 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 MetricsServiceV2Client interface { type MetricsServiceV2Client interface {
Connect(ctx context.Context, opts ...grpc.CallOption) (MetricsServiceV2_ConnectClient, error) Send(ctx context.Context, in *MetricsServiceV2SendRequest, opts ...grpc.CallOption) (*Response, error)
} }
type metricsServiceV2Client struct { type metricsServiceV2Client struct {
@@ -37,43 +37,21 @@ func NewMetricsServiceV2Client(cc grpc.ClientConnInterface) MetricsServiceV2Clie
return &metricsServiceV2Client{cc} return &metricsServiceV2Client{cc}
} }
func (c *metricsServiceV2Client) Connect(ctx context.Context, opts ...grpc.CallOption) (MetricsServiceV2_ConnectClient, error) { func (c *metricsServiceV2Client) Send(ctx context.Context, in *MetricsServiceV2SendRequest, opts ...grpc.CallOption) (*Response, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &MetricsServiceV2_ServiceDesc.Streams[0], MetricsServiceV2_Connect_FullMethodName, cOpts...) out := new(Response)
err := c.cc.Invoke(ctx, MetricsServiceV2_Send_FullMethodName, in, out, cOpts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
x := &metricsServiceV2ConnectClient{ClientStream: stream} return out, nil
return x, nil
}
type MetricsServiceV2_ConnectClient interface {
Send(*MetricsServiceV2ConnectRequest) error
Recv() (*MetricsServiceV2ConnectResponse, error)
grpc.ClientStream
}
type metricsServiceV2ConnectClient struct {
grpc.ClientStream
}
func (x *metricsServiceV2ConnectClient) Send(m *MetricsServiceV2ConnectRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *metricsServiceV2ConnectClient) Recv() (*MetricsServiceV2ConnectResponse, error) {
m := new(MetricsServiceV2ConnectResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
} }
// MetricsServiceV2Server is the server API for MetricsServiceV2 service. // MetricsServiceV2Server is the server API for MetricsServiceV2 service.
// All implementations must embed UnimplementedMetricsServiceV2Server // All implementations must embed UnimplementedMetricsServiceV2Server
// for forward compatibility // for forward compatibility
type MetricsServiceV2Server interface { type MetricsServiceV2Server interface {
Connect(MetricsServiceV2_ConnectServer) error Send(context.Context, *MetricsServiceV2SendRequest) (*Response, error)
mustEmbedUnimplementedMetricsServiceV2Server() mustEmbedUnimplementedMetricsServiceV2Server()
} }
@@ -81,8 +59,8 @@ type MetricsServiceV2Server interface {
type UnimplementedMetricsServiceV2Server struct { type UnimplementedMetricsServiceV2Server struct {
} }
func (UnimplementedMetricsServiceV2Server) Connect(MetricsServiceV2_ConnectServer) error { func (UnimplementedMetricsServiceV2Server) Send(context.Context, *MetricsServiceV2SendRequest) (*Response, error) {
return status.Errorf(codes.Unimplemented, "method Connect not implemented") return nil, status.Errorf(codes.Unimplemented, "method Send not implemented")
} }
func (UnimplementedMetricsServiceV2Server) mustEmbedUnimplementedMetricsServiceV2Server() {} func (UnimplementedMetricsServiceV2Server) mustEmbedUnimplementedMetricsServiceV2Server() {}
@@ -97,30 +75,22 @@ func RegisterMetricsServiceV2Server(s grpc.ServiceRegistrar, srv MetricsServiceV
s.RegisterService(&MetricsServiceV2_ServiceDesc, srv) s.RegisterService(&MetricsServiceV2_ServiceDesc, srv)
} }
func _MetricsServiceV2_Connect_Handler(srv interface{}, stream grpc.ServerStream) error { func _MetricsServiceV2_Send_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
return srv.(MetricsServiceV2Server).Connect(&metricsServiceV2ConnectServer{ServerStream: stream}) in := new(MetricsServiceV2SendRequest)
} if err := dec(in); err != nil {
type MetricsServiceV2_ConnectServer interface {
Send(*MetricsServiceV2ConnectResponse) error
Recv() (*MetricsServiceV2ConnectRequest, error)
grpc.ServerStream
}
type metricsServiceV2ConnectServer struct {
grpc.ServerStream
}
func (x *metricsServiceV2ConnectServer) Send(m *MetricsServiceV2ConnectResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *metricsServiceV2ConnectServer) Recv() (*MetricsServiceV2ConnectRequest, error) {
m := new(MetricsServiceV2ConnectRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err return nil, err
} }
return m, nil if interceptor == nil {
return srv.(MetricsServiceV2Server).Send(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: MetricsServiceV2_Send_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MetricsServiceV2Server).Send(ctx, req.(*MetricsServiceV2SendRequest))
}
return interceptor(ctx, in, info, handler)
} }
// MetricsServiceV2_ServiceDesc is the grpc.ServiceDesc for MetricsServiceV2 service. // MetricsServiceV2_ServiceDesc is the grpc.ServiceDesc for MetricsServiceV2 service.
@@ -129,14 +99,12 @@ func (x *metricsServiceV2ConnectServer) Recv() (*MetricsServiceV2ConnectRequest,
var MetricsServiceV2_ServiceDesc = grpc.ServiceDesc{ var MetricsServiceV2_ServiceDesc = grpc.ServiceDesc{
ServiceName: "grpc.MetricsServiceV2", ServiceName: "grpc.MetricsServiceV2",
HandlerType: (*MetricsServiceV2Server)(nil), HandlerType: (*MetricsServiceV2Server)(nil),
Methods: []grpc.MethodDesc{}, Methods: []grpc.MethodDesc{
Streams: []grpc.StreamDesc{
{ {
StreamName: "Connect", MethodName: "Send",
Handler: _MetricsServiceV2_Connect_Handler, Handler: _MetricsServiceV2_Send_Handler,
ServerStreams: true,
ClientStreams: true,
}, },
}, },
Streams: []grpc.StreamDesc{},
Metadata: "services/metrics_service_v2.proto", Metadata: "services/metrics_service_v2.proto",
} }

View File

@@ -1,31 +1,29 @@
syntax = "proto3"; syntax = "proto3";
import "entity/response.proto";
package grpc; package grpc;
option go_package = ".;grpc"; option go_package = ".;grpc";
message Metric { message MetricsServiceV2SendRequest {
string namespace = 1; string type = 1;
string subsystem = 2; string node_key = 2;
string module = 3; int64 timestamp = 3;
string name = 4; float cpu_usage_percent = 4;
float value = 5; uint64 total_memory = 5;
string help = 6; uint64 available_memory = 6;
bytes labels = 7; uint64 used_memory = 7;
} float used_memory_percent = 8;
uint64 total_disk = 9;
message MetricsServiceV2ConnectRequest { uint64 available_disk = 10;
string node_key = 1; uint64 used_disk = 11;
repeated Metric metrics = 2; float used_disk_percent = 12;
} float disk_read_bytes_rate = 15;
float disk_write_bytes_rate = 16;
enum MetricsServiceV2Code { float network_bytes_sent_rate = 17;
SYNC_METRICS = 0; float network_bytes_recv_rate = 18;
}
message MetricsServiceV2ConnectResponse {
MetricsServiceV2Code code = 1;
} }
service MetricsServiceV2 { service MetricsServiceV2 {
rpc Connect(stream MetricsServiceV2ConnectRequest) returns (stream MetricsServiceV2ConnectResponse){}; rpc Send(MetricsServiceV2SendRequest) returns (Response){};
} }