Skip to content

Commit

Permalink
Update deprecated grpc names
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Doherty <chris.doherty4@gmail.com>
  • Loading branch information
chrisdoherty4 committed May 9, 2023
1 parent 45ed70d commit 6d75307
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/grpcserver/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"context"
"net"

grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/pkg/errors"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
Expand All @@ -20,15 +19,21 @@ type Registrar interface {
// SetupGRPC opens a listener and serves a given Registrar's APIs on a gRPC server and returns the listener's address or an error.
func SetupGRPC(ctx context.Context, r Registrar, listenAddr string, errCh chan<- error) (string, error) {
params := []grpc.ServerOption{
grpc_middleware.WithUnaryServerChain(grpc_prometheus.UnaryServerInterceptor, otelgrpc.UnaryServerInterceptor()),
grpc_middleware.WithStreamServerChain(grpc_prometheus.StreamServerInterceptor, otelgrpc.StreamServerInterceptor()),
grpc.ChainUnaryInterceptor(
grpcprometheus.UnaryServerInterceptor,
otelgrpc.UnaryServerInterceptor(),
),
grpc.ChainStreamInterceptor(
grpcprometheus.StreamServerInterceptor,
otelgrpc.StreamServerInterceptor(),
),
}

// register servers
s := grpc.NewServer(params...)
r.Register(s)
reflection.Register(s)
grpc_prometheus.Register(s)
grpcprometheus.Register(s)

lis, err := net.Listen("tcp", listenAddr)
if err != nil {
Expand Down

0 comments on commit 6d75307

Please sign in to comment.