mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 11:16:38 +00:00
parallel processing for routes and regions
This commit is contained in:
@@ -79,20 +79,22 @@ public class RegionService : IRegionService
|
||||
|
||||
public async Task ProcessRegionAsync(Guid id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
_logger.LogInformation("Processing region {RegionId}", id);
|
||||
_logger.LogInformation("Processing region {RegionId} - START", id);
|
||||
var startTime = DateTime.UtcNow;
|
||||
|
||||
var region = await _regionRepository.GetByIdAsync(id);
|
||||
if (region == null)
|
||||
{
|
||||
_logger.LogWarning("Region {RegionId} not found", id);
|
||||
_logger.LogWarning("Region {RegionId} not found in database", id);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Region {RegionId}: Updating status to 'processing' (was: {OldStatus})", id, region.Status);
|
||||
region.Status = "processing";
|
||||
region.UpdatedAt = DateTime.UtcNow;
|
||||
await _regionRepository.UpdateAsync(region);
|
||||
|
||||
_logger.LogInformation("Region {RegionId}: Creating timeout CTS (5 minutes)", id);
|
||||
using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(5));
|
||||
using var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
|
||||
|
||||
@@ -103,32 +105,33 @@ public class RegionService : IRegionService
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Downloading tiles for region {RegionId} at ({Lat}, {Lon}) size {Size}m zoom {Zoom}",
|
||||
_logger.LogInformation("Region {RegionId}: Step 1 - Starting download for location ({Lat}, {Lon}) size {Size}m zoom {Zoom}",
|
||||
id, region.Latitude, region.Longitude, region.SizeMeters, region.ZoomLevel);
|
||||
|
||||
var processingStartTime = DateTime.UtcNow;
|
||||
|
||||
_logger.LogInformation("Checking for existing tiles in region {RegionId}", id);
|
||||
_logger.LogInformation("Region {RegionId}: Step 2 - Checking for existing tiles", id);
|
||||
var tilesBeforeDownload = await _tileService.GetTilesByRegionAsync(
|
||||
region.Latitude,
|
||||
region.Longitude,
|
||||
region.SizeMeters,
|
||||
region.ZoomLevel);
|
||||
var existingTileIds = new HashSet<Guid>(tilesBeforeDownload.Select(t => t.Id));
|
||||
_logger.LogInformation("Found {Count} existing tiles for region {RegionId}", existingTileIds.Count, id);
|
||||
_logger.LogInformation("Region {RegionId}: Step 3 - Found {Count} existing tiles", id, existingTileIds.Count);
|
||||
|
||||
_logger.LogInformation("Starting tile download for region {RegionId}", id);
|
||||
_logger.LogInformation("Region {RegionId}: Step 4 - Calling DownloadAndStoreTilesAsync", id);
|
||||
tiles = await _tileService.DownloadAndStoreTilesAsync(
|
||||
region.Latitude,
|
||||
region.Longitude,
|
||||
region.SizeMeters,
|
||||
region.ZoomLevel,
|
||||
linkedCts.Token);
|
||||
_logger.LogInformation("Region {RegionId}: Step 5 - DownloadAndStoreTilesAsync completed with {Count} tiles", id, tiles.Count);
|
||||
|
||||
tilesDownloaded = tiles.Count(t => !existingTileIds.Contains(t.Id));
|
||||
tilesReused = tiles.Count(t => existingTileIds.Contains(t.Id));
|
||||
|
||||
_logger.LogInformation("Region {RegionId}: Downloaded {Downloaded} tiles, Reused {Reused} tiles",
|
||||
_logger.LogInformation("Region {RegionId}: Step 6 - Downloaded {Downloaded} new tiles, Reused {Reused} existing tiles",
|
||||
id, tilesDownloaded, tilesReused);
|
||||
|
||||
var readyDir = _storageConfig.ReadyDirectory;
|
||||
|
||||
Reference in New Issue
Block a user