Exemple #1
0
        public async Task Process(WorkMessage message, CancellationToken cancellationToken)
        {
            var sw       = Stopwatch.StartNew();
            var response = await _client.GetAsync(message.Url, cancellationToken);

            response.EnsureSuccessStatusCode();
            var content = await response.Content.ReadAsStringAsync(cancellationToken);

            sw.Stop();
            var total = (DateTime.UtcNow - message.Started).TotalMilliseconds;

            _logger.LogInformation("Content Size: {ContentLength}. Time Taken: {TimeTaken}. Worker:{WorkerId} Total:{TotalTime}", content.Length, sw.ElapsedMilliseconds, _id, total);
            if (message.LastInBatch)
            {
                _logger.LogInformation("Batch - Done");
            }
        }
Exemple #2
0
 public async Task SendWorkMessage(WorkMessage message)
 {
     _workQueue.Add(message);
     await Task.CompletedTask;
 }