This commit is contained in:
Anton Martynenko
2025-11-19 18:27:35 +01:00
parent 48ebad0609
commit 9048a7b3ec
6 changed files with 56 additions and 54 deletions
@@ -47,13 +47,9 @@ public class RegionProcessingService : BackgroundService
if (workerId > 1)
{
var startupDelay = Random.Shared.Next(100, 500);
_logger.LogInformation("Region worker {WorkerId} starting with {Delay}ms delay to reduce contention",
workerId, startupDelay);
await Task.Delay(startupDelay, stoppingToken);
}
_logger.LogInformation("Region worker {WorkerId} started", workerId);
while (!stoppingToken.IsCancellationRequested)
{
try
@@ -62,13 +58,7 @@ public class RegionProcessingService : BackgroundService
if (request != null)
{
_logger.LogInformation("Worker {WorkerId}: Dequeued region request {RegionId}",
workerId, request.Id);
await _regionService.ProcessRegionAsync(request.Id, stoppingToken);
_logger.LogInformation("Worker {WorkerId}: Completed region {RegionId}",
workerId, request.Id);
}
}
catch (OperationCanceledException)
@@ -80,8 +70,6 @@ public class RegionProcessingService : BackgroundService
_logger.LogError(ex, "Worker {WorkerId}: Error processing region request", workerId);
}
}
_logger.LogInformation("Region worker {WorkerId} stopped", workerId);
}
}