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

            _logger.LogInformation("Started");
        }
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 OnStart(IBusHost host, HostControl control)
        {
            host.StartAsync().GetAwaiter().GetResult();

            return(true);
        }