Interface ITeamMailKeyStore
- Namespace
- Tharga.Team
- Assembly
- Tharga.Team.dll
Keeps teams' mail keys. The persistence port behind ITeamMailboxService.
public interface ITeamMailKeyStore
Remarks
The port expresses atomicity. Rotating changes three keys at once — a new primary, the old primary demoted, an older secondary retired — so it is one operation an adapter performs as one write, never three calls a caller sequences. IssueAsync(TeamMailKeyRecord, CancellationToken) refuses a second primary for the same reason: two instances issuing a team's first key at the same moment must end with one key, not two.
Retired keys are kept. A mail to a retired key goes to the postmaster as retired rather than unknown, which tells whoever reads it that the sender is still using an old address.
Methods
DeleteForTeamAsync(string, CancellationToken)
Removes every key the team has held, when the team itself is removed.
Task DeleteForTeamAsync(string teamKey, CancellationToken cancellationToken = default)
Parameters
teamKeystringcancellationTokenCancellationToken
Returns
FindAsync(string, CancellationToken)
The key with this value, whichever team holds it; null when nobody does.
Task<TeamMailKeyRecord> FindAsync(string key, CancellationToken cancellationToken = default)
Parameters
keystringcancellationTokenCancellationToken
Returns
GetForTeamAsync(string, CancellationToken)
Every key the team has held, retired ones included.
Task<TeamMailKeyRecord[]> GetForTeamAsync(string teamKey, CancellationToken cancellationToken = default)
Parameters
teamKeystringcancellationTokenCancellationToken
Returns
IssueAsync(TeamMailKeyRecord, CancellationToken)
Adds a team's first primary key; false, and nothing written, when the team already has a primary.
Task<bool> IssueAsync(TeamMailKeyRecord primary, CancellationToken cancellationToken = default)
Parameters
primaryTeamMailKeyRecordcancellationTokenCancellationToken
Returns
RotateAsync(string, TeamMailKeyRecord, DateTime, DateTime, CancellationToken)
In one write: retires the team's current secondary at now, makes its primary the
secondary until retiresAt, and adds newPrimary.
Task RotateAsync(string teamKey, TeamMailKeyRecord newPrimary, DateTime retiresAt, DateTime now, CancellationToken cancellationToken = default)
Parameters
teamKeystringnewPrimaryTeamMailKeyRecordretiresAtDateTimenowDateTimecancellationTokenCancellationToken