Failing unit + acceptance tests for the Event Subscriber's NotificationProjector: a zaken/zaak/create notification yields one INGEDIEND projection row, duplicate deliveries collapse to one row, non-zaak/non-create notifications are ignored, and a rebuild repopulates the projection from the durable notification log (PRD §8.4). The projector is a no-op stub so the tests compile and fail on the assertions; the implementation follows in the green commit. The notification log doubles as the idempotency guard and rebuild source so a rebuild needs no OpenZaak access (§8.1). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
38 lines
1.9 KiB
C#
38 lines
1.9 KiB
C#
namespace EventSubscriber.Application;
|
|
|
|
/// <summary>
|
|
/// The durable log of notifications the subscriber has accepted. It is both the idempotency
|
|
/// guard (a replayed notification is recognised and dropped) and the rebuild source: the
|
|
/// projection is a derived artefact (PRD §8.4) regenerated by replaying this log, so a rebuild
|
|
/// needs no access to OpenZaak (CLAUDE.md §8.1). Implemented in Infrastructure over Postgres.
|
|
/// </summary>
|
|
public interface INotificationLog
|
|
{
|
|
/// <summary>
|
|
/// Record a notification. Returns <c>true</c> if it was newly recorded, <c>false</c> if an
|
|
/// entry with the same key already existed (a duplicate delivery). Must be atomic so that
|
|
/// concurrent duplicate deliveries cannot both observe <c>true</c>.
|
|
/// </summary>
|
|
Task<bool> TryRecordAsync(RecordedNotification notification, CancellationToken ct = default);
|
|
|
|
/// <summary>Every accepted notification, for rebuilding the projection.</summary>
|
|
Task<IReadOnlyList<RecordedNotification>> AllAsync(CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>A notification that has been accepted, retaining what a rebuild needs to recompute its projection row.</summary>
|
|
public sealed record RecordedNotification(string Key, string Actie, string ZaakId);
|
|
|
|
/// <summary>The read projection store. Owned by the projection bounded context (ADR-0008); the
|
|
/// subscriber writes to it and the projection-api reads it.</summary>
|
|
public interface IProjectionStore
|
|
{
|
|
/// <summary>Insert or update the row for <see cref="RegisterEntry.Id"/>. Idempotent on the id.</summary>
|
|
Task UpsertAsync(RegisterEntry entry, CancellationToken ct = default);
|
|
|
|
/// <summary>Remove every row — the first step of a rebuild.</summary>
|
|
Task ClearAsync(CancellationToken ct = default);
|
|
|
|
/// <summary>Every projection row (used by tests and the rebuild verification).</summary>
|
|
Task<IReadOnlyList<RegisterEntry>> AllAsync(CancellationToken ct = default);
|
|
}
|