Пример #1
0
        protected virtual void OnInitialised()
        {
            var seedNode = Config.SeedNode;

            if (!string.Equals(Identity.HostAndPort, seedNode))
            {
                var min     = Config.JoinSettings.JoinMinTimeout;
                var max     = Config.JoinSettings.JoinMaxTimeout;
                var timeout = Config.Random.Next(min, max);

                Log($"Join Timeout {timeout} ms");

                var dueTime = ExpiryCalculator.CalcExpiry(timeout);
                ActionScheduler.ScheduleAction(dueTime, null, _ => { CommunicationManager.SendInternal(new InitJoin()); });
            }
        }
Пример #2
0
        public CovidDataProvider(ActionScheduler actionScheduler,
                                 ILogger <CovidDataProvider> logger,
                                 CovidDataDbContext dbContext,
                                 IConfiguration configuration)
        {
            _actionScheduler = actionScheduler;
            _logger          = logger;
            _dbContext       = dbContext;
            _configuration   = configuration;

            // ReSharper disable StringLiteralTypo
            _healthZones = new List <HealthZone>
            {
                new HealthZone("Moncton", 1),
                new HealthZone("Saint John", 2),
                new HealthZone("Fredericton", 3),
                new HealthZone("Edmundston", 4),
                new HealthZone("Campbellton", 5),
                new HealthZone("Bathurst", 6),
                new HealthZone("Miramichi", 7)
            };
            // ReSharper restore StringLiteralTypo

            _zonesDailyInfo         = new List <ZoneDailyInfo>();
            _provincePastInfo       = new List <ProvincePastInfo>();
            _zonesRecoveryPhaseInfo = new List <ZoneRecoveryPhaseInfo>();

            _dataUpdateTasks = new List <Func <DataUpdateCallback> >();

            _actionScheduler.ScheduleAction(DataQueryActionKey, _configuration["CovidQuerySchedule"], QueryUntilDataUpdates);

            RunOnDataUpdated(() => RecordUpdateToDatabase);

            // Get data now
            Task.Run(() => UpdateData(true));
        }