Esempio n. 1
0
        public async Task StopAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Stopping");
            await _host.StopAsync();

            _logger.LogInformation("Stopped");
        }
Esempio n. 2
0
        public async Task FunctionHandlerAsync(TInput input, ILambdaContext context)
        {
            try
            {
                await _busHost.StartAsync().ConfigureAwait(false);

                using (var scope = ServiceProvider.CreateScope())
                {
                    var handler = scope.ServiceProvider.GetService <Kralizek.Lambda.IEventHandler <TInput> >();

                    if (handler == null)
                    {
                        Logger.LogCritical($"No IEventHandler<{typeof(TInput).Name}> could be found.");
                        throw new InvalidOperationException($"No IEventHandler<{typeof(TInput).Name}> could be found.");
                    }

                    Logger.LogInformation("Invoking handler");
                    await handler.HandleAsync(input, context).ConfigureAwait(false);
                }
            }
            finally
            {
                await _busHost.StopAsync().ConfigureAwait(false);
            }
        }
Esempio n. 3
0
        public virtual bool OnStop(IBusHost host, HostControl control)
        {
            host.StopAsync().GetAwaiter().GetResult();

            return(true);
        }