Interface IEventStoreArchive
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
ISP interface for event stores that support archive operations.
public interface IEventStoreArchive
Remarks
This is an ISP extension to IEventStore. Providers that support
tiered storage implement this alongside IEventStore to enable
the EventArchiveService to discover and move old events to cold storage.
Hot store providers (SQL Server, Postgres) implement this interface. The archive service uses it on a schedule to identify and archive old events.
Methods
GetArchiveCandidatesAsync(ArchivePolicy, int, CancellationToken)
Finds aggregates with events eligible for archival based on the archive policy.
Task<IReadOnlyList<ArchiveCandidate>> GetArchiveCandidatesAsync(ArchivePolicy policy, int batchSize, CancellationToken cancellationToken)
Parameters
policyArchivePolicyThe archive policy criteria.
batchSizeintMaximum number of candidates to return.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IReadOnlyList<ArchiveCandidate>>
A list of aggregates with archivable events.
Remarks
Discovery is deliberately cross-tenant: one pass enumerates candidates for every tenant, and each returned candidate carries the tenant that owns it. Scoping this enumeration to a single tenant would stall archival for all others, so the tenant term is a result here, never a parameter. Candidates must contain pending work. Apply the policy's retention override and stop each stream's prefix at its first ineligible or unresolved event before applying the candidate batch limit. Read candidate payloads through the same hot store's IEventStoreArchiveReader capability, using the candidate's tenant, aggregate identity, and inclusive version ceiling.
TombstoneArchivedEventsUpToVersionAsync(KeyedTenantPartition, string, string, long, CancellationToken)
Clears archived payloads from the hot store up to and including the specified version, preserving event identity, ordering, and archive markers.
Task<int> TombstoneArchivedEventsUpToVersionAsync(KeyedTenantPartition tenant, string aggregateId, string aggregateType, long toVersion, CancellationToken cancellationToken)
Parameters
tenantKeyedTenantPartitionThe tenant partition whose payloads are to be cleared. The update is addressed by this term, so a run for one tenant cannot clear another tenant's payloads for the same aggregate identifier.
aggregateIdstringThe aggregate identifier.
aggregateTypestringThe aggregate type name.
toVersionlongThe version up to which payloads should be cleared (inclusive).
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
The caller must bound this operation by both the candidate ceiling and the cold store's confirmed durable prefix. Completion of a write attempt alone does not establish that the full submitted range is durable. Preserve hot rows and their global positions so subscribers can hydrate them from cold storage without silently skipping committed events.
The tenant term is required and must be the same one under which the cold write was confirmed. Implementations MUST emit it as a predicate on the deletion; a deletion addressed by aggregate identifier alone spans every tenant sharing that identifier and destroys events this call never archived.