protected override void AddGenericVoidBlockingMethodCore <TRequest>(
            Action <TService, TRequest, CancellationToken> serviceCaller,
            RpcServerFaultHandler faultHandler,
            RpcStub <TService> serviceStub,
            RpcOperationInfo operationInfo,
            ILightweightMethodBinder binder)
        {
            var serializer = operationInfo.SerializerOverride ?? serviceStub.Serializer;

            ValueTask <RpcResponse> HandleRequest(TRequest request, IServiceProvider?serviceProvider, LightweightCallContext context)
            => serviceStub.CallVoidBlockingMethod(request, serviceProvider, context, serviceCaller, faultHandler, serializer);

            var methodStub = new LightweightMethodStub <TRequest, RpcResponse>(operationInfo.FullName, HandleRequest, serializer, faultHandler,
                                                                               operationInfo.AllowInlineExecution);

            binder.AddMethod(methodStub);
        }
Пример #2
0
        protected override void AddGenericVoidBlockingMethodCore <TRequest>(
            Action <TService, TRequest, CancellationToken> serviceCaller,
            RpcServerFaultHandler faultHandler,
            RpcStub <TService> serviceStub,
            RpcOperationInfo operationInfo,
            INetGrpcBinder <TService> binder)
        {
            var serializer = serviceStub.Serializer;

            Task <RpcResponse> handler(NetGrpcServiceActivator <TService> activator, TRequest request, ServerCallContext context)
            => serviceStub.CallVoidBlockingMethod(
                request, activator.ServiceProvider, new GrpcCallContext(context), serviceCaller, faultHandler,
                serializer).AsTask();

            var methodStub = GrpcMethodDefinition.Create <TRequest, RpcResponse>(
                MethodType.Unary,
                operationInfo.FullServiceName, operationInfo.Name,
                serializer);

            binder.AddUnaryMethod(methodStub, operationInfo.Metadata, handler);
        }
Пример #3
0
        protected override void AddGenericVoidBlockingMethodCore <TRequest>(
            Action <TService, TRequest, CancellationToken> serviceCaller,
            RpcServerFaultHandler faultHandler,
            RpcStub <TService> serviceStub,
            RpcOperationInfo operationInfo,
            IGrpcMethodBinder binder)
        {
            var serializer = serviceStub.Serializer;

            GrpcCore.UnaryServerMethod <TRequest, RpcResponse> handler = (request, context) =>
            {
                using (var serviceScope = CreateServiceScope(serviceStub))
                {
                    return(serviceStub.CallVoidBlockingMethod(
                               request, serviceScope?.ServiceProvider, new GrpcCallContext(context), serviceCaller,
                               faultHandler, serializer).AsTask());
                }
            };

            binder.AddMethod(
                GrpcMethodDefinition.Create <TRequest, RpcResponse>(GrpcCore.MethodType.Unary,
                                                                    operationInfo.FullServiceName, operationInfo.Name, serializer),
                handler);
        }