Interface IEventStoreErasure
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
Extends IEventStore with GDPR Article 17 (Right to Erasure) support.
public interface IEventStoreErasure
Remarks
Implementations perform cryptographic erasure by redacting or deleting event data for a given aggregate. The stream itself may be retained (with tombstoned payloads) to preserve the event sequence for other aggregates that reference these events.
Event stores that do not support erasure should not implement this interface.
This is a capability of the event store, not a separately registered service. It is never added to the service collection on its own, so resolving it from the container always yields null. Probe the resolved IEventStore instead:
var eventStore = serviceProvider.GetRequiredKeyedService<IEventStore>("default");
if (eventStore.GetService(typeof(IEventStoreErasure)) is IEventStoreErasure erasure)
{
_ = await erasure.EraseEventsAsync(aggregateId, aggregateType, requestId, cancellationToken);
}
Ask the store for the capability, as above; do not test its type. A store is commonly reached through a decorator, whose own interface list is fixed when it is compiled while the capabilities of the store it wraps are known only at run time — so a type test reports the decorator and answers false for a store that supports erasure perfectly well. A decorator answers this probe on behalf of the store it wraps, and a decorator that cannot honour the capability over its inner store answers null rather than claiming it.
Tenant confinement. Both operations are confined to the ambient tenant established for this store instance: EraseEventsAsync(string, string, Guid, CancellationToken) tombstones only that tenant's stream for the given aggregate, and IsErasedAsync(string, string, CancellationToken) answers only for it. The confinement is structural, not conventional, and the mechanism differs by provider family. The relational stores bind an unconditional tenant term on every erase and existence check, routed through a partition type that has no empty inhabitant, so a tenant-less erase is unconstructable rather than merely unwritten; the document and in-memory stores address a key whose leading segment is the owning tenant, so another tenant's stream is unaddressable rather than filtered out. Under ambient multi-tenancy the composition additionally refuses an erase that never resolved a tenant, before any row is mutated.
Where a provider composes the tenant into a key, the composition is injective. Erasure is destructive and irreversible — a confinement failure here destroys another tenant's history rather than disclosing it — so the tenant and the record identifier are encoded, not concatenated: no pair of identifiers can compose to another pair's key, whatever characters they contain. Identifiers containing the separator are supported and need no special handling by the caller. A store presenting no tenant capability marker is not confined by the framework.
Methods
EraseEventsAsync(string, string, Guid, CancellationToken)
Erases all event payloads for the specified aggregate, replacing them with a tombstone marker.
Task<int> EraseEventsAsync(string aggregateId, string aggregateType, Guid erasureRequestId, CancellationToken cancellationToken)
Parameters
aggregateIdstringThe aggregate whose events should be erased.
aggregateTypestringThe aggregate type name.
erasureRequestIdGuidThe GDPR erasure request tracking ID for audit purposes.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
Confined to the ambient tenant established for this store instance: tombstones events only in the
caller's own tenant's stream for aggregateId, and cannot reach or be triggered
by another tenant's stream under the same identifier.
IsErasedAsync(string, string, CancellationToken)
Checks whether erasure has been performed for the specified aggregate.
Task<bool> IsErasedAsync(string aggregateId, string aggregateType, CancellationToken cancellationToken)
Parameters
aggregateIdstringThe aggregate identifier.
aggregateTypestringThe aggregate type name.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
Confined to the ambient tenant established for this store instance: answers for the caller's own tenant's stream, never another tenant's stream under the same identifier.