public async Task StartAsync() { _startTime.Start(); long pagingTokenLong = await GetCurrentCursorFromDatabase("operation"); string pagingToken = pagingTokenLong.ToString(); _logger.LogDebug($"Starting page token is {pagingToken}"); _operationsRequestBuilder = _server.Operations.Cursor(pagingToken).Limit(200); _eventSource = _operationsRequestBuilder.Stream((sender, response) => { _operationsToHandleQueue.Enqueue(response); if (_sendQueueInfoMessageTime == null || DateTime.Now >= _sendQueueInfoMessageTime) { _sendQueueInfoMessageTime = DateTime.Now.AddMinutes(1); _logger.LogInformation($"Total operations parsed {_totalRequest}"); _logger.LogInformation($"Currently queued operations {_operationsToHandleQueue.Count}"); _logger.LogInformation($"Current paging token '{response.PagingToken}"); var rpm = _startTime.Elapsed.Minutes > 0 ? $"{_totalRequest / (int)_startTime.Elapsed.TotalMinutes} request handled per minute ({(int)_startTime.Elapsed.TotalMinutes}m)" : ""; if (!string.IsNullOrEmpty(rpm)) { _logger.LogInformation($"{rpm}"); } } }); _eventSource.Error += (sender, args) => { _logger.LogError(args.Exception.Message); }; _eventSource.Connect().Wait(); }
public async void StartAsync() { try { // _databaseQueueService.StartAsync(); await _stellarService.StartAsync(); _logger.LogInformation("Startup service has completed"); } catch (Exception e) { _logger.LogError(e.Message, e); } }