test(workers): prove clock and restart safety
CI and Deploy / test (pull_request) Successful in 5m13s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-15 20:18:02 +02:00
parent a08ba9b45d
commit dbf28b97ce
7 changed files with 124 additions and 36 deletions
@@ -11,7 +11,8 @@ public sealed class JobEnrichmentHostedService(
BackgroundTenantRunner tenants,
IConfiguration configuration,
ILogger<JobEnrichmentHostedService> logger,
IStartupReadiness startupReadiness) : BackgroundService
IStartupReadiness startupReadiness,
TimeProvider timeProvider) : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
@@ -22,11 +23,11 @@ public sealed class JobEnrichmentHostedService(
return;
}
await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken);
await Task.Delay(TimeSpan.FromSeconds(10), timeProvider, stoppingToken);
while (!stoppingToken.IsCancellationRequested)
{
await RunOnceAsync(stoppingToken);
await Task.Delay(TimeSpan.FromMinutes(10), stoppingToken);
await Task.Delay(TimeSpan.FromMinutes(10), timeProvider, stoppingToken);
}
}