Skip to content

Commit

Permalink
fix:ratelimit server spec dep (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun authored Aug 22, 2023
1 parent e72071e commit 2e4969b
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 1,152 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
8 changes: 4 additions & 4 deletions pkg/flow/quota/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package quota
import (
"context"
"fmt"
"github.com/polarismesh/specification/source/go/api/v1/traffic_manage/ratelimiter"
"io"
"net"
"strings"
Expand All @@ -30,14 +29,15 @@ 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"

"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 应答回调函数
Expand All @@ -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
}
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/flow/quota/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 2e4969b

Please sign in to comment.