Method RunAsync
- Namespace
- MailFathom.Application.Discovery.Streaming
- Assembly
- MailFathom.Application.dll
RunAsync(MailQuestion, DiscoveryRunJournal, CancellationToken)
Runs the question and writes the run into its journal, ending it however it ends.
public Task RunAsync(MailQuestion question, DiscoveryRunJournal journal, CancellationToken cancellationToken)
Parameters
questionMailQuestionThe question and the scope bounding what may be read to answer it.
journalDiscoveryRunJournalWhere the run writes, which is what a client reads, comes back to, and stops it through.
cancellationTokenCancellationTokenStops the run where it stands, which is how the deployment shutting down reaches it.
Returns
- Task
A task that completes once the run has written its ending.
Remarks
Cancellation ends the run as a stated failure rather than as a cancelled task, because the caller is a background worker with nowhere to report one and because a client watching a run that was stopped has to read that rather than be left reading a run that never finishes.
Which cancellation it was is part of what the client reads, and there are three of them. The person stopped the run — on this replica or on any other, a stop recorded elsewhere reaching the execution as the first write the store refuses — which ends it as Cancelled; the run spent the longest a run may take, which ends it as TimedOut; or the deployment stopped mid-run, which ends it as Stopped. Each is a different fact for the person reading it — I stopped this, this question was more than one run could answer, and nothing about the question at all — so each gets a source of its own rather than being collapsed into whichever the caller happened to name.
A stop reaches the provider call and the retrieval because it cancels the token those run under, which is the difference between stopping the spending and stopping the watching. What had already been written stays, and what had already been spent stays spent — the ending carries this execution's own counts, which is why a stop recorded on another replica is turned into an ending here rather than written there.
Exceptions
- ArgumentNullException
Thrown when
questionorjournalis null.