Add resilient Azure offline transcription backlog
PR and Push Build/Test / build-and-test (push) Successful in 18m41s

This commit is contained in:
2026-06-15 17:26:34 +02:00
parent b22754ce5d
commit b774ccc375
35 changed files with 2456 additions and 198 deletions
@@ -0,0 +1,53 @@
namespace MeetingAssistant.Recording;
public sealed class OfflineTranscriptionBacklogHostedService : BackgroundService
{
private static readonly TimeSpan RetryDelay = TimeSpan.FromMinutes(1);
private readonly OfflineTranscriptionBacklogProcessor processor;
private readonly ILogger<OfflineTranscriptionBacklogHostedService> logger;
public OfflineTranscriptionBacklogHostedService(
OfflineTranscriptionBacklogProcessor processor,
ILogger<OfflineTranscriptionBacklogHostedService> logger)
{
this.processor = processor;
this.logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
try
{
var processed = await processor.ProcessPendingAsync(stoppingToken);
if (processed > 0)
{
logger.LogInformation(
"Processed {ProcessedCount} offline transcription backlog item(s)",
processed);
}
}
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
{
return;
}
catch (Exception exception)
{
logger.LogWarning(
exception,
"Offline transcription backlog processing failed; it will be retried later");
}
try
{
await Task.Delay(RetryDelay, stoppingToken);
}
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
{
return;
}
}
}
}