Пример #1
0
        public async Task HandleAsync(IServiceOnceApiConvert convert, ChannelType channelType)
        {
            try
            {
                var contractOptions    = _serviceProvider.GetRequiredService <IOptions <ContractOptions> >();
                var rpcContextAccessor = _serviceProvider.GetRequiredService <IActionExecutingContextAccessor>();

                using IServiceScope scope           = _serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope();
                GlobalServiceProvider.Provider      = _serviceProvider;
                GlobalServiceProvider.ScopeProvider = scope.ServiceProvider;
                var instances    = scope.ServiceProvider.GetContractInstances(contractOptions.Value);
                var onceTransfer = new ServiceOnceTransfer(instances,
                                                           scope.ServiceProvider,
                                                           convert,
                                                           _middlewareBuilder,
                                                           rpcContextAccessor,
                                                           channelType,
                                                           _logger);
                await onceTransfer.StartAsync();

                await onceTransfer.HandleRequestAsync();
            }
            catch (Exception e)
            {
                _logger.LogCritical(e, null);
                throw;
            }
        }
Пример #2
0
        public async Task HandleAsync(IConnection connection)
        {
            var t = new ServiceOnceTransfer(connection, _middlewareRegister, _instances);

            t.Start();
            await t.HandleRequestAsync();
        }