Method ReadAllAsync
- Namespace
- MailFathom.Application.Mail.Delivery.Outbox
- Assembly
- MailFathom.Application.dll
ReadAllAsync(CancellationToken)
Reads the accounts to take a pass over, as they are signalled.
public IAsyncEnumerable<MailAccountId> ReadAllAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenStops the enumeration when the host stops.
Returns
- IAsyncEnumerable<MailAccountId>
Each signalled account, once per signal that landed.
Remarks
An account is removed from the pending set as it is handed out rather than when its pass finishes, so a message written while that pass is running signals the account again instead of being absorbed into a pass that had already read the outbox.
The token is read before every account rather than only when there is nothing to read. A channel observes cancellation where it would have to wait, so a queue that is refilled as fast as it is drained — which is what a backlog large enough to fill every batch produces — would otherwise be enumerated straight past the host's shutdown, and the loop reading it would never end.
Exceptions
- OperationCanceledException
Thrown when
cancellationTokenis cancelled.