using Big.Domain;
namespace Big.Application;
///
/// Handles one acquired OpenZaakAanmaken external-worker job (ADR-0009): load the registration
/// the job correlates to, open a zaak for it via the ACL (§8.1), attach the zaak to the aggregate, and
/// return the zaak URL so the caller can complete the Flowable job. Pure application logic over ports —
/// it knows nothing of Flowable; the polling loop that feeds it jobs lives in Infrastructure.
///
public sealed class OpenZaakWorker(IRegistrationStore store, IAclClient acl)
{
///
/// Process the job and return the URL of the (existing or newly opened) zaak. Idempotent: if the
/// registration already has a zaak — a job redelivered after its completion was lost — it returns
/// that zaak without opening a second one (§8.6, at-least-once delivery). An unknown registration
/// is an error: it throws, leaving the job un-completed for Flowable to redeliver.
///
public async Task HandleAsync(OpenZaakJob job, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(job);
// STUB (red): does not load, call the ACL, or attach.
await Task.CompletedTask;
return new Uri("about:blank");
}
}