Method SwitchToAsync
- Namespace
- MailFathom.Application.Emails.Embeddings.Generations
- Assembly
- MailFathom.Application.dll
SwitchToAsync(IPersistenceSession, EmbeddingProfileId, CancellationToken)
Makes a built generation the one retrieval reads, and supersedes whichever one it replaces.
Task<bool> SwitchToAsync(IPersistenceSession session, EmbeddingProfileId built, CancellationToken cancellationToken)
Parameters
sessionIPersistenceSessionThe session whose transaction this write joins.
builtEmbeddingProfileIdThe generation whose vectors are complete.
cancellationTokenCancellationTokenPropagates caller cancellation.
Returns
- Task<bool>
true when the switch applied, and false when the named generation was no longer being built.
Remarks
One operation rather than two, because the two halves are one fact: an instance that superseded its old generation without promoting the new one would serve nothing, and one that promoted the new one first would briefly claim two. Both are written in the caller's transaction, so the switch a reader observes is the whole of it or none of it — and a generation somebody abandoned while the sweep was finishing it is not switched to at all, which is what the answer reports.