Skip to content

Commit

Permalink
chore(migrate): grpc client side migate
Browse files Browse the repository at this point in the history
migrate cmdserver
- server
  - migrate ServerInterceptor -> NewServerHandler
- client
  - migrate ClientInterceptor -> NewClientHandler

Signed-off-by: Jack-R-lantern <tjdfkr2421@gmail.com>
  • Loading branch information
Jack-R-lantern committed May 23, 2024
1 parent 8776cc1 commit 70cf3a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 5 additions & 4 deletions cmpserver/apiclient/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package apiclient

import (
"context"
"github.com/argoproj/argo-cd/v2/common"
"github.com/argoproj/argo-cd/v2/util/env"
"math"
"time"

"github.com/argoproj/argo-cd/v2/common"
"github.com/argoproj/argo-cd/v2/util/env"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"

grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -49,8 +51,7 @@ func NewConnection(address string) (*grpc.ClientConn, error) {
grpc.WithStreamInterceptor(grpc_retry.StreamClientInterceptor(retryOpts...)),
grpc.WithUnaryInterceptor(grpc_middleware.ChainUnaryClient(unaryInterceptors...)),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(MaxGRPCMessageSize), grpc.MaxCallSendMsgSize(MaxGRPCMessageSize)),
grpc.WithUnaryInterceptor(grpc_util.OTELUnaryClientInterceptor()),
grpc.WithStreamInterceptor(grpc_util.OTELStreamClientInterceptor()),
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
}

dialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials()))
Expand Down
3 changes: 1 addition & 2 deletions cmpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ func NewServer(initConstants plugin.CMPServerInitConstants) (*ArgoCDCMPServer, e

serverLog := log.NewEntry(log.StandardLogger())
streamInterceptors := []grpc.StreamServerInterceptor{
otelgrpc.StreamServerInterceptor(), //nolint:staticcheck // TODO: ignore SA1019 for depreciation: see https://github.com/argoproj/argo-cd/issues/18258
grpc_logrus.StreamServerInterceptor(serverLog),
grpc_prometheus.StreamServerInterceptor,
grpc_util.PanicLoggerStreamServerInterceptor(serverLog),
}
unaryInterceptors := []grpc.UnaryServerInterceptor{
otelgrpc.UnaryServerInterceptor(), //nolint:staticcheck // TODO: ignore SA1019 for depreciation: see https://github.com/argoproj/argo-cd/issues/18258
grpc_logrus.UnaryServerInterceptor(serverLog),
grpc_prometheus.UnaryServerInterceptor,
grpc_util.PanicLoggerUnaryServerInterceptor(serverLog),
Expand All @@ -68,6 +66,7 @@ func NewServer(initConstants plugin.CMPServerInitConstants) (*ArgoCDCMPServer, e
MinTime: common.GetGRPCKeepAliveEnforcementMinimum(),
},
),
grpc.StatsHandler(otelgrpc.NewServerHandler()),
}

return &ArgoCDCMPServer{
Expand Down

0 comments on commit 70cf3a3

Please sign in to comment.