Interface IMultiRegionKeyProvider
- Namespace
- Excalibur.Compliance
- Assembly
- Excalibur.Compliance.Abstractions.dll
Extends IKeyManagementProvider with multi-region disaster recovery capabilities.
public interface IMultiRegionKeyProvider : IKeyManagementProvider, IServiceProvider, IDisposable
- Inherited Members
Remarks
Multi-region key management provides:
- Active-passive failover between primary and secondary regions
- Automatic health monitoring and failover detection
- Geographic key replication for disaster recovery
- RPO/RTO optimization through configurable sync strategies
Architecture Decision: Active-passive is chosen over active-active to:
- Simplify consistency model (single writer)
- Avoid split-brain scenarios
- Align with cloud provider capabilities
- Maintain clear data residency boundaries
Health monitoring methods are available via IMultiRegionHealthMonitor.
Properties
ActiveRegionId
Gets the identifier of the currently active region.
string ActiveRegionId { get; }
Property Value
- string
The region identifier (e.g., "westeurope", "us-east-1") of the region currently handling key management operations.
IsInFailoverMode
Gets a value indicating whether the provider is currently operating in failover mode.
bool IsInFailoverMode { get; }
Property Value
- bool
trueif the secondary region is active due to primary failure;falseif the primary region is active.
Methods
FailbackToPrimaryAsync(string, CancellationToken)
Returns operations to the primary region after failover.
Task FailbackToPrimaryAsync(string reason, CancellationToken cancellationToken)
Parameters
reasonstringThe reason for failback (for audit purposes).
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
A task representing the asynchronous failback operation.
Remarks
Failback is always manual to prevent split-brain scenarios where a recovering primary might conflict with the active secondary.
Before failback, keys created during failover are synchronized from secondary to primary.
This operation is audited via FailbackCompletedEvent.
Exceptions
- InvalidOperationException
Thrown when not in failover mode or primary is unhealthy.
ForceFailoverAsync(string, CancellationToken)
Manually triggers failover to the secondary region.
Task ForceFailoverAsync(string reason, CancellationToken cancellationToken)
Parameters
reasonstringThe reason for manual failover (for audit purposes).
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
A task representing the asynchronous failover operation.
Remarks
Use this for planned failover during maintenance or when automatic failover thresholds have not been met but manual intervention is needed.
This operation is audited via FailoverInitiatedEvent.
Exceptions
- InvalidOperationException
Thrown when already in failover mode or secondary is unhealthy.
ReplicateKeysAsync(string?, CancellationToken)
Replicates keys from the primary region to the secondary region.
Task ReplicateKeysAsync(string? keyId, CancellationToken cancellationToken)
Parameters
keyIdstringOptional specific key to replicate. If null, replicates all keys.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
A task representing the asynchronous replication operation.
Remarks
Most cloud providers handle replication automatically. This method is primarily for manual replication scenarios or after key imports.
For providers with automatic replication (Azure KV Premium, AWS KMS MRKs), this may be a no-op or trigger an immediate sync.