Skip to main content
Table of Contents

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

handedOverBefore DateTimeOffset

The moment a command's last hand-over must precede for it to be due.

batchSize int

The maximum number of commands to return.

cancellationToken CancellationToken

Cancels 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

intentId Guid

The recorded command.

now DateTimeOffset

The time it was kept.

cancellationToken CancellationToken

Cancels 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

intentId Guid

The identity of the recorded command.

envelope CommandEnvelope

The serialised command and the session it was dispatched under.

aggregateId Guid?

The aggregate the command names, or null for a command that names none.

heavy bool

Whether the command declared itself long-running.

cancellationToken CancellationToken

Cancels 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

intentId Guid

The recorded command.

failure string

A description of the failure.

cancellationToken CancellationToken

Cancels 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

intentId Guid

The recorded command.

now DateTimeOffset

The time of the renewal.

cancellationToken CancellationToken

Cancels 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

intentId Guid

The recorded command.

expectedLastHandedOverAt DateTimeOffset?

The last hand-over read with the command, or null for one never handed over.

now DateTimeOffset

The time of this hand-over.

cancellationToken CancellationToken

Cancels the operation.

Returns

Task<bool>

true when this call claimed the hand-over.