Files
Oleksandr Bezdieniezhnykh 534ab41b8e
ci/woodpecker/push/01-test Pipeline was successful
ci/woodpecker/push/02-build-push Pipeline was successful
[AZ-372] Apply dotnet format whitespace cleanup; archive batch 22
Pure whitespace-only cleanup uncovered by the new format gate from the
previous commit. Verified via `git diff -w --stat`: only 4 files differ
when whitespace is ignored, and those differ only by the BOM byte.

Cleanup kinds applied across 22 source files:
- BOM removal (MapConfig.cs, SatTile.cs, GeoUtils.cs,
  IntegrationTests/Program.cs)
- CRLF -> LF (IntegrationTests/Program.cs)
- Trailing whitespace on blank lines (Common, Api, DataAccess,
  IntegrationTests, Services.RegionProcessing,
  Services.TileDownloader)
- Final newline added (RoutePoint.cs, GeoPoint.cs, others)

After this commit `dotnet format whitespace SatelliteProvider.sln
--verify-no-changes` exits 0; AC-1 is enforceable from `scripts/
run-tests.sh` going forward.

Also lands the batch 22 report, code-review report
(PASS_WITH_WARNINGS, 2 Low findings — both deferred per spec),
dependency-table status update (AZ-372 -> Done (In Testing)), task
archive (todo/ -> done/), and autodev state update.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 04:43:08 +03:00

76 lines
2.3 KiB
C#

using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using SatelliteProvider.Common.Configs;
using SatelliteProvider.Common.Interfaces;
namespace SatelliteProvider.Services.RegionProcessing;
public class RegionProcessingService : BackgroundService
{
private readonly IRegionRequestQueue _queue;
private readonly IRegionService _regionService;
private readonly ProcessingConfig _processingConfig;
private readonly ILogger<RegionProcessingService> _logger;
public RegionProcessingService(
IRegionRequestQueue queue,
IRegionService regionService,
IOptions<ProcessingConfig> processingConfig,
ILogger<RegionProcessingService> logger)
{
_queue = queue;
_regionService = regionService;
_processingConfig = processingConfig.Value;
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_logger.LogInformation("Region Processing Service started with {MaxConcurrent} parallel workers",
_processingConfig.MaxConcurrentRegions);
var workers = new List<Task>();
for (int i = 0; i < _processingConfig.MaxConcurrentRegions; i++)
{
var workerId = i + 1;
workers.Add(ProcessRegionWorkerAsync(workerId, stoppingToken));
}
await Task.WhenAll(workers);
_logger.LogInformation("Region Processing Service stopped");
}
private async Task ProcessRegionWorkerAsync(int workerId, CancellationToken stoppingToken)
{
if (workerId > 1)
{
var startupDelay = Random.Shared.Next(100, 500);
await Task.Delay(startupDelay, stoppingToken);
}
while (!stoppingToken.IsCancellationRequested)
{
try
{
var request = await _queue.DequeueAsync(stoppingToken);
if (request != null)
{
await _regionService.ProcessRegionAsync(request.Id, stoppingToken);
}
}
catch (OperationCanceledException)
{
break;
}
catch (Exception ex)
{
_logger.LogError(ex, "Worker {WorkerId}: Error processing region request", workerId);
}
}
}
}