diff --git a/go.mod b/go.mod index ad8d5b52..b5baf685 100644 --- a/go.mod +++ b/go.mod @@ -19,13 +19,12 @@ require ( github.com/modern-go/reflect2 v1.0.2 github.com/natefinch/lumberjack v2.0.0+incompatible github.com/pkg/errors v0.9.1 - github.com/polarismesh/specification v1.4.0-alpha.5 + github.com/polarismesh/specification v1.4.0 github.com/prometheus/client_golang v1.12.2 github.com/smartystreets/goconvey v1.7.2 github.com/spaolacci/murmur3 v1.1.0 github.com/stretchr/testify v1.8.2 go.uber.org/zap v1.21.0 - golang.org/x/net v0.2.0 google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a // indirect google.golang.org/grpc v1.51.0 google.golang.org/protobuf v1.28.1 diff --git a/go.sum b/go.sum index 3f616f42..3b2c7200 100644 --- a/go.sum +++ b/go.sum @@ -380,8 +380,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polarismesh/specification v1.4.0-alpha.5 h1:1bUiGB2DdL6wlli+TfJ2EoDLcR58fAUzm9FxKLtVBE0= -github.com/polarismesh/specification v1.4.0-alpha.5/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.0 h1:fm7sUtFZC2g9+lLmRCtjGrUow47CY5JDFoZXwwCQGGY= +github.com/polarismesh/specification v1.4.0/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/pkg/flow/quota/remote.go b/pkg/flow/quota/remote.go index 78d71e0c..e9fe491a 100644 --- a/pkg/flow/quota/remote.go +++ b/pkg/flow/quota/remote.go @@ -20,7 +20,6 @@ package quota import ( "context" "fmt" - "github.com/polarismesh/specification/source/go/api/v1/traffic_manage/ratelimiter" "io" "net" "strings" @@ -30,6 +29,7 @@ import ( "github.com/golang/protobuf/jsonpb" "github.com/modern-go/reflect2" + "github.com/polarismesh/specification/source/go/api/v1/traffic_manage/ratelimiter" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/metadata" @@ -37,7 +37,7 @@ import ( "github.com/polarismesh/polaris-go/pkg/config" "github.com/polarismesh/polaris-go/pkg/log" "github.com/polarismesh/polaris-go/pkg/model" - rlimitV2 "github.com/polarismesh/polaris-go/pkg/model/pb/metric/v2" + limitpb "github.com/polarismesh/polaris-go/pkg/model/pb/metric/v2" ) // ResponseCallBack 应答回调函数 @@ -55,7 +55,7 @@ type RateLimitMsgSender interface { // SendInitRequest 发送初始化请求 SendInitRequest(request *ratelimiter.RateLimitInitRequest, callback ResponseCallBack) // SendReportRequest 发送上报请求 - SendReportRequest(request *rlimitV2.ClientRateLimitReportRequest) error + SendReportRequest(request *limitpb.ClientRateLimitReportRequest) error // AdjustTime 同步时间 AdjustTime() int64 } @@ -510,7 +510,7 @@ func (s *StreamCounterSet) processResponse(serviceStream ratelimiter.RateLimitGR } // SendReportRequest 发送上报请求 -func (s *StreamCounterSet) SendReportRequest(clientReportReq *rlimitV2.ClientRateLimitReportRequest) error { +func (s *StreamCounterSet) SendReportRequest(clientReportReq *limitpb.ClientRateLimitReportRequest) error { s.mutex.RLock() defer s.mutex.RUnlock() if reflect2.IsNil(s.serviceStream) { diff --git a/pkg/flow/quota/window.go b/pkg/flow/quota/window.go index fa1815ff..3a63c26d 100644 --- a/pkg/flow/quota/window.go +++ b/pkg/flow/quota/window.go @@ -33,7 +33,7 @@ import ( "github.com/polarismesh/polaris-go/pkg/log" "github.com/polarismesh/polaris-go/pkg/model" "github.com/polarismesh/polaris-go/pkg/model/pb" - rlimitV2 "github.com/polarismesh/polaris-go/pkg/model/pb/metric/v2" + limitpb "github.com/polarismesh/polaris-go/pkg/model/pb/metric/v2" "github.com/polarismesh/polaris-go/pkg/plugin" "github.com/polarismesh/polaris-go/pkg/plugin/common" "github.com/polarismesh/polaris-go/pkg/plugin/ratelimiter" @@ -563,8 +563,8 @@ func (r *RateLimitWindow) EnsureDeleted(value interface{}) bool { } // acquireRequest 转换成限流PB上报消息 -func (r *RateLimitWindow) acquireRequest() *rlimitV2.ClientRateLimitReportRequest { - reportReq := &rlimitV2.ClientRateLimitReportRequest{ +func (r *RateLimitWindow) acquireRequest() *limitpb.ClientRateLimitReportRequest { + reportReq := &limitpb.ClientRateLimitReportRequest{ Service: r.SvcKey.Service, Namespace: r.SvcKey.Namespace, Labels: r.Labels, diff --git a/pkg/model/pb/metric/polaris_metric.pb.go b/pkg/model/pb/metric/polaris_metric.pb.go deleted file mode 100644 index 153753c8..00000000 --- a/pkg/model/pb/metric/polaris_metric.pb.go +++ /dev/null @@ -1,595 +0,0 @@ -// Code generated by protoc-gen-go. -// source: polaris_metric.proto -// DO NOT EDIT! - -/* -Package metric is a generated protocol buffer package. - -It is generated from these files: - - polaris_metric.proto - polaris_metric_api.proto - polaris_ratelimit.proto - -It has these top-level messages: - - MetricDimension - MetricKey - MetricInitRequest - MetricQueryRequest - MetricRequest - MetricResponse - RateLimitRequest - RateLimitResponse - Limiter -*/ -package metric - -import ( - "fmt" - "math" - - "github.com/golang/protobuf/proto" - google_protobuf "github.com/golang/protobuf/ptypes/wrappers" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// 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.ProtoPackageIsVersion2 // please upgrade the proto package - -// 统计类型 -type MetricType int32 - -const ( - // 请求数 - MetricType_ReqCount MetricType = 0 - // 被限流数 - MetricType_LimitCount MetricType = 1 - // 按时延来进行上报 - MetricType_ReqCountByDelay MetricType = 2 - // 通用错误数 - MetricType_ErrorCount MetricType = 3 - // 通过错误类型来统计上报 - MetricType_ErrorCountByType MetricType = 4 -) - -var MetricType_name = map[int32]string{ - 0: "ReqCount", - 1: "LimitCount", - 2: "ReqCountByDelay", - 3: "ErrorCount", - 4: "ErrorCountByType", -} -var MetricType_value = map[string]int32{ - "ReqCount": 0, - "LimitCount": 1, - "ReqCountByDelay": 2, - "ErrorCount": 3, - "ErrorCountByType": 4, -} - -func (x MetricType) String() string { - return proto.EnumName(MetricType_name, int32(x)) -} -func (MetricType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -// 当前上报的角色类型,主调或者被调 -type MetricKey_Role int32 - -const ( - // 主调 - MetricKey_Caller MetricKey_Role = 0 - // 被调 - MetricKey_Callee MetricKey_Role = 1 -) - -var MetricKey_Role_name = map[int32]string{ - 0: "Caller", - 1: "Callee", -} -var MetricKey_Role_value = map[string]int32{ - "Caller": 0, - "Callee": 1, -} - -func (x MetricKey_Role) String() string { - return proto.EnumName(MetricKey_Role_name, int32(x)) -} -func (MetricKey_Role) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{1, 0} } - -// 统计维度 -// 这里直接使用基础类型可以避免转换过程 -type MetricDimension struct { - // 维度类型 - Type MetricType `protobuf:"varint,1,opt,name=type,enum=metric.MetricType" json:"type,omitempty"` - // 维度的具体值,比如具体错误类型 - Value string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` -} - -func (m *MetricDimension) Reset() { *m = MetricDimension{} } -func (m *MetricDimension) String() string { return proto.CompactTextString(m) } -func (*MetricDimension) ProtoMessage() {} -func (*MetricDimension) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *MetricDimension) GetType() MetricType { - if m != nil { - return m.Type - } - return MetricType_ReqCount -} - -func (m *MetricDimension) GetValue() string { - if m != nil { - return m.Value - } - return "" -} - -// 统计标识,用于唯一关联一种类型的统计滑窗 -// 这里直接使用基础类型可以避免转换过程 -type MetricKey struct { - // 服务名 - Service string `protobuf:"bytes,1,opt,name=service" json:"service,omitempty"` - // 命名空间 - Namespace string `protobuf:"bytes,2,opt,name=namespace" json:"namespace,omitempty"` - // 服务子集群,格式为key1:value1|key2:value2 - // 如果要查询服务下面所有的subSet信息,subset字段可以填* - Subset string `protobuf:"bytes,3,opt,name=subset" json:"subset,omitempty"` - // 业务标签信息,格式为key1:value1|key2:value2 - // 如果要查询服务下面所有的labels信息,labels字段可以填* - Labels string `protobuf:"bytes,4,opt,name=labels" json:"labels,omitempty"` - Role MetricKey_Role `protobuf:"varint,5,opt,name=role,enum=metric.MetricKey_Role" json:"role,omitempty"` -} - -func (m *MetricKey) Reset() { *m = MetricKey{} } -func (m *MetricKey) String() string { return proto.CompactTextString(m) } -func (*MetricKey) ProtoMessage() {} -func (*MetricKey) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -func (m *MetricKey) GetService() string { - if m != nil { - return m.Service - } - return "" -} - -func (m *MetricKey) GetNamespace() string { - if m != nil { - return m.Namespace - } - return "" -} - -func (m *MetricKey) GetSubset() string { - if m != nil { - return m.Subset - } - return "" -} - -func (m *MetricKey) GetLabels() string { - if m != nil { - return m.Labels - } - return "" -} - -func (m *MetricKey) GetRole() MetricKey_Role { - if m != nil { - return m.Role - } - return MetricKey_Caller -} - -// 统计初始化请求 -type MetricInitRequest struct { - // 消息ID,用于和应答相对应 - MsgId *google_protobuf.Int64Value `protobuf:"bytes,1,opt,name=msgId" json:"msgId,omitempty"` - // 标识 - Key *MetricKey `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` - // 统计类型 - Dimensions []*MetricDimension `protobuf:"bytes,3,rep,name=dimensions" json:"dimensions,omitempty"` - Windows []*MetricInitRequest_MetricWindow `protobuf:"bytes,4,rep,name=windows" json:"windows,omitempty"` -} - -func (m *MetricInitRequest) Reset() { *m = MetricInitRequest{} } -func (m *MetricInitRequest) String() string { return proto.CompactTextString(m) } -func (*MetricInitRequest) ProtoMessage() {} -func (*MetricInitRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } - -func (m *MetricInitRequest) GetMsgId() *google_protobuf.Int64Value { - if m != nil { - return m.MsgId - } - return nil -} - -func (m *MetricInitRequest) GetKey() *MetricKey { - if m != nil { - return m.Key - } - return nil -} - -func (m *MetricInitRequest) GetDimensions() []*MetricDimension { - if m != nil { - return m.Dimensions - } - return nil -} - -func (m *MetricInitRequest) GetWindows() []*MetricInitRequest_MetricWindow { - if m != nil { - return m.Windows - } - return nil -} - -// 统计滑窗 -type MetricInitRequest_MetricWindow struct { - // 滑窗统计周期,单位ms - Duration int64 `protobuf:"varint,1,opt,name=duration" json:"duration,omitempty"` - // 滑窗统计精度 - Precision uint32 `protobuf:"varint,2,opt,name=precision" json:"precision,omitempty"` -} - -func (m *MetricInitRequest_MetricWindow) Reset() { *m = MetricInitRequest_MetricWindow{} } -func (m *MetricInitRequest_MetricWindow) String() string { return proto.CompactTextString(m) } -func (*MetricInitRequest_MetricWindow) ProtoMessage() {} -func (*MetricInitRequest_MetricWindow) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{2, 0} -} - -func (m *MetricInitRequest_MetricWindow) GetDuration() int64 { - if m != nil { - return m.Duration - } - return 0 -} - -func (m *MetricInitRequest_MetricWindow) GetPrecision() uint32 { - if m != nil { - return m.Precision - } - return 0 -} - -// 统计查询请求 -type MetricQueryRequest struct { - // 消息ID,用于和应答相对应 - MsgId *google_protobuf.Int64Value `protobuf:"bytes,1,opt,name=msgId" json:"msgId,omitempty"` - // 标识 - Key *MetricKey `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` - // 统计类型 - Dimensions []*MetricDimension `protobuf:"bytes,3,rep,name=dimensions" json:"dimensions,omitempty"` - // 查询周期,单位ms - // 该查询周期必须不大于初始化时候给的window信息,按最近的一个精度滑窗向上取整 - Duration int64 `protobuf:"varint,4,opt,name=duration" json:"duration,omitempty"` -} - -func (m *MetricQueryRequest) Reset() { *m = MetricQueryRequest{} } -func (m *MetricQueryRequest) String() string { return proto.CompactTextString(m) } -func (*MetricQueryRequest) ProtoMessage() {} -func (*MetricQueryRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } - -func (m *MetricQueryRequest) GetMsgId() *google_protobuf.Int64Value { - if m != nil { - return m.MsgId - } - return nil -} - -func (m *MetricQueryRequest) GetKey() *MetricKey { - if m != nil { - return m.Key - } - return nil -} - -func (m *MetricQueryRequest) GetDimensions() []*MetricDimension { - if m != nil { - return m.Dimensions - } - return nil -} - -func (m *MetricQueryRequest) GetDuration() int64 { - if m != nil { - return m.Duration - } - return 0 -} - -// 周期统计上报请求 -type MetricRequest struct { - // 消息ID,用于和应答相对应 - MsgId *google_protobuf.Int64Value `protobuf:"bytes,1,opt,name=msgId" json:"msgId,omitempty"` - // 标识 - Key *MetricKey `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` - Increments []*MetricRequest_MetricIncrement `protobuf:"bytes,3,rep,name=increments" json:"increments,omitempty"` - // 上报数据最后发生的时间(统计server绝对时间),单位unixnano - Timestamp *google_protobuf.Int64Value `protobuf:"bytes,4,opt,name=timestamp" json:"timestamp,omitempty"` -} - -func (m *MetricRequest) Reset() { *m = MetricRequest{} } -func (m *MetricRequest) String() string { return proto.CompactTextString(m) } -func (*MetricRequest) ProtoMessage() {} -func (*MetricRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } - -func (m *MetricRequest) GetMsgId() *google_protobuf.Int64Value { - if m != nil { - return m.MsgId - } - return nil -} - -func (m *MetricRequest) GetKey() *MetricKey { - if m != nil { - return m.Key - } - return nil -} - -func (m *MetricRequest) GetIncrements() []*MetricRequest_MetricIncrement { - if m != nil { - return m.Increments - } - return nil -} - -func (m *MetricRequest) GetTimestamp() *google_protobuf.Int64Value { - if m != nil { - return m.Timestamp - } - return nil -} - -// 上报的数据 -// 可一次同时上报多种类型的统计数据 -type MetricRequest_MetricIncrement struct { - // 滑窗统计周期,单位ms - Duration int64 `protobuf:"varint,1,opt,name=duration" json:"duration,omitempty"` - Values []*MetricRequest_MetricIncrement_Values `protobuf:"bytes,2,rep,name=values" json:"values,omitempty"` - // 滑窗统计精度 - Precision uint32 `protobuf:"varint,3,opt,name=precision" json:"precision,omitempty"` -} - -func (m *MetricRequest_MetricIncrement) Reset() { *m = MetricRequest_MetricIncrement{} } -func (m *MetricRequest_MetricIncrement) String() string { return proto.CompactTextString(m) } -func (*MetricRequest_MetricIncrement) ProtoMessage() {} -func (*MetricRequest_MetricIncrement) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{4, 0} -} - -func (m *MetricRequest_MetricIncrement) GetDuration() int64 { - if m != nil { - return m.Duration - } - return 0 -} - -func (m *MetricRequest_MetricIncrement) GetValues() []*MetricRequest_MetricIncrement_Values { - if m != nil { - return m.Values - } - return nil -} - -func (m *MetricRequest_MetricIncrement) GetPrecision() uint32 { - if m != nil { - return m.Precision - } - return 0 -} - -// 单次上报的统计数据 -type MetricRequest_MetricIncrement_Values struct { - // 统计类型 - Dimension *MetricDimension `protobuf:"bytes,1,opt,name=dimension" json:"dimension,omitempty"` - // 上报的统计值,按步长为最小单位,包含2次上报之间的增量数据 - // 下标越小,则数据是越近 - Values []int64 `protobuf:"varint,2,rep,packed,name=values" json:"values,omitempty"` -} - -func (m *MetricRequest_MetricIncrement_Values) Reset() { *m = MetricRequest_MetricIncrement_Values{} } -func (m *MetricRequest_MetricIncrement_Values) String() string { return proto.CompactTextString(m) } -func (*MetricRequest_MetricIncrement_Values) ProtoMessage() {} -func (*MetricRequest_MetricIncrement_Values) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{4, 0, 0} -} - -func (m *MetricRequest_MetricIncrement_Values) GetDimension() *MetricDimension { - if m != nil { - return m.Dimension - } - return nil -} - -func (m *MetricRequest_MetricIncrement_Values) GetValues() []int64 { - if m != nil { - return m.Values - } - return nil -} - -// 统计应答 -type MetricResponse struct { - // 返回码 - Code *google_protobuf.UInt32Value `protobuf:"bytes,1,opt,name=code" json:"code,omitempty"` - // 返回码详情 - Info *google_protobuf.StringValue `protobuf:"bytes,2,opt,name=info" json:"info,omitempty"` - // 消息ID,用于和应答相对应 - MsgId *google_protobuf.Int64Value `protobuf:"bytes,3,opt,name=msgId" json:"msgId,omitempty"` - Summaries []*MetricResponse_MetricSum `protobuf:"bytes,4,rep,name=summaries" json:"summaries,omitempty"` - // 统计server绝对时间,单位unixnano - Timestamp *google_protobuf.Int64Value `protobuf:"bytes,5,opt,name=timestamp" json:"timestamp,omitempty"` -} - -func (m *MetricResponse) Reset() { *m = MetricResponse{} } -func (m *MetricResponse) String() string { return proto.CompactTextString(m) } -func (*MetricResponse) ProtoMessage() {} -func (*MetricResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } - -func (m *MetricResponse) GetCode() *google_protobuf.UInt32Value { - if m != nil { - return m.Code - } - return nil -} - -func (m *MetricResponse) GetInfo() *google_protobuf.StringValue { - if m != nil { - return m.Info - } - return nil -} - -func (m *MetricResponse) GetMsgId() *google_protobuf.Int64Value { - if m != nil { - return m.MsgId - } - return nil -} - -func (m *MetricResponse) GetSummaries() []*MetricResponse_MetricSum { - if m != nil { - return m.Summaries - } - return nil -} - -func (m *MetricResponse) GetTimestamp() *google_protobuf.Int64Value { - if m != nil { - return m.Timestamp - } - return nil -} - -// 统计滑窗汇总值 -type MetricResponse_MetricSum struct { - // 滑窗统计周期,单位ms - Duration int64 `protobuf:"varint,1,opt,name=duration" json:"duration,omitempty"` - Values []*MetricResponse_MetricSum_Value `protobuf:"bytes,2,rep,name=values" json:"values,omitempty"` -} - -func (m *MetricResponse_MetricSum) Reset() { *m = MetricResponse_MetricSum{} } -func (m *MetricResponse_MetricSum) String() string { return proto.CompactTextString(m) } -func (*MetricResponse_MetricSum) ProtoMessage() {} -func (*MetricResponse_MetricSum) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5, 0} } - -func (m *MetricResponse_MetricSum) GetDuration() int64 { - if m != nil { - return m.Duration - } - return 0 -} - -func (m *MetricResponse_MetricSum) GetValues() []*MetricResponse_MetricSum_Value { - if m != nil { - return m.Values - } - return nil -} - -// 单次上报的统计数据 -// 一次可以同时上报多种类型的统计数据 -type MetricResponse_MetricSum_Value struct { - // 统计类型 - Dimension *MetricDimension `protobuf:"bytes,1,opt,name=dimension" json:"dimension,omitempty"` - // 上报的统计值,按步长为最小单位,包含2次上报之间的增量数据 - Value int64 `protobuf:"varint,2,opt,name=value" json:"value,omitempty"` -} - -func (m *MetricResponse_MetricSum_Value) Reset() { *m = MetricResponse_MetricSum_Value{} } -func (m *MetricResponse_MetricSum_Value) String() string { return proto.CompactTextString(m) } -func (*MetricResponse_MetricSum_Value) ProtoMessage() {} -func (*MetricResponse_MetricSum_Value) Descriptor() ([]byte, []int) { - return fileDescriptor0, []int{5, 0, 0} -} - -func (m *MetricResponse_MetricSum_Value) GetDimension() *MetricDimension { - if m != nil { - return m.Dimension - } - return nil -} - -func (m *MetricResponse_MetricSum_Value) GetValue() int64 { - if m != nil { - return m.Value - } - return 0 -} - -func init() { - proto.RegisterType((*MetricDimension)(nil), "metric.MetricDimension") - proto.RegisterType((*MetricKey)(nil), "metric.MetricKey") - proto.RegisterType((*MetricInitRequest)(nil), "metric.MetricInitRequest") - proto.RegisterType((*MetricInitRequest_MetricWindow)(nil), "metric.MetricInitRequest.MetricWindow") - proto.RegisterType((*MetricQueryRequest)(nil), "metric.MetricQueryRequest") - proto.RegisterType((*MetricRequest)(nil), "metric.MetricRequest") - proto.RegisterType((*MetricRequest_MetricIncrement)(nil), "metric.MetricRequest.MetricIncrement") - proto.RegisterType((*MetricRequest_MetricIncrement_Values)(nil), "metric.MetricRequest.MetricIncrement.Values") - proto.RegisterType((*MetricResponse)(nil), "metric.MetricResponse") - proto.RegisterType((*MetricResponse_MetricSum)(nil), "metric.MetricResponse.MetricSum") - proto.RegisterType((*MetricResponse_MetricSum_Value)(nil), "metric.MetricResponse.MetricSum.Value") - proto.RegisterEnum("metric.MetricType", MetricType_name, MetricType_value) - proto.RegisterEnum("metric.MetricKey_Role", MetricKey_Role_name, MetricKey_Role_value) -} - -func init() { proto.RegisterFile("polaris_metric.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 700 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xdb, 0x6e, 0xd3, 0x40, - 0x10, 0xad, 0xe3, 0x24, 0x6d, 0xa6, 0xb7, 0x74, 0xa9, 0x8a, 0x15, 0xaa, 0x2a, 0x0a, 0xa2, 0xaa, - 0x2a, 0xe4, 0x42, 0xca, 0x45, 0xbc, 0x54, 0xa8, 0x17, 0x89, 0xa8, 0x20, 0xc4, 0xb6, 0xd0, 0x47, - 0xe4, 0x24, 0xd3, 0x68, 0x85, 0xed, 0x75, 0x77, 0xd7, 0xad, 0xfc, 0x57, 0xfc, 0x00, 0x42, 0xfc, - 0x04, 0x1f, 0xc0, 0x23, 0x5f, 0x81, 0xbc, 0x6b, 0xc7, 0x71, 0x2b, 0xda, 0x82, 0x84, 0xc4, 0x5b, - 0x66, 0xf6, 0x9c, 0xf1, 0x99, 0x33, 0xb3, 0x59, 0x58, 0x8e, 0xb8, 0xef, 0x09, 0x26, 0x3f, 0x06, - 0xa8, 0x04, 0x1b, 0xb8, 0x91, 0xe0, 0x8a, 0x93, 0xba, 0x89, 0x5a, 0x6b, 0x23, 0xce, 0x47, 0x3e, - 0x6e, 0xe9, 0x6c, 0x3f, 0x3e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3, 0x92, 0x82, 0x0e, 0x84, 0xe0, 0xc2, 0x80, 0x6c, - 0xb2, 0x0c, 0xcd, 0x22, 0xde, 0x4d, 0xd2, 0xb2, 0xcd, 0x6a, 0xbf, 0xae, 0x6d, 0xdc, 0xfe, 0x15, - 0x00, 0x00, 0xff, 0xff, 0xbb, 0xbb, 0x9c, 0x03, 0x75, 0x07, 0x00, 0x00, -} diff --git a/pkg/model/pb/metric/polaris_metric.proto b/pkg/model/pb/metric/polaris_metric.proto deleted file mode 100644 index 54de3d17..00000000 --- a/pkg/model/pb/metric/polaris_metric.proto +++ /dev/null @@ -1,138 +0,0 @@ -syntax = "proto3"; - -package metric; - -import "google/protobuf/wrappers.proto"; - - -// 统计类型 -enum MetricType { - // 请求数 - ReqCount = 0; - // 被限流数 - LimitCount = 1; - // 按时延来进行上报 - ReqCountByDelay = 2; - // 通用错误数 - ErrorCount = 3; - // 通过错误类型来统计上报 - ErrorCountByType = 4; -} - -// 统计维度 -// 这里直接使用基础类型可以避免转换过程 -message MetricDimension { - //维度类型 - MetricType type = 1; - //维度的具体值,比如具体错误类型 - string value = 2; -} - -// 统计标识,用于唯一关联一种类型的统计滑窗 -// 这里直接使用基础类型可以避免转换过程 -message MetricKey { - // 服务名 - string service = 1; - // 命名空间 - string namespace = 2; - // 服务子集群,格式为key1:value1|key2:value2 - // 如果要查询服务下面所有的subSet信息,subset字段可以填* - string subset = 3; - // 业务标签信息,格式为key1:value1|key2:value2 - // 如果要查询服务下面所有的labels信息,labels字段可以填* - string labels = 4; - // 当前上报的角色类型,主调或者被调 - enum Role { - // 主调 - Caller = 0; - //被调 - Callee = 1; - } - Role role = 5; -} - -//统计初始化请求 -message MetricInitRequest { - //消息ID,用于和应答相对应 - google.protobuf.Int64Value msgId = 1; - // 标识 - MetricKey key = 2; - // 统计类型 - repeated MetricDimension dimensions = 3; - // 统计滑窗 - message MetricWindow { - // 滑窗统计周期,单位ms - int64 duration = 1; - // 滑窗统计精度 - uint32 precision = 2; - } - repeated MetricWindow windows = 4; -} - -//统计查询请求 -message MetricQueryRequest { - //消息ID,用于和应答相对应 - google.protobuf.Int64Value msgId = 1; - // 标识 - MetricKey key = 2; - // 统计类型 - repeated MetricDimension dimensions = 3; - // 查询周期,单位ms - // 该查询周期必须不大于初始化时候给的window信息,按最近的一个精度滑窗向上取整 - int64 duration = 4; -} - -//周期统计上报请求 -message MetricRequest { - //消息ID,用于和应答相对应 - google.protobuf.Int64Value msgId = 1; - // 标识 - MetricKey key = 2; - // 上报的数据 - // 可一次同时上报多种类型的统计数据 - message MetricIncrement { - // 滑窗统计周期,单位ms - int64 duration = 1; - // 单次上报的统计数据 - message Values { - // 统计类型 - MetricDimension dimension = 1; - // 上报的统计值,按步长为最小单位,包含2次上报之间的增量数据 - // 下标越小,则数据是越近 - repeated int64 values = 2; - } - repeated Values values = 2; - // 滑窗统计精度 - uint32 precision = 3; - } - repeated MetricIncrement increments = 3; - // 上报数据最后发生的时间(统计server绝对时间),单位unixnano - google.protobuf.Int64Value timestamp = 4; -} - -//统计应答 -message MetricResponse { - // 返回码 - google.protobuf.UInt32Value code = 1; - // 返回码详情 - google.protobuf.StringValue info = 2; - //消息ID,用于和应答相对应 - google.protobuf.Int64Value msgId = 3; - // 统计滑窗汇总值 - message MetricSum { - // 滑窗统计周期,单位ms - int64 duration = 1; - // 单次上报的统计数据 - // 一次可以同时上报多种类型的统计数据 - message Value { - // 统计类型 - MetricDimension dimension = 1; - // 上报的统计值,按步长为最小单位,包含2次上报之间的增量数据 - int64 value = 2; - } - repeated Value values = 2; - } - repeated MetricSum summaries = 4; - // 统计server绝对时间,单位unixnano - google.protobuf.Int64Value timestamp = 5; -} \ No newline at end of file diff --git a/pkg/model/pb/metric/polaris_metric_api.pb.go b/pkg/model/pb/metric/polaris_metric_api.pb.go deleted file mode 100644 index 91ab12ac..00000000 --- a/pkg/model/pb/metric/polaris_metric_api.pb.go +++ /dev/null @@ -1,382 +0,0 @@ -// Code generated by protoc-gen-go. -// source: polaris_metric_api.proto -// DO NOT EDIT! - -package metric - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -import ( - context "golang.org/x/net/context" - grpc "google.golang.org/grpc" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// 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 RateLimitGRPC service - -type RateLimitGRPCClient interface { - // 限流KEY初始化 - InitializeQuota(ctx context.Context, in *RateLimitRequest, opts ...grpc.CallOption) (*RateLimitResponse, error) - // 获取限流配额 - AcquireQuota(ctx context.Context, opts ...grpc.CallOption) (RateLimitGRPC_AcquireQuotaClient, error) -} - -type rateLimitGRPCClient struct { - cc *grpc.ClientConn -} - -func NewRateLimitGRPCClient(cc *grpc.ClientConn) RateLimitGRPCClient { - return &rateLimitGRPCClient{cc} -} - -func (c *rateLimitGRPCClient) InitializeQuota(ctx context.Context, in *RateLimitRequest, opts ...grpc.CallOption) (*RateLimitResponse, error) { - out := new(RateLimitResponse) - err := grpc.Invoke(ctx, "/v1.RateLimitGRPC/InitializeQuota", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *rateLimitGRPCClient) AcquireQuota(ctx context.Context, opts ...grpc.CallOption) (RateLimitGRPC_AcquireQuotaClient, error) { - stream, err := grpc.NewClientStream(ctx, &_RateLimitGRPC_serviceDesc.Streams[0], c.cc, "/v1.RateLimitGRPC/AcquireQuota", opts...) - if err != nil { - return nil, err - } - x := &rateLimitGRPCAcquireQuotaClient{stream} - return x, nil -} - -type RateLimitGRPC_AcquireQuotaClient interface { - Send(*RateLimitRequest) error - Recv() (*RateLimitResponse, error) - grpc.ClientStream -} - -type rateLimitGRPCAcquireQuotaClient struct { - grpc.ClientStream -} - -func (x *rateLimitGRPCAcquireQuotaClient) Send(m *RateLimitRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *rateLimitGRPCAcquireQuotaClient) Recv() (*RateLimitResponse, error) { - m := new(RateLimitResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// Server API for RateLimitGRPC service - -type RateLimitGRPCServer interface { - // 限流KEY初始化 - InitializeQuota(context.Context, *RateLimitRequest) (*RateLimitResponse, error) - // 获取限流配额 - AcquireQuota(RateLimitGRPC_AcquireQuotaServer) error -} - -func RegisterRateLimitGRPCServer(s *grpc.Server, srv RateLimitGRPCServer) { - s.RegisterService(&_RateLimitGRPC_serviceDesc, srv) -} - -func _RateLimitGRPC_InitializeQuota_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RateLimitRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RateLimitGRPCServer).InitializeQuota(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/v1.RateLimitGRPC/InitializeQuota", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RateLimitGRPCServer).InitializeQuota(ctx, req.(*RateLimitRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _RateLimitGRPC_AcquireQuota_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(RateLimitGRPCServer).AcquireQuota(&rateLimitGRPCAcquireQuotaServer{stream}) -} - -type RateLimitGRPC_AcquireQuotaServer interface { - Send(*RateLimitResponse) error - Recv() (*RateLimitRequest, error) - grpc.ServerStream -} - -type rateLimitGRPCAcquireQuotaServer struct { - grpc.ServerStream -} - -func (x *rateLimitGRPCAcquireQuotaServer) Send(m *RateLimitResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *rateLimitGRPCAcquireQuotaServer) Recv() (*RateLimitRequest, error) { - m := new(RateLimitRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -var _RateLimitGRPC_serviceDesc = grpc.ServiceDesc{ - ServiceName: "v1.RateLimitGRPC", - HandlerType: (*RateLimitGRPCServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "InitializeQuota", - Handler: _RateLimitGRPC_InitializeQuota_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "AcquireQuota", - Handler: _RateLimitGRPC_AcquireQuota_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "polaris_metric_api.proto", -} - -// Client API for MetricGRPC service - -type MetricGRPCClient interface { - // 初始化统计周期 - Init(ctx context.Context, in *MetricInitRequest, opts ...grpc.CallOption) (*MetricResponse, error) - // 查询汇总统计数据 - Query(ctx context.Context, opts ...grpc.CallOption) (MetricGRPC_QueryClient, error) - // 上报统计数据,并返回上报状态(成功or失败) - Report(ctx context.Context, opts ...grpc.CallOption) (MetricGRPC_ReportClient, error) -} - -type metricGRPCClient struct { - cc *grpc.ClientConn -} - -func NewMetricGRPCClient(cc *grpc.ClientConn) MetricGRPCClient { - return &metricGRPCClient{cc} -} - -func (c *metricGRPCClient) Init(ctx context.Context, in *MetricInitRequest, opts ...grpc.CallOption) (*MetricResponse, error) { - out := new(MetricResponse) - err := grpc.Invoke(ctx, "/v1.MetricGRPC/Init", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *metricGRPCClient) Query(ctx context.Context, opts ...grpc.CallOption) (MetricGRPC_QueryClient, error) { - stream, err := grpc.NewClientStream(ctx, &_MetricGRPC_serviceDesc.Streams[0], c.cc, "/v1.MetricGRPC/Query", opts...) - if err != nil { - return nil, err - } - x := &metricGRPCQueryClient{stream} - return x, nil -} - -type MetricGRPC_QueryClient interface { - Send(*MetricQueryRequest) error - Recv() (*MetricResponse, error) - grpc.ClientStream -} - -type metricGRPCQueryClient struct { - grpc.ClientStream -} - -func (x *metricGRPCQueryClient) Send(m *MetricQueryRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *metricGRPCQueryClient) Recv() (*MetricResponse, error) { - m := new(MetricResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *metricGRPCClient) Report(ctx context.Context, opts ...grpc.CallOption) (MetricGRPC_ReportClient, error) { - stream, err := grpc.NewClientStream(ctx, &_MetricGRPC_serviceDesc.Streams[1], c.cc, "/v1.MetricGRPC/Report", opts...) - if err != nil { - return nil, err - } - x := &metricGRPCReportClient{stream} - return x, nil -} - -type MetricGRPC_ReportClient interface { - Send(*MetricRequest) error - Recv() (*MetricResponse, error) - grpc.ClientStream -} - -type metricGRPCReportClient struct { - grpc.ClientStream -} - -func (x *metricGRPCReportClient) Send(m *MetricRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *metricGRPCReportClient) Recv() (*MetricResponse, error) { - m := new(MetricResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// Server API for MetricGRPC service - -type MetricGRPCServer interface { - // 初始化统计周期 - Init(context.Context, *MetricInitRequest) (*MetricResponse, error) - // 查询汇总统计数据 - Query(MetricGRPC_QueryServer) error - // 上报统计数据,并返回上报状态(成功or失败) - Report(MetricGRPC_ReportServer) error -} - -func RegisterMetricGRPCServer(s *grpc.Server, srv MetricGRPCServer) { - s.RegisterService(&_MetricGRPC_serviceDesc, srv) -} - -func _MetricGRPC_Init_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MetricInitRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MetricGRPCServer).Init(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/v1.MetricGRPC/Init", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MetricGRPCServer).Init(ctx, req.(*MetricInitRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MetricGRPC_Query_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(MetricGRPCServer).Query(&metricGRPCQueryServer{stream}) -} - -type MetricGRPC_QueryServer interface { - Send(*MetricResponse) error - Recv() (*MetricQueryRequest, error) - grpc.ServerStream -} - -type metricGRPCQueryServer struct { - grpc.ServerStream -} - -func (x *metricGRPCQueryServer) Send(m *MetricResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *metricGRPCQueryServer) Recv() (*MetricQueryRequest, error) { - m := new(MetricQueryRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func _MetricGRPC_Report_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(MetricGRPCServer).Report(&metricGRPCReportServer{stream}) -} - -type MetricGRPC_ReportServer interface { - Send(*MetricResponse) error - Recv() (*MetricRequest, error) - grpc.ServerStream -} - -type metricGRPCReportServer struct { - grpc.ServerStream -} - -func (x *metricGRPCReportServer) Send(m *MetricResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *metricGRPCReportServer) Recv() (*MetricRequest, error) { - m := new(MetricRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -var _MetricGRPC_serviceDesc = grpc.ServiceDesc{ - ServiceName: "v1.MetricGRPC", - HandlerType: (*MetricGRPCServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Init", - Handler: _MetricGRPC_Init_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Query", - Handler: _MetricGRPC_Query_Handler, - ServerStreams: true, - ClientStreams: true, - }, - { - StreamName: "Report", - Handler: _MetricGRPC_Report_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "polaris_metric_api.proto", -} - -func init() { proto.RegisterFile("polaris_metric_api.proto", fileDescriptor1) } - -var fileDescriptor1 = []byte{ - // 223 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0xc8, 0xcf, 0x49, - 0x2c, 0xca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x57, 0x47, 0x84, 0xf6, 0x24, 0x36, 0x70, 0xd8, - 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x5a, 0x90, 0x7a, 0x84, 0xce, 0x01, 0x00, 0x00, -} diff --git a/pkg/model/pb/metric/polaris_metric_api.proto b/pkg/model/pb/metric/polaris_metric_api.proto deleted file mode 100644 index f67e4927..00000000 --- a/pkg/model/pb/metric/polaris_metric_api.proto +++ /dev/null @@ -1,23 +0,0 @@ -syntax = "proto3"; - -package metric; - -import "polaris_ratelimit.proto"; -import "polaris_metric.proto"; - -service RateLimitGRPC { - // 限流KEY初始化 - rpc InitializeQuota(RateLimitRequest) returns(RateLimitResponse) {} - // 获取限流配额 - rpc AcquireQuota(stream RateLimitRequest) returns(stream RateLimitResponse) {} -} - -// 统计接口 -service MetricGRPC { - // 初始化统计周期 - rpc Init(MetricInitRequest) returns(MetricResponse) {} - // 查询汇总统计数据 - rpc Query(stream MetricQueryRequest) returns(stream MetricResponse) {} - // 上报统计数据,并返回上报状态(成功or失败) - rpc Report(stream MetricRequest) returns(stream MetricResponse) {} -} \ No newline at end of file diff --git a/pkg/model/pb/metric/v2/wrapper.go b/pkg/model/pb/metric/v2/wrapper.go index e004711b..ba3e3833 100644 --- a/pkg/model/pb/metric/v2/wrapper.go +++ b/pkg/model/pb/metric/v2/wrapper.go @@ -18,8 +18,9 @@ package v2 import ( - "github.com/polarismesh/specification/source/go/api/v1/traffic_manage/ratelimiter" "time" + + "github.com/polarismesh/specification/source/go/api/v1/traffic_manage/ratelimiter" ) // ClientRateLimitReportRequest 客户端视角的上报请求 diff --git a/test/mock/namingserver.go b/test/mock/namingserver.go index fb9e16b8..168be4de 100644 --- a/test/mock/namingserver.go +++ b/test/mock/namingserver.go @@ -450,7 +450,7 @@ func (n *namingServer) Heartbeat(ctx context.Context, req *service_manage.Instan }, nil } -func (n *namingServer) BatchHeartbeat(server service_manage.PolarisHeartbeatGRPC_BatchHeartbeatClient) error { +func (n *namingServer) BatchHeartbeat(server service_manage.PolarisHeartbeatGRPC_BatchHeartbeatServer) error { // TODO return nil } diff --git a/test/ratelimit/mock_server.go b/test/ratelimit/mock_server.go index 8e95c649..fb3c74b1 100644 --- a/test/ratelimit/mock_server.go +++ b/test/ratelimit/mock_server.go @@ -19,11 +19,12 @@ package ratelimit import ( "context" - "github.com/polarismesh/specification/source/go/api/v1/traffic_manage/ratelimiter" "sync" "sync/atomic" "time" + "github.com/polarismesh/specification/source/go/api/v1/traffic_manage/ratelimiter" + "github.com/polarismesh/polaris-go/pkg/model" )