Interface ICommandIntentStore
- Namespace
- Stratara.Abstractions.Outbox
- Assembly
- Stratara.Abstractions.dll
Where an execution model that records every accepted command keeps the bookkeeping of its resume: the command with the aggregate it names and whether it is heavy, how often it has been handed over, when it was last handed over, the failure of its last attempt, and whether it has been kept for an operator. The resume is bounded only as far as an implementation persists these; an execution model that requires this port fails at start when none is registered, rather than resuming without a bound.
public interface ICommandIntentStore
- Extension Methods
Methods
GetDueAsync(DateTimeOffset, int, CancellationToken)
Returns the recorded commands due for resumption, oldest first: not kept, recorded at or before
handedOverBefore, and not handed over since then.
Task<IReadOnlyList<RecordedIntent>> GetDueAsync(DateTimeOffset handedOverBefore, int batchSize, CancellationToken cancellationToken)
Parameters
handedOverBeforeDateTimeOffsetThe moment a command's last hand-over must precede for it to be due.
batchSizeintThe maximum number of commands to return.
cancellationTokenCancellationTokenCancels the operation.
Returns
- Task<IReadOnlyList<RecordedIntent>>
The due commands, or an empty list.
KeepAsync(Guid, DateTimeOffset, CancellationToken)
Keeps the command for an operator; a kept command is not due until an operator returns it.
Task KeepAsync(Guid intentId, DateTimeOffset now, CancellationToken cancellationToken)
Parameters
intentIdGuidThe recorded command.
nowDateTimeOffsetThe time it was kept.
cancellationTokenCancellationTokenCancels the operation.
Returns
- Task
A task that completes when the command is kept.
RecordAsync(Guid, CommandEnvelope, Guid?, bool, CancellationToken)
Records an accepted command durably, with the aggregate it names and whether it is heavy.
Task RecordAsync(Guid intentId, CommandEnvelope envelope, Guid? aggregateId, bool heavy, CancellationToken cancellationToken)
Parameters
intentIdGuidThe identity of the recorded command.
envelopeCommandEnvelopeThe serialised command and the session it was dispatched under.
aggregateIdGuid?The aggregate the command names, or null for a command that names none.
heavyboolWhether the command declared itself long-running.
cancellationTokenCancellationTokenCancels the operation.
Returns
- Task
A task that completes when the command is durable.
RecordFailureAsync(Guid, string, CancellationToken)
Records the failure of the command's latest attempt.
Task RecordFailureAsync(Guid intentId, string failure, CancellationToken cancellationToken)
Parameters
intentIdGuidThe recorded command.
failurestringA description of the failure.
cancellationTokenCancellationTokenCancels the operation.
Returns
- Task
A task that completes when the failure is durable.
RenewAsync(Guid, DateTimeOffset, CancellationToken)
Renews the hand-over of a command whose handler is running, so it does not become due again while it runs.
Task RenewAsync(Guid intentId, DateTimeOffset now, CancellationToken cancellationToken)
Parameters
intentIdGuidThe recorded command.
nowDateTimeOffsetThe time of the renewal.
cancellationTokenCancellationTokenCancels the operation.
Returns
- Task
A task that completes when the renewal is durable.
TryClaimAsync(Guid, DateTimeOffset?, DateTimeOffset, CancellationToken)
Claims a hand-over of a due command: stamps now as its last hand-over and
increments its attempt count, only if it is not kept and its last hand-over is still
expectedLastHandedOverAt.
Task<bool> TryClaimAsync(Guid intentId, DateTimeOffset? expectedLastHandedOverAt, DateTimeOffset now, CancellationToken cancellationToken)
Parameters
intentIdGuidThe recorded command.
expectedLastHandedOverAtDateTimeOffset?The last hand-over read with the command, or null for one never handed over.
nowDateTimeOffsetThe time of this hand-over.
cancellationTokenCancellationTokenCancels the operation.