Ejemplo n.º 1
0
        public async Task Handler(SQSEvent evnt, ILambdaContext context)
        {
            Log.Logger = Builders.Log();

            try
            {
                var host = Builders.Host(Messaging.SQS, Cache.Redis);

                var application = host.Build();

                using (application)
                {
                    var orchestrator = application.Services.GetService <IOrchestratorService>();

                    foreach (var record in evnt.Records)
                    {
                        var message = JsonConvert.DeserializeObject <NewUserEvent>(record.Body);

                        await orchestrator.OrchestrateAsync(message);
                    }
                }
            }
            finally
            {
                Log.CloseAndFlush();
            }

            await Task.CompletedTask;
        }
Ejemplo n.º 2
0
        public static async Task Main(string[] args)
        {
            Log.Logger = Builders.Log();

            try
            {
                var host = Builders.Host(Messaging.RabbitMQ, Cache.Redis);

                host.ConfigureServices((context, services) =>
                {
                    services.AddHostedService <Host>();
                });

                var application = host.Build();

                using (application)
                {
                    await application.StartAsync();

                    await application.WaitForShutdownAsync();
                }
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }