Class WatchedDiscoveryRun
- Namespace
- MailFathom.Application.Discovery.Streaming
- Assembly
- MailFathom.Application.dll
Runs one question and writes down what happens as it happens, including what it is spending while it spends it.
public sealed class WatchedDiscoveryRun
- Inheritance
-
WatchedDiscoveryRun
- Inherited Members
Remarks
The use case a watched Discover run is performed through. It decides nothing about the question — that is DiscoveryRun's, unchanged — and owns one thing instead: that a person watching sees the run working, reads a block before the rest arrives, keeps what arrived when the run ends badly, and can read what the run cost while it is still running.
Every failure this type can name becomes the run's own ending, because by the time this executes the request that asked the question has already been answered and there is nobody left to throw at. Which failure it was is written as a closed value carrying nothing about the question or the mail. A failure it cannot name is left to propagate deliberately: naming it would need a log to name it in, this layer has no logger by construction, and a caller that records it is the only place Failed becomes readable to an operator.
A run writes its sources before the blocks that name them, so a client can render a block the moment it reads it rather than holding it until a plan closes. That ordering is this type's, and it is the reason the composition hands citations and blocks over separately.
It is the one writer of its own record, which is what makes the sequence a client reads by mean what it says. Every write here is awaited before the next is made — including the retrieval's own progress reports — so nothing about a run's order depends on which write reached the database first.
What it records about cost is the run's own consumption and never a price. The three counts and the ceilings they are read against are what ADR 0022 settles on: the envelope goes out with the start, the counts accrue on the events the run already writes, and the final ones stay with the ending whichever ending it was. Every one of them is a number or a name an operator chose.
Constructors
- WatchedDiscoveryRun(DiscoveryRun, MailAnsweringRunLedger, MailAnsweringPeriodBounds, TimeProvider, AnsweringEndpointIdentity?)
Initializes the use case one watched run is performed through.
Methods
- RunAsync(MailQuestion, DiscoveryRunJournal, CancellationToken)
Runs the question and writes the run into its journal, ending it however it ends.