Table of Contents

Method ReadAccountsWithWorkInFlightAsync

Namespace
MailFathom.Application.Jobs
Assembly
MailFathom.Application.dll

ReadAccountsWithWorkInFlightAsync(IReadOnlyList<MailAccountId>, CancellationToken)

Names which of a set of mail accounts a worker is holding a job for right now.

Task<IReadOnlyList<MailAccountId>> ReadAccountsWithWorkInFlightAsync(IReadOnlyList<MailAccountId> accounts, CancellationToken cancellationToken)

Parameters

accounts IReadOnlyList<MailAccountId>

The accounts asked about.

cancellationToken CancellationToken

Cancels the read.

Returns

Task<IReadOnlyList<MailAccountId>>

The accounts among them a claim still holds a job for, in ordinal order, and an empty answer when none does.

Remarks

A claim rather than a queue depth, because what makes an account's work unfinished is a handler running against it and a pending row writes nothing until somebody takes it. The claim is also the whole of the test: an attempt waits on the concurrency gate after the claim stamped it and before its renewals begin, so a handler can be running with an expiry already behind it, and a predicate that asked for a live lease would report that account quiet. An account this answers for is therefore one that may be being written to rather than one that certainly is, which is the direction a caller about to delete its rows wants to be wrong in.

It answers one question and belongs to whoever has to stop an account being written to — an erasure, above all. It says nothing about whether a job will be claimed next, so a caller that needs the account to stay quiet has to have stopped whatever enqueues for it and to have taken the rows themselves out of reach of the next claim.

Exceptions

ArgumentNullException

Thrown when accounts is null.