Method PlaceContentAsync
- Namespace
- MailFathom.Application.EmailContent.Storage
- Assembly
- MailFathom.Application.dll
PlaceContentAsync(EmailContentKind, ReadOnlyMemory<byte>, CancellationToken)
Puts one raw MIME payload wherever this deployment writes content next, before any unit of work is open.
Task<PlacedEmailContent> PlaceContentAsync(EmailContentKind kind, ReadOnlyMemory<byte> rawMime, CancellationToken cancellationToken)
Parameters
kindEmailContentKindWhich of the five payload kinds is being placed.
rawMimeReadOnlyMemory<byte>The raw RFC 822 bytes.
cancellationTokenCancellationTokenPropagates caller cancellation.
Returns
- Task<PlacedEmailContent>
Where the payload was put, and what was measured over it.
Remarks
A caller calls this before it opens its unit of work, never inside one. That is the whole reason the placement is a step of its own: under the object backend this reaches the network, and a database transaction may not be held open across a call to a remote store. Every caller here has a transaction open by the time it reaches one of the write methods below, because the repository that mints the owning row's identity has already run — so the only moment at which the object can legally be written is before all of it.
It is also what keeps a replay off the endpoint. OptimisticConcurrencyRetryPolicy repeats the caller's
whole unit of work, and this call sits outside what it repeats, so every attempt records the same placement over
the same object and no attempt writes bytes a second time.
A placement whose unit of work never commits — one abandoned, or one that resolved to a record already carrying a payload — leaves an object nothing points at. That is the designed failure rather than a leak: no reader can observe it, and reclamation removes it once it is older than the configured age floor.
Under the database backend this reaches no store at all. It measures the payload and hands it back, so that backend keeps committing content and metadata in one transaction exactly as it always has.
Exceptions
- ArgumentException
Thrown when
rawMimeis empty.