Table of Contents

Interface ISupportMailPositionStore

Namespace
Tharga.Team
Assembly
Tharga.Team.dll

Remembers how far the support mailbox has been read, so a restart does not re-read it from the start.

public interface ISupportMailPositionStore

Remarks

A position rather than a flag, and that is the whole design. The mailbox may be read by two applications — two sites sharing one support@ address is the case this was built for — so "handled" cannot live in shared mailbox state. Setting \Seen or moving a message would hide it from the instance that actually wanted it. Each deployment keeps its own position and ignores what is not addressed to it.

The key is what separates those deployments, and getting it wrong loses mail silently: two instances sharing a mailbox and a database must not share a position, or the first to poll advances past a message addressed to the second and the second never sees it. It is derived from the recipients the instance answers for, which is exactly what makes the two different.

Losing a position is safe, and that is deliberate. A missing or stale record means the mailbox is re-read, and ISupportEventLedger then recognises everything already handled. So this is a cost optimisation with a correctness story behind it, not a system of record — which is why the store is optional and a host without one simply keeps its position in memory.

It duplicates the transport's own position type rather than sharing it. Everything under Tharga.Team.Support.Email is about mail and only mail, so that it can be lifted out as a move rather than a rewrite; a port declared here cannot reach into it. Two small records that must agree are cheaper than a boundary that leaks, and the poller is the one place that converts between them.

Methods

GetAsync(string, CancellationToken)

Reads the position for key, or Start when there is none.

Task<SupportMailPosition> GetAsync(string key, CancellationToken cancellationToken = default)

Parameters

key string

Identifies the deployment, not the mailbox. See the remarks.

cancellationToken CancellationToken

Abandons the read.

Returns

Task<SupportMailPosition>

SetAsync(string, SupportMailPosition, CancellationToken)

Records how far the mailbox has been read.

Task SetAsync(string key, SupportMailPosition position, CancellationToken cancellationToken = default)

Parameters

key string

Identifies the deployment, not the mailbox.

position SupportMailPosition

The new position.

cancellationToken CancellationToken

Abandons the write.

Returns

Task