Exemplo n.º 1
0
        public void ConfigureServices(IServiceCollection services)
        {
            var idInfo = new IdentifyingInformation(
                "communications",
                "Comms.Reservation.Reminder.Policy",
                "*****@*****.**");

            var busOpts = new BusOptions()
                          .SetIdentifyingInformation(idInfo)
                          .SetLogger(EDALogger.Global)
                          .SetRegion(Region.RS);

            busOpts.SetDeployEnvironment(DeployEnvironment.PP);
            bool connected = false;
            int  attempt   = 1;

            while (!connected && attempt < 5)
            {
                try
                {
                    services.AddSingleton <IBus>(new Bus(busOpts));
                    connected = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Error contacting EDA ({e.Message})");
                    Console.WriteLine(e);
                    attempt++;
                    Thread.Sleep(TimeSpan.FromSeconds(attempt * 10));
                }
            }

            if (!connected)
            {
                throw new ApplicationException("Could not connect to EDA (I did try a few times but it would not answer)");
            }

            services.AddSingleton <IEdaSource, EdaSource>();

            services.AddSingleton <IConsumeFromEda, ReservationConsumer>();

            services.AddSingleton <IHostedService, GuestGroupChat>();
        }