コード例 #1
0
 public override IEnumerable <IAction> GetActions()
 {
     if (EjectViewModel.IsEject)
     {
         yield return(ServiceActivator.Create <EjectAction>());
     }
 }
コード例 #2
0
        protected override async Task HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext)
        {
            // Decode request
            var request = await httpContext.Request.BodyReader.ReadSingleMessageAsync <TRequest>(serverCallContext, Method.RequestMarshaller.ContextualDeserializer);

            if (_pipelineInvoker == null)
            {
                var service = (TService)ServiceActivator.Create(serverCallContext, typeof(TService));
                try
                {
                    await _invoker(
                        service,
                        request,
                        new HttpContextStreamWriter <TResponse>(serverCallContext, Method.ResponseMarshaller.ContextualSerializer),
                        serverCallContext);
                }
                finally
                {
                    await ServiceActivator.ReleaseAsync(service);
                }
            }
            else
            {
                await _pipelineInvoker(
                    request,
                    new HttpContextStreamWriter <TResponse>(serverCallContext, Method.ResponseMarshaller.ContextualSerializer),
                    serverCallContext);
            }
        }
コード例 #3
0
        protected override async Task HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext)
        {
            var request = await httpContext.Request.BodyReader.ReadSingleMessageAsync <TRequest>(serverCallContext, Method.RequestMarshaller.ContextualDeserializer);

            TResponse?response = null;

            if (_pipelineInvoker == null)
            {
                var service = (TService)ServiceActivator.Create(serverCallContext, typeof(TService));
                try
                {
                    response = await _invoker(service, request, serverCallContext);
                }
                finally
                {
                    await ServiceActivator.ReleaseAsync(service);
                }
            }
            else
            {
                response = await _pipelineInvoker(request, serverCallContext);
            }

            if (response == null)
            {
                // This is consistent with Grpc.Core when a null value is returned
                throw new RpcException(new Status(StatusCode.Cancelled, "No message returned from method."));
            }

            var responseBodyWriter = httpContext.Response.BodyWriter;
            await responseBodyWriter.WriteMessageAsync(response, serverCallContext, Method.ResponseMarshaller.ContextualSerializer, canFlush : false);
        }
コード例 #4
0
        public void TestRandomness()
        {
            IPAddress[] ips = new IPAddress[4];
            for (byte i = 0; i < ips.Length; ++i)
            {
                ips[i] = new IPAddress(new byte[] { 192, 168, 0, i });
            }

            IEndpointStrategy endpointStrategy = ServiceActivator <Factory> .Create <IEndpointStrategy>("Random", ips.AsEnumerable());

            List <IPAddress> alls = new List <IPAddress>();

            for (int i = 0; i < 10000; ++i)
            {
                IPAddress nextEndpoint = endpointStrategy.Pick(null);
                if (!alls.Contains(nextEndpoint))
                {
                    alls.Add(nextEndpoint);
                }
            }

            foreach (IPAddress ip in alls)
            {
                Assert.IsTrue(alls.Contains(ip));
            }
        }
コード例 #5
0
        public void TestCreateCustom()
        {
            string          customType = typeof(CustomSnitch).AssemblyQualifiedName;
            IEndpointSnitch snitch     = ServiceActivator <Factory> .Create <IEndpointSnitch>(customType);

            Assert.IsTrue(snitch is CustomSnitch);
        }
コード例 #6
0
        protected override async Task HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext)
        {
            // Disable request body data rate for client streaming
            DisableMinRequestBodyDataRateAndMaxRequestBodySize(httpContext);

            if (_pipelineInvoker == null)
            {
                GrpcActivatorHandle <TService> serviceHandle = default;
                try
                {
                    serviceHandle = ServiceActivator.Create(httpContext.RequestServices);
                    await _invoker(
                        serviceHandle.Instance,
                        new HttpContextStreamReader <TRequest>(serverCallContext, Method.RequestMarshaller.ContextualDeserializer),
                        new HttpContextStreamWriter <TResponse>(serverCallContext, Method.ResponseMarshaller.ContextualSerializer),
                        serverCallContext);
                }
                finally
                {
                    if (serviceHandle.Instance != null)
                    {
                        ServiceActivator.Release(serviceHandle);
                    }
                }
            }
            else
            {
                await _pipelineInvoker(
                    new HttpContextStreamReader <TRequest>(serverCallContext, Method.RequestMarshaller.ContextualDeserializer),
                    new HttpContextStreamWriter <TResponse>(serverCallContext, Method.ResponseMarshaller.ContextualSerializer),
                    serverCallContext);
            }
        }
コード例 #7
0
        protected override async Task HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext)
        {
            // Disable request body data rate for client streaming
            DisableMinRequestBodyDataRateAndMaxRequestBodySize(httpContext);

            if (_pipelineInvoker == null)
            {
                var service = (TService)ServiceActivator.Create(serverCallContext, typeof(TService));
                try
                {
                    await _invoker(
                        service,
                        new HttpContextStreamReader <TRequest>(serverCallContext, Method.RequestMarshaller.ContextualDeserializer),
                        new HttpContextStreamWriter <TResponse>(serverCallContext, Method.ResponseMarshaller.ContextualSerializer),
                        serverCallContext);
                }
                finally
                {
                    await ServiceActivator.ReleaseAsync(service);
                }
            }
            else
            {
                await _pipelineInvoker(
                    new HttpContextStreamReader <TRequest>(serverCallContext, Method.RequestMarshaller.ContextualDeserializer),
                    new HttpContextStreamWriter <TResponse>(serverCallContext, Method.ResponseMarshaller.ContextualSerializer),
                    serverCallContext);
            }
        }
コード例 #8
0
        public ServerStreamingServerCallHandler(
            Method <TRequest, TResponse> method,
            ServerStreamingServerMethod <TService, TRequest, TResponse> invoker,
            GrpcServiceOptions serviceOptions,
            ILoggerFactory loggerFactory,
            IGrpcServiceActivator <TService> serviceActivator,
            IServiceProvider serviceProvider)
            : base(method, serviceOptions, loggerFactory, serviceActivator, serviceProvider)
        {
            _invoker = invoker;

            if (ServiceOptions.HasInterceptors)
            {
                ServerStreamingServerMethod <TRequest, TResponse> resolvedInvoker = async(resolvedRequest, responseStream, resolvedContext) =>
                {
                    GrpcActivatorHandle <TService> serviceHandle = default;
                    try
                    {
                        serviceHandle = ServiceActivator.Create(resolvedContext.GetHttpContext().RequestServices);
                        await _invoker(serviceHandle.Instance, resolvedRequest, responseStream, resolvedContext);
                    }
                    finally
                    {
                        if (serviceHandle.Instance != null)
                        {
                            ServiceActivator.Release(serviceHandle);
                        }
                    }
                };

                var interceptorPipeline = new InterceptorPipelineBuilder <TRequest, TResponse>(ServiceOptions.Interceptors, ServiceProvider);
                _pipelineInvoker = interceptorPipeline.ServerStreamingPipeline(resolvedInvoker);
            }
        }
コード例 #9
0
        protected override async Task HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext)
        {
            // Decode request
            var request = await httpContext.Request.BodyReader.ReadSingleMessageAsync <TRequest>(serverCallContext, Method.RequestMarshaller.ContextualDeserializer);

            if (_pipelineInvoker == null)
            {
                GrpcActivatorHandle <TService> serviceHandle = default;
                try
                {
                    serviceHandle = ServiceActivator.Create(httpContext.RequestServices);
                    await _invoker(
                        serviceHandle.Instance,
                        request,
                        new HttpContextStreamWriter <TResponse>(serverCallContext, Method.ResponseMarshaller.ContextualSerializer),
                        serverCallContext);
                }
                finally
                {
                    if (serviceHandle.Instance != null)
                    {
                        ServiceActivator.Release(serviceHandle);
                    }
                }
            }
            else
            {
                await _pipelineInvoker(
                    request,
                    new HttpContextStreamWriter <TResponse>(serverCallContext, Method.ResponseMarshaller.ContextualSerializer),
                    serverCallContext);
            }
        }
コード例 #10
0
 /// <summary>
 /// Invoke the client streaming method with the specified <see cref="HttpContext"/>.
 /// </summary>
 /// <param name="httpContext">The <see cref="HttpContext"/> for the current request.</param>
 /// <param name="serverCallContext">The <see cref="ServerCallContext"/>.</param>
 /// <param name="requestStream">The <typeparamref name="TRequest"/> reader.</param>
 /// <returns>A <see cref="Task{TResponse}"/> that represents the asynchronous method. The <see cref="Task{TResponse}.Result"/>
 /// property returns the <typeparamref name="TResponse"/> message.</returns>
 public async Task <TResponse> Invoke(HttpContext httpContext, ServerCallContext serverCallContext, IAsyncStreamReader <TRequest> requestStream)
 {
     if (_pipelineInvoker == null)
     {
         GrpcActivatorHandle <TService> serviceHandle = default;
         try
         {
             serviceHandle = ServiceActivator.Create(httpContext.RequestServices);
             return(await _invoker(
                        serviceHandle.Instance,
                        requestStream,
                        serverCallContext));
         }
         finally
         {
             if (serviceHandle.Instance != null)
             {
                 await ServiceActivator.ReleaseAsync(serviceHandle);
             }
         }
     }
     else
     {
         return(await _pipelineInvoker(
                    requestStream,
                    serverCallContext));
     }
 }
コード例 #11
0
 public override IEnumerable <IAction> GetActions()
 {
     if (SoftwareViewModel.SelectedItem == null)
     {
         yield return(ServiceActivator.Create <BrowseAction>());
     }
 }
コード例 #12
0
 /// <summary>
 /// Invoke the server streaming method with the specified <see cref="HttpContext"/>.
 /// </summary>
 /// <param name="httpContext">The <see cref="HttpContext"/> for the current request.</param>
 /// <param name="serverCallContext">The <see cref="ServerCallContext"/>.</param>
 /// <param name="request">The <typeparamref name="TRequest"/> message.</param>
 /// <param name="streamWriter">The <typeparamref name="TResponse"/> stream writer.</param>
 /// <returns>A <see cref="Task"/> that represents the asynchronous method.</returns>
 public async Task Invoke(HttpContext httpContext, ServerCallContext serverCallContext, TRequest request, IServerStreamWriter <TResponse> streamWriter)
 {
     if (_pipelineInvoker == null)
     {
         GrpcActivatorHandle <TService> serviceHandle = default;
         try
         {
             serviceHandle = ServiceActivator.Create(httpContext.RequestServices);
             await _invoker(
                 serviceHandle.Instance,
                 request,
                 streamWriter,
                 serverCallContext);
         }
         finally
         {
             if (serviceHandle.Instance != null)
             {
                 await ServiceActivator.ReleaseAsync(serviceHandle);
             }
         }
     }
     else
     {
         await _pipelineInvoker(
             request,
             streamWriter,
             serverCallContext);
     }
 }
コード例 #13
0
        public void TestCreateWithNull()
        {
            string       type  = null;
            const string key   = "tralala";
            const int    value = 42;

            Assert.Throws <ArgumentException>(() => ServiceActivator <FactoryWithCustomType> .Create <ITestService>(type, key, value));
        }
コード例 #14
0
        public void TestCreateRandom()
        {
            IEndpointStrategy endpointStrategy = ServiceActivator <CassandraSharp.EndpointStrategy.Factory> .Create <IEndpointStrategy>("Random",
                                                                                                                                        Enumerable.Empty <IPAddress>
                                                                                                                                            (),
                                                                                                                                        new SimpleSnitch());

            Assert.IsTrue(endpointStrategy is RandomEndpointStrategy);
        }
コード例 #15
0
 public override IEnumerable <IAction> GetActions()
 {
     if (CardViewModel.SelectedItem.Scriptable)
     {
         yield return(ServiceActivator.Create <ClearScriptableAction>());
     }
     else if (CanSetScriptable)
     {
         yield return(ServiceActivator.Create <SetScriptableAction>());
     }
 }
        /// <summary>
        /// Invoke the unary method with the specified <see cref="HttpContext"/>.
        /// </summary>
        /// <param name="httpContext">The <see cref="HttpContext"/> for the current request.</param>
        /// <param name="serverCallContext">The <see cref="ServerCallContext"/>.</param>
        /// <param name="request">The <typeparamref name="TRequest"/> message.</param>
        /// <returns>A <see cref="Task{TResponse}"/> that represents the asynchronous method. The <see cref="Task{TResponse}.Result"/>
        /// property returns the <typeparamref name="TResponse"/> message.</returns>
        public Task <TResponse> Invoke(HttpContext httpContext, ServerCallContext serverCallContext, TRequest request)
        {
            if (_pipelineInvoker == null)
            {
                GrpcActivatorHandle <TService> serviceHandle = default;
                Task <TResponse>?invokerTask = null;
                try
                {
                    serviceHandle = ServiceActivator.Create(httpContext.RequestServices);
                    invokerTask   = _invoker(
                        serviceHandle.Instance,
                        request,
                        serverCallContext);
                }
                catch (Exception ex)
                {
                    // Invoker calls user code. User code may throw an exception instead
                    // of a faulted task. We need to catch the exception, ensure cleanup
                    // runs and convert exception into a faulted task.
                    if (serviceHandle.Instance != null)
                    {
                        var releaseTask = ServiceActivator.ReleaseAsync(serviceHandle);
                        if (!releaseTask.IsCompletedSuccessfully)
                        {
                            // Capture the current exception state so we can rethrow it after awaiting
                            // with the same stack trace.
                            var exceptionDispatchInfo = ExceptionDispatchInfo.Capture(ex);
                            return(AwaitServiceReleaseAndThrow(releaseTask, exceptionDispatchInfo));
                        }
                    }

                    return(Task.FromException <TResponse>(ex));
                }

                if (invokerTask.IsCompletedSuccessfully && serviceHandle.Instance != null)
                {
                    var releaseTask = ServiceActivator.ReleaseAsync(serviceHandle);
                    if (!releaseTask.IsCompletedSuccessfully)
                    {
                        return(AwaitServiceReleaseAndReturn(invokerTask.Result, serviceHandle));
                    }

                    return(invokerTask);
                }

                return(AwaitInvoker(invokerTask, serviceHandle));
            }
            else
            {
                return(_pipelineInvoker(
                           request,
                           serverCallContext));
            }
        }
コード例 #17
0
        public void TestCreateWithCustomType()
        {
            string       type  = typeof(TestService).AssemblyQualifiedName;
            const string key   = "tralala";
            const int    value = 42;

            ITestService testService = ServiceActivator <FactoryWithCustomType> .Create <ITestService>(type, key, value);

            Assert.IsNotNull(testService);
            Assert.IsTrue(key == testService.Key);
            Assert.IsTrue(value == testService.Value);
        }
コード例 #18
0
        private IAction CreateAction(int part)
        {
            var types = new[]
            {
                typeof(int),
            };
            var args = new object[]
            {
                part,
            };

            return(ServiceActivator.Create <SwitchAction>(types, args));
        }
コード例 #19
0
        private IAction CreateAction(ProductSource productSource)
        {
            var types = new[]
            {
                typeof(ProductSource)
            };
            var values = new object[]
            {
                productSource
            };

            return(ServiceActivator.Create <TAction>(types, values));
        }
コード例 #20
0
        private async Task ResolvedInterceptorInvoker(TRequest resolvedRequest, IServerStreamWriter <TResponse> responseStream, ServerCallContext resolvedContext)
        {
            var service = (TService)ServiceActivator.Create(resolvedContext, typeof(TService));

            try
            {
                await _invoker(service, resolvedRequest, responseStream, resolvedContext);
            }
            finally
            {
                await ServiceActivator.ReleaseAsync(service);
            }
        }
コード例 #21
0
        protected IAction CreateAction(SoftwareCameraInfo camera, ProductSource productSource)
        {
            var types = new[]
            {
                typeof(SoftwareCameraInfo),
                typeof(ProductSource)
            };
            var values = new object[]
            {
                camera,
                productSource
            };

            return(ServiceActivator.Create <TAction>(types, values));
        }
コード例 #22
0
        private async Task <TResponse> ResolvedInterceptorInvoker(IAsyncStreamReader <TRequest> resolvedRequestStream, ServerCallContext resolvedContext)
        {
            var service = (TService)ServiceActivator.Create(resolvedContext, typeof(TService));

            try
            {
                return(await _invoker(
                           service,
                           resolvedRequestStream,
                           resolvedContext));
            }
            finally
            {
                await ServiceActivator.ReleaseAsync(service);
            }
        }
コード例 #23
0
        private async Task <TResponse> ResolvedInterceptorInvoker(TRequest resolvedRequest, ServerCallContext resolvedContext)
        {
            GrpcActivatorHandle <TService> serviceHandle = default;

            try
            {
                serviceHandle = ServiceActivator.Create(resolvedContext.GetHttpContext().RequestServices);
                return(await _invoker(serviceHandle.Instance, resolvedRequest, resolvedContext));
            }
            finally
            {
                if (serviceHandle.Instance != null)
                {
                    await ServiceActivator.ReleaseAsync(serviceHandle);
                }
            }
        }
コード例 #24
0
        public void TestCreateCustom()
        {
            string customType = typeof(CustomEndpointStrategy).AssemblyQualifiedName;

            IEnumerable <IPAddress> endpoints = new List <IPAddress> {
                null
            };
            IEndpointStrategy endpointStrategy = ServiceActivator <CassandraSharp.EndpointStrategy.Factory> .Create <IEndpointStrategy>(customType, endpoints,
                                                                                                                                        new SimpleSnitch());

            CustomEndpointStrategy customEndpointStrategy = endpointStrategy as CustomEndpointStrategy;

            Assert.IsNotNull(customEndpointStrategy);
            IPAddress customEndpoint = customEndpointStrategy.Endpoints.Single();

            Assert.AreEqual(customEndpoint, endpoints.Single());
        }
コード例 #25
0
        public override IEnumerable <IAction> GetActions()
        {
            var categoryName = CardViewModel.SelectedItem.Bootable;

            if (categoryName != null)
            {
                var types  = new[] { typeof(string) };
                var values = new[] { categoryName };
                yield return(ServiceActivator.Create <ClearBootableAction>(types, values));
            }
            else if ((categoryName = GetCategoryName()) != null)
            {
                var types  = new[] { typeof(string) };
                var values = new[] { categoryName };
                yield return(ServiceActivator.Create <SetBootableAction>(types, values));
            }
        }
コード例 #26
0
        protected override async Task HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext)
        {
            var requestPayload = await httpContext.Request.BodyReader.ReadSingleMessageAsync(serverCallContext);

            serverCallContext.DeserializationContext.SetPayload(requestPayload);
            var request = Method.RequestMarshaller.ContextualDeserializer(serverCallContext.DeserializationContext);

            serverCallContext.DeserializationContext.SetPayload(null);

            GrpcEventSource.Log.MessageReceived();

            TResponse?response = null;

            if (_pipelineInvoker == null)
            {
                GrpcActivatorHandle <TService> serviceHandle = default;
                try
                {
                    serviceHandle = ServiceActivator.Create(httpContext.RequestServices);
                    response      = await _invoker(serviceHandle.Instance, request, serverCallContext);
                }
                finally
                {
                    if (serviceHandle.Instance != null)
                    {
                        ServiceActivator.Release(serviceHandle);
                    }
                }
            }
            else
            {
                response = await _pipelineInvoker(request, serverCallContext);
            }

            if (response == null)
            {
                // This is consistent with Grpc.Core when a null value is returned
                throw new RpcException(new Status(StatusCode.Cancelled, "No message returned from method."));
            }

            var responseBodyWriter = httpContext.Response.BodyWriter;
            await responseBodyWriter.WriteMessageAsync(response, serverCallContext, Method.ResponseMarshaller.ContextualSerializer, canFlush : false);

            GrpcEventSource.Log.MessageSent();
        }
コード例 #27
0
        protected override async Task HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext)
        {
            // Disable request body data rate for client streaming
            DisableMinRequestBodyDataRateAndMaxRequestBodySize(httpContext);

            TResponse?response = null;

            if (_pipelineInvoker == null)
            {
                GrpcActivatorHandle <TService> serviceHandle = default;
                try
                {
                    serviceHandle = ServiceActivator.Create(httpContext.RequestServices);
                    response      = await _invoker(
                        serviceHandle.Instance,
                        new HttpContextStreamReader <TRequest>(serverCallContext, Method.RequestMarshaller.ContextualDeserializer),
                        serverCallContext);
                }
                finally
                {
                    if (serviceHandle.Instance != null)
                    {
                        ServiceActivator.Release(serviceHandle);
                    }
                }
            }
            else
            {
                response = await _pipelineInvoker(
                    new HttpContextStreamReader <TRequest>(serverCallContext, Method.RequestMarshaller.ContextualDeserializer),
                    serverCallContext);
            }

            if (response == null)
            {
                // This is consistent with Grpc.Core when a null value is returned
                throw new RpcException(new Status(StatusCode.Cancelled, "No message returned from method."));
            }

            var responseBodyWriter = httpContext.Response.BodyWriter;
            await responseBodyWriter.WriteMessageAsync(response, serverCallContext, Method.ResponseMarshaller.ContextualSerializer, canFlush : false);

            GrpcEventSource.Log.MessageSent();
        }
コード例 #28
0
        public ICluster GetCluster(ClusterConfig clusterConfig)
        {
            clusterConfig.CheckArgumentNotNull("clusterConfig");
            clusterConfig.Endpoints.CheckArgumentNotNull("clusterConfig.Endpoints");

            TransportConfig  transportConfig = clusterConfig.Transport ?? new TransportConfig();
            IRecoveryService recoveryService = GetRecoveryService(transportConfig.Recoverable);
            KeyspaceConfig   keyspaceConfig  = clusterConfig.DefaultKeyspace ?? new KeyspaceConfig();

            // create endpoints
            IEndpointSnitch snitch = ServiceActivator <Factory> .Create <IEndpointSnitch>(clusterConfig.Endpoints.Snitch, _logger);

            IEnumerable <IPAddress> endpoints = clusterConfig.Endpoints.Servers.Select(Network.Find).Where(x => null != x).ToArray();

            if (!endpoints.Any())
            {
                throw new ArgumentException("Expecting at least one valid endpoint");
            }

            // create required services
            IEndpointStrategy endpointsManager = ServiceActivator <EndpointStrategy.Factory> .Create <IEndpointStrategy>(clusterConfig.Endpoints.Strategy,
                                                                                                                         endpoints, snitch,
                                                                                                                         _logger, clusterConfig.Endpoints);

            IConnectionFactory connectionFactory = ServiceActivator <Transport.Factory> .Create <IConnectionFactory>(transportConfig.Type, transportConfig, keyspaceConfig, _logger,
                                                                                                                     _instrumentation);

            IPartitioner partitioner = ServiceActivator <Partitioner.Factory> .Create <IPartitioner>(clusterConfig.Partitioner);

            // create the cluster now
            ICluster cluster = ServiceActivator <Cluster.Factory> .Create <ICluster>(clusterConfig.Type, endpointsManager, _logger, connectionFactory,
                                                                                     recoveryService, partitioner, clusterConfig);

            IDiscoveryService discoveryService = ServiceActivator <Discovery.Factory> .Create <IDiscoveryService>(clusterConfig.Endpoints.Discovery.Type,
                                                                                                                  clusterConfig.Endpoints.Discovery,
                                                                                                                  _logger,
                                                                                                                  cluster);

            discoveryService.OnTopologyUpdate += endpointsManager.Update;
            cluster.OnClosed += discoveryService.SafeDispose;

            return(cluster);
        }
コード例 #29
0
        public void Configure(CassandraSharpConfig config)
        {
            config.CheckArgumentNotNull("config");

            lock (_lock)
            {
                if (null != _config)
                {
                    throw new InvalidOperationException("ClusterManager is already initialized");
                }

                _logger = ServiceActivator <Logger.Factory> .Create <ILogger>(config.Logger.Type, config.Logger);

                _recoveryService = ServiceActivator <Recovery.Factory> .Create <IRecoveryService>(config.Recovery.Type, config.Recovery, _logger);

                _instrumentation = ServiceActivator <Instrumentation.Factory> .Create <IInstrumentation>(config.Instrumentation.Type, config.Instrumentation);

                _config = config;
            }
        }
コード例 #30
0
        private async Task ResolvedInterceptorInvoker(IAsyncStreamReader <TRequest> requestStream, IServerStreamWriter <TResponse> responseStream, ServerCallContext resolvedContext)
        {
            GrpcActivatorHandle <TService> serviceHandle = default;

            try
            {
                serviceHandle = ServiceActivator.Create(resolvedContext.GetHttpContext().RequestServices);
                await _invoker(
                    serviceHandle.Instance,
                    requestStream,
                    responseStream,
                    resolvedContext);
            }
            finally
            {
                if (serviceHandle.Instance != null)
                {
                    await ServiceActivator.ReleaseAsync(serviceHandle);
                }
            }
        }