public async Task StartAsync()
        {
            await _log.WriteInfoAsync(nameof(StartAsync), "", "Deserializing persistence queue async...");

            var tasks = new List <Task>
            {
                _snapshotSerializer.DeserializeAsync(_persistenceQueue, _persistenceQueueSnapshotRepository)
            };

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Initializing cache from the history async...");

            tasks.Add(_cacheInitalizationService.InitializeCacheAsync());

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Waiting for async tasks...");

            await Task.WhenAll(tasks);

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Starting persistence queue...");

            _persistenceQueue.Start();

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Starting persistence manager...");

            _persistenceManager.Start();

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Starting candles subscriber...");

            _candlesSubscriber.Start();

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Started up");
        }
        public async Task StartAsync()
        {
            await _log.WriteInfoAsync(nameof(StartAsync), "", "Deserializing persistence queue async...");

            var tasks = new List <Task>
            {
                _snapshotSerializer.DeserializeAsync(_persistenceQueue, _persistenceQueueSnapshotRepository)
            };

            if (!_migrationEnabled)
            {
                await _log.WriteInfoAsync(nameof(StartAsync), "", "Initializing cache from the history async...");

                tasks.Add(_cacheInitalizationService.InitializeCacheAsync());
            }

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Waiting for async tasks...");

            await Task.WhenAll(tasks);

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Starting persistence queue...");

            _persistenceQueue.Start();

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Starting persistence manager...");

            _persistenceManager.Start();

            // We can not combine it with the previous if(!_migration...) due to launch order importance.
            if (!_migrationEnabled)
            {
                await _log.WriteInfoAsync(nameof(StartAsync), "", "Starting candles subscriber...");

                _candlesSubscriber.Start();
            }

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Starting cqrs engine subscribers...");

            _cqrsEngine.StartSubscribers();

            await _log.WriteInfoAsync(nameof(StartAsync), "", "Started up");
        }
예제 #3
0
        public async Task StartAsync()
        {
            _log.Info(nameof(StartAsync), "Deserializing persistence queue async...");

            var tasks = new List <Task>
            {
                _snapshotSerializer.DeserializeAsync(_persistenceQueue, _persistenceQueueSnapshotRepository)
            };

            if (!_migrationEnabled)
            {
                _log.Info(nameof(StartAsync), "Initializing cache from the history async...");

                tasks.Add(_cacheInitalizationService.InitializeCacheAsync());
            }

            _log.Info(nameof(StartAsync), "Waiting for async tasks...");

            await Task.WhenAll(tasks);

            _log.Info(nameof(StartAsync), "Starting persistence queue...");

            _persistenceQueue.Start();

            _log.Info(nameof(StartAsync), "Starting persistence manager...");

            _persistenceManager.Start();

            // We can not combine it with the previous if(!_migration...) due to launch order importance.
            if (!_migrationEnabled)
            {
                _log.Info(nameof(StartAsync), "Starting candles subscriber...");

                _candlesSubscriber.Start();

                _cacheCaretaker.Start();  // Should go after cache initialization has finished working && if no migration
            }

            _log.Info(nameof(StartAsync), "Started up");
        }