Skip to content

Commit

Permalink
use google.golang.org/protobuf instead of `github.com/golang/protob…
Browse files Browse the repository at this point in the history
…uf` (#553)

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Apr 7, 2024
1 parent 4537d29 commit 82a4fb5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/coocood/freecache v1.2.4
github.com/envoyproxy/go-control-plane v0.12.1-0.20240123181358-841e293a220b
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
Expand Down Expand Up @@ -44,6 +43,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
github.com/planetscale/vtprotobuf v0.5.1-0.20231212170721-e7d721933795 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
3 changes: 1 addition & 2 deletions src/provider/xds_grpc_sotw_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
"github.com/envoyproxy/go-control-plane/pkg/resource/v3"
"github.com/golang/protobuf/ptypes/any"
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
"github.com/jpillora/backoff"
logger "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -149,7 +148,7 @@ func (p *XdsGrpcSotwProvider) getGrpcTransportCredentials() grpc.DialOption {
return grpc.WithTransportCredentials(credentials.NewTLS(configGrpcXdsTlsConfig))
}

func (p *XdsGrpcSotwProvider) sendConfigs(resources []*any.Any) {
func (p *XdsGrpcSotwProvider) sendConfigs(resources []*anypb.Any) {
defer func() {
if e := recover(); e != nil {
p.configUpdateEventChan <- &ConfigUpdateEventImpl{err: e}
Expand Down
6 changes: 3 additions & 3 deletions src/utils/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"

pb "github.com/envoyproxy/go-control-plane/envoy/service/ratelimit/v3"
"github.com/golang/protobuf/ptypes/duration"
"google.golang.org/protobuf/types/known/durationpb"
)

// Interface for a time source.
Expand All @@ -31,10 +31,10 @@ func UnitToDivider(unit pb.RateLimitResponse_RateLimit_Unit) int64 {
panic("should not get here")
}

func CalculateReset(unit *pb.RateLimitResponse_RateLimit_Unit, timeSource TimeSource) *duration.Duration {
func CalculateReset(unit *pb.RateLimitResponse_RateLimit_Unit, timeSource TimeSource) *durationpb.Duration {
sec := UnitToDivider(*unit)
now := timeSource.UnixNow()
return &duration.Duration{Seconds: sec - now%sec}
return &durationpb.Duration{Seconds: sec - now%sec}
}

func Max(a uint32, b uint32) uint32 {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
"time"

pb "github.com/envoyproxy/go-control-plane/envoy/service/ratelimit/v3"
"github.com/golang/protobuf/ptypes/duration"
"github.com/kelseyhightower/envconfig"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/protobuf/types/known/durationpb"

"github.com/envoyproxy/ratelimit/src/memcached"
"github.com/envoyproxy/ratelimit/src/service_cmd/runner"
Expand Down Expand Up @@ -59,14 +59,14 @@ func defaultSettings() settings.Settings {
return s
}

func newDescriptorStatus(status pb.RateLimitResponse_Code, requestsPerUnit uint32, unit pb.RateLimitResponse_RateLimit_Unit, limitRemaining uint32, durRemaining *duration.Duration) *pb.RateLimitResponse_DescriptorStatus {
func newDescriptorStatus(status pb.RateLimitResponse_Code, requestsPerUnit uint32, unit pb.RateLimitResponse_RateLimit_Unit, limitRemaining uint32, durRemaining *durationpb.Duration) *pb.RateLimitResponse_DescriptorStatus {
limit := &pb.RateLimitResponse_RateLimit{RequestsPerUnit: requestsPerUnit, Unit: unit}

return &pb.RateLimitResponse_DescriptorStatus{
Code: status,
CurrentLimit: limit,
LimitRemaining: limitRemaining,
DurationUntilReset: &duration.Duration{Seconds: durRemaining.GetSeconds()},
DurationUntilReset: &durationpb.Duration{Seconds: durRemaining.GetSeconds()},
}
}

Expand Down

0 comments on commit 82a4fb5

Please sign in to comment.