FlowableWorkflowClient implements IRegistratieVerlopenClient (acquire/complete the RegistratieVerlopen jobs) and CompleteDocumentWaitAsync (complete WachtOpDocumenten, best-effort). Wires the RegistratieVerlopenProcessor + hosted RegistratieVerlopenPump into the domain host and excludes the pump from mutation (like the other pumps). Fakes updated for the new IWorkflowClient member. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Big.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// The hosted polling loop of the document-timeout worker (S-10a, ADR-0017): on an interval it
|
|
/// resolves a scoped <see cref="RegistratieVerlopenProcessor"/> and asks it to drain the parked
|
|
/// <c>RegistratieVerlopen</c> jobs. A deliberately thin shell — all acquire/expire/complete logic
|
|
/// lives in the processor, which is unit-tested; this class only owns the timer, the per-tick scope,
|
|
/// and loop resilience. Structurally identical to <see cref="BeoordelingEscalatiePump"/>.
|
|
/// </summary>
|
|
public sealed class RegistratieVerlopenPump(
|
|
IServiceScopeFactory scopeFactory,
|
|
FlowableOptions options,
|
|
ILogger<RegistratieVerlopenPump> logger) : BackgroundService
|
|
{
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
while (!stoppingToken.IsCancellationRequested)
|
|
{
|
|
try
|
|
{
|
|
using var scope = scopeFactory.CreateScope();
|
|
var processor = scope.ServiceProvider.GetRequiredService<RegistratieVerlopenProcessor>();
|
|
await processor.PumpOnceAsync(options.MaxJobsPerPoll, stoppingToken);
|
|
}
|
|
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
|
|
{
|
|
break;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// A transient fault (e.g. Flowable briefly unreachable) must not kill the loop.
|
|
logger.LogError(ex, "RegistratieVerlopen job poll failed; retrying after the poll interval.");
|
|
}
|
|
|
|
try
|
|
{
|
|
await Task.Delay(options.PollInterval, stoppingToken);
|
|
}
|
|
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|