mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 12:01:15 +00:00
de4d4fa760
AZ-351: Resolve ILogger<DatabaseMigrator> directly from DI in Program.cs instead of casting ILogger<Program> (which always returned null). Migrator now logs through Serilog at startup. AZ-352: Drop empty catch in RouteProcessingService.ExtractTileCoordinatesFromFilename. Convert the method from private static to internal instance so it can use the existing _logger (per coderule: side-effecting code must not be static). Add typed null-guard via ArgumentNullException.ThrowIfNull so unexpected exceptions propagate. Adds InternalsVisibleTo on the RouteManagement csproj for SatelliteProvider.Tests, plus 4 unit tests in RouteProcessingServiceTests.cs covering AC-1 (valid / malformed / non-numeric) and AC-2 (null path propagation). AZ-363: Delete _totalEnqueued / _totalDequeued fields and the two non-atomic ++ writes in RegionRequestQueue. Fields were write-only dead code and a thread-safety hazard. Tests: 44/44 unit + 5/5 smoke (scripts/run-tests.sh --smoke). Code review verdict: PASS, 0 findings, 0 auto-fix attempts. Batch report: _docs/03_implementation/batch_07_report.md. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Threading.Channels;
|
|
using Microsoft.Extensions.Logging;
|
|
using SatelliteProvider.Common.DTO;
|
|
using SatelliteProvider.Common.Interfaces;
|
|
|
|
namespace SatelliteProvider.Services.RegionProcessing;
|
|
|
|
public class RegionRequestQueue : IRegionRequestQueue
|
|
{
|
|
private readonly Channel<RegionRequest> _queue;
|
|
private readonly ILogger<RegionRequestQueue>? _logger;
|
|
|
|
public RegionRequestQueue(int capacity, ILogger<RegionRequestQueue>? logger = null)
|
|
{
|
|
var options = new BoundedChannelOptions(capacity)
|
|
{
|
|
FullMode = BoundedChannelFullMode.Wait
|
|
};
|
|
_queue = Channel.CreateBounded<RegionRequest>(options);
|
|
_logger = logger;
|
|
_logger?.LogInformation("RegionRequestQueue created with capacity {Capacity}", capacity);
|
|
}
|
|
|
|
public async ValueTask EnqueueAsync(RegionRequest request, CancellationToken cancellationToken = default)
|
|
{
|
|
await _queue.Writer.WriteAsync(request, cancellationToken);
|
|
}
|
|
|
|
public async ValueTask<RegionRequest?> DequeueAsync(CancellationToken cancellationToken = default)
|
|
{
|
|
if (await _queue.Reader.WaitToReadAsync(cancellationToken))
|
|
{
|
|
if (_queue.Reader.TryRead(out var request))
|
|
{
|
|
return request;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public int Count => _queue.Reader.Count;
|
|
}
|
|
|