Table of Contents

Method AppendAsync

Namespace
MailFathom.Application.Discovery.Streaming
Assembly
MailFathom.Application.dll

AppendAsync(DiscoveryRunId, DiscoveryRunEvent, DateTimeOffset, CancellationToken)

Writes one event into a run, giving it the next place in that run.

Task<long?> AppendAsync(DiscoveryRunId id, DiscoveryRunEvent written, DateTimeOffset now, CancellationToken cancellationToken)

Parameters

id DiscoveryRunId

The run the event belongs to.

written DiscoveryRunEvent

What happened, carrying neither a run nor a sequence of its own.

now DateTimeOffset

The instant the event was written.

cancellationToken CancellationToken

Cancels the write.

Returns

Task<long?>

The sequence the event was written under, or null when nothing was written.

Remarks

The sequence starts at 1 and never skips, because it is derived from what the run already holds inside the statement that writes the row rather than by anything counting outside the database.

Nothing is written for a run that has been forgotten, for one that has already published its ending, or for an event that is not itself an ending where the run has been asked to stop or has no room left for anything but its ending. Each of those is the run being over rather than a fault, so the caller ends the run rather than retrying.