Beispiel #1
0
func newGRPCBinding(ctx context.Context, tracer opentracing.Tracer, svc server.AddService, tracingLogger log.Logger) grpcBinding {
	return grpcBinding{
		sum: grpc.NewServer(
			ctx,
			kitot.TraceServer(tracer, "sum")(makeSumEndpoint(svc)),
			servergrpc.DecodeSumRequest,
			servergrpc.EncodeSumResponse,
			grpc.ServerBefore(kitot.FromGRPCRequest(tracer, "", tracingLogger)),
		),
		concat: grpc.NewServer(
			ctx,
			kitot.TraceServer(tracer, "concat")(makeConcatEndpoint(svc)),
			servergrpc.DecodeConcatRequest,
			servergrpc.EncodeConcatResponse,
			grpc.ServerBefore(kitot.FromGRPCRequest(tracer, "", tracingLogger)),
		),
	}
}
Beispiel #2
0
// MakeGRPCServer makes a set of endpoints available as a gRPC AddServer.
func MakeGRPCServer(ctx context.Context, endpoints Endpoints, tracer stdopentracing.Tracer, logger log.Logger) pb.AddServer {
	options := []grpctransport.ServerOption{
		grpctransport.ServerErrorLogger(logger),
	}
	return &grpcServer{
		sum: grpctransport.NewServer(
			ctx,
			endpoints.SumEndpoint,
			DecodeGRPCSumRequest,
			EncodeGRPCSumResponse,
			append(options, grpctransport.ServerBefore(opentracing.FromGRPCRequest(tracer, "Sum", logger)))...,
		),
		concat: grpctransport.NewServer(
			ctx,
			endpoints.ConcatEndpoint,
			DecodeGRPCConcatRequest,
			EncodeGRPCConcatResponse,
			append(options, grpctransport.ServerBefore(opentracing.FromGRPCRequest(tracer, "Concat", logger)))...,
		),
	}
}