Skip to content

VolatileJournalStorage Methods

An in-memory, volatile implementation of IJournalStorage for non-durable use cases, such as development and testing.

AppendAsync(ReadOnlySequence<byte>, CancellationToken)

View source
public ValueTask AppendAsync(ReadOnlySequence<byte> segment, CancellationToken cancellationToken)
Appends the provided segment to the journal atomically.

Parameters

segmentReadOnlySequence<byte>
The encoded journal bytes to append. The storage provider must not retain this buffer after the returned task completes.
cancellationTokenCancellationToken
The cancellation token.

Returns

A System.Threading.Tasks.ValueTask representing the operation.

CreateIfNotExistsAsync(IReadOnlyDictionary<string, string>, CancellationToken)

View source
public ValueTask<bool> CreateIfNotExistsAsync(IReadOnlyDictionary<string, string>? metadata = null, CancellationToken cancellationToken = default(CancellationToken))
Creates this journal storage instance if it does not already exist.

Parameters

metadataIReadOnlyDictionary<string, string>
Initial caller-owned metadata properties.
cancellationTokenCancellationToken
The cancellation token.

Returns

true if storage was created; otherwise, false.

DeleteAsync(CancellationToken)

View source
public ValueTask DeleteAsync(CancellationToken cancellationToken)
Deletes the journal atomically.

Parameters

cancellationTokenCancellationToken
The cancellation token.

Returns

A System.Threading.Tasks.ValueTask representing the operation.

GetMetadataAsync(CancellationToken)

View source
public ValueTask<IJournalMetadata?> GetMetadataAsync(CancellationToken cancellationToken = default(CancellationToken))
Gets metadata for this journal storage instance.

Parameters

cancellationTokenCancellationToken
The cancellation token.

Returns

The metadata, or null if the storage instance does not exist.

ReadAsync(IJournalStorageConsumer, CancellationToken)

View source
public ValueTask ReadAsync(IJournalStorageConsumer consumer, CancellationToken cancellationToken)
Reads all journal data belonging to this instance and sends it to consumer.

Parameters

consumerIJournalStorageConsumer
The consumer of ordered raw journal data. Chunk boundaries are not journal-entry boundaries.
cancellationTokenCancellationToken
The cancellation token.

Returns

A System.Threading.Tasks.ValueTask representing the operation.

ReplaceAsync(ReadOnlySequence<byte>, CancellationToken)

View source
public ValueTask ReplaceAsync(ReadOnlySequence<byte> snapshot, CancellationToken cancellationToken)
Replaces the journal with the provided value atomically.

Parameters

snapshotReadOnlySequence<byte>
The encoded journal bytes to write. The storage provider must not retain this buffer after the returned task completes.
cancellationTokenCancellationToken
The cancellation token.

Returns

A System.Threading.Tasks.ValueTask representing the operation.

UpdateMetadataAsync(IReadOnlyDictionary<string, string>, IEnumerable<string>, string?, CancellationToken)

View source
public ValueTask<IJournalMetadata?> UpdateMetadataAsync(IReadOnlyDictionary<string, string>? set = null, IEnumerable<string>? remove = null, string? expectedETag = null, CancellationToken cancellationToken = default(CancellationToken))
Conditionally updates caller-owned metadata properties.

Parameters

setIReadOnlyDictionary<string, string>
Metadata properties to set.
removeIEnumerable<string>
Metadata properties to remove.
expectedETagstring?
The expected metadata ETag, or null for an unconditional update.
cancellationTokenCancellationToken
The cancellation token.

Returns

The current metadata if the update was applied or made no changes; otherwise, null.