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
idDiscoveryRunIdThe run the event belongs to.
writtenDiscoveryRunEventWhat happened, carrying neither a run nor a sequence of its own.
nowDateTimeOffsetThe instant the event was written.
cancellationTokenCancellationTokenCancels the write.
Returns
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.