예제 #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)),
		),
	}
}
예제 #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)))...,
		),
	}
}
예제 #3
0
파일: grpc_binding.go 프로젝트: qband/down
func newGRPCBinding(ctx context.Context, svc server.AddService) grpcBinding {
	return grpcBinding{
		sum:    grpc.NewServer(ctx, makeSumEndpoint(svc), servergrpc.DecodeSumRequest, servergrpc.EncodeSumResponse),
		concat: grpc.NewServer(ctx, makeConcatEndpoint(svc), servergrpc.DecodeConcatRequest, servergrpc.EncodeConcatResponse),
	}
}