Class IdentityEventStore
The flat SQL of the event pipeline: the audit row and the delivery outbox
(identity_delivery_outbox). No statement lives in a processor; each one is a section of an
embedded per-dialect resource (sql/events/{pg,mssql,sqlite}.sql), run through redb's
so it shares the connection and transaction handling of redb.
Every time the outbox stores or compares comes from the database clock, inside the statement: two
nodes whose clocks disagree still agree on who holds a lease and on what is due.
public sealed class IdentityEventStore
Inheritance
Methods
CleanupAsync(TimeSpan, TimeSpan, int, CancellationToken)
Deletes one batch of finished rows past their retention (delivered after
public Task<int> CleanupAsync(TimeSpan delivered, TimeSpan finished, int batch, CancellationToken ct = default)
DueAsync(int, CancellationToken)
Pending rows that are due and not leased, oldest first, at most limit.
public Task<List<OutboxRow>> DueAsync(int limit, CancellationToken ct = default)
EnsureOutboxAsync(CancellationToken)
Creates the outbox table and its indexes when they are missing; idempotent.
public Task EnsureOutboxAsync(CancellationToken ct = default)
InsertAuditAsync(object[], CancellationToken)
One row of identity_audit_log.
public Task InsertAuditAsync(object[] values, CancellationToken ct = default)
InsertOutboxAsync(IReadOnlyList<OutboxEntry>, CancellationToken)
The outbox rows of one event, all or none: one transaction of their own. The audit row is not in
public Task InsertOutboxAsync(IReadOnlyList<OutboxEntry> entries, CancellationToken ct = default)
ListAsync(string, string, string, int, int, CancellationToken)
Rows newest first; an empty filter means any value.
public Task<List<OutboxDelivery>> ListAsync(string status, string kind, string destination, int limit, int offset, CancellationToken ct = default)
MarkCancelledAsync(long, string, string, CancellationToken)
The destination went away before delivery (subscription deleted or disabled, audit target
public Task MarkCancelledAsync(long id, string node, string reason, CancellationToken ct = default)
MarkDeliveredAsync(long, string, CancellationToken)
public Task MarkDeliveredAsync(long id, string node, CancellationToken ct = default)
MarkFailedAsync(long, string, string, CancellationToken)
public Task MarkFailedAsync(long id, string node, string error, CancellationToken ct = default)
RedeliverAsync(long, CancellationToken)
Makes a failed or cancelled row due again with its attempts reset; true when the row was one of
public Task<bool> RedeliverAsync(long id, CancellationToken ct = default)
ScheduleRetryAsync(long, string, int, string, CancellationToken)
public Task ScheduleRetryAsync(long id, string node, int delayMilliseconds, string error, CancellationToken ct = default)
StatsAsync(CancellationToken)
The pending rows and the age of the oldest of them, by the database clock.
public Task<OutboxStats> StatsAsync(CancellationToken ct = default)
StatusOfAsync(long, CancellationToken)
The status of one row, or null when there is no such row.
public Task<string?> StatusOfAsync(long id, CancellationToken ct = default)
TryClaimAsync(long, int, int, string, CancellationToken)
Takes a lease on one row for leaseSeconds; true when this node holds it. The row must
public Task<bool> TryClaimAsync(long id, int attempts, int leaseSeconds, string node, CancellationToken ct = default)