Class InMemoryOutboxStore<TPayload>
- Namespace
- PatternKit.Messaging.Reliability
- Assembly
- PatternKit.Core.dll
Thread-safe in-memory implementation of IOutboxStore<TPayload> for tests, demos, and single-process applications.
public sealed class InMemoryOutboxStore<TPayload> : IOutboxStore<TPayload>
Type Parameters
TPayloadThe outbox message payload type.
- Inheritance
-
InMemoryOutboxStore<TPayload>
- Implements
-
IOutboxStore<TPayload>
- Inherited Members
Properties
Records
All records currently held in the store.
public IReadOnlyList<OutboxMessage<TPayload>> Records { get; }
Property Value
- IReadOnlyList<OutboxMessage<TPayload>>
Methods
EnqueueAsync(Message<TPayload>, string?, DateTimeOffset?, CancellationToken)
Adds a message to the outbox and returns the stored record.
public ValueTask<OutboxMessage<TPayload>> EnqueueAsync(Message<TPayload> message, string? id = null, DateTimeOffset? createdAt = null, CancellationToken cancellationToken = default)
Parameters
messageMessage<TPayload>idstringcreatedAtDateTimeOffset?cancellationTokenCancellationToken
Returns
- ValueTask<OutboxMessage<TPayload>>
MarkDispatchedAsync(string, DateTimeOffset, CancellationToken)
Marks a message as successfully dispatched.
public ValueTask MarkDispatchedAsync(string id, DateTimeOffset dispatchedAt, CancellationToken cancellationToken = default)
Parameters
idstringdispatchedAtDateTimeOffsetcancellationTokenCancellationToken
Returns
MarkFailedAsync(string, string?, CancellationToken)
Records a failed dispatch attempt for a message.
public ValueTask MarkFailedAsync(string id, string? error, CancellationToken cancellationToken = default)
Parameters
idstringerrorstringcancellationTokenCancellationToken
Returns
SnapshotPendingAsync(CancellationToken)
Returns all messages that have not yet been dispatched.
public ValueTask<IReadOnlyList<OutboxMessage<TPayload>>> SnapshotPendingAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
- ValueTask<IReadOnlyList<OutboxMessage<TPayload>>>