Class EventualConsistencyTracker
- Namespace
- Excalibur.Data.ElasticSearch.Projections
- Assembly
- Excalibur.Data.ElasticSearch.dll
Tracks eventual consistency between write and read models using Elasticsearch indices.
public sealed class EventualConsistencyTracker : IEventualConsistencyTracker, IEventualConsistencyTrackerAdmin, IDisposable
- Inheritance
-
EventualConsistencyTracker
- Implements
- Inherited Members
Constructors
EventualConsistencyTracker(ElasticsearchClient, IOptions<ElasticSearchProjectionManagementOptions>, ILogger<EventualConsistencyTracker>)
Initializes a new instance of the EventualConsistencyTracker class.
public EventualConsistencyTracker(ElasticsearchClient client, IOptions<ElasticSearchProjectionManagementOptions> options, ILogger<EventualConsistencyTracker> logger)
Parameters
clientElasticsearchClientoptionsIOptions<ElasticSearchProjectionManagementOptions>loggerILogger<EventualConsistencyTracker>
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetConsistencyLagAsync(string, CancellationToken)
Gets the current consistency lag for a specific projection type.
public Task<ConsistencyLag> GetConsistencyLagAsync(string projectionType, CancellationToken cancellationToken)
Parameters
projectionTypestringThe type of projection to check.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<ConsistencyLag>
The consistency lag information.
GetConsistencyMetricsAsync(DateTime, DateTime, CancellationToken)
Gets consistency metrics for all projection types.
public Task<IEnumerable<ConsistencyMetrics>> GetConsistencyMetricsAsync(DateTime fromTime, DateTime toTime, CancellationToken cancellationToken)
Parameters
fromTimeDateTimeThe start time for metrics calculation.
toTimeDateTimeThe end time for metrics calculation.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<IEnumerable<ConsistencyMetrics>>
A collection of consistency metrics.
GetLaggingEventsAsync(TimeSpan, int, CancellationToken)
Gets events that have not been processed within the expected time window.
public Task<IEnumerable<LaggingEvent>> GetLaggingEventsAsync(TimeSpan expectedProcessingTime, int maxResults, CancellationToken cancellationToken)
Parameters
expectedProcessingTimeTimeSpanThe expected maximum processing time.
maxResultsintMaximum number of results to return.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<IEnumerable<LaggingEvent>>
A collection of lagging events.
IsEventFullyProcessedAsync(string, CancellationToken)
Checks if a specific event has been processed by all projections.
public Task<bool> IsEventFullyProcessedAsync(string eventId, CancellationToken cancellationToken)
Parameters
eventIdstringThe event identifier to check.
cancellationTokenCancellationTokenThe cancellation token.
Returns
TrackReadModelProjectionAsync(string, string, DateTime, CancellationToken)
Records when a projection is updated in the read model.
public Task TrackReadModelProjectionAsync(string eventId, string projectionType, DateTime timestamp, CancellationToken cancellationToken)
Parameters
eventIdstringThe event identifier that triggered the projection update.
projectionTypestringThe type of projection updated.
timestampDateTimeThe timestamp when the projection was updated.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the asynchronous tracking operation.
TrackWriteModelEventAsync(string, string, string, DateTime, CancellationToken)
Records when an event is written to the write model.
public Task TrackWriteModelEventAsync(string eventId, string aggregateId, string eventType, DateTime timestamp, CancellationToken cancellationToken)
Parameters
eventIdstringThe unique identifier of the event.
aggregateIdstringThe aggregate identifier associated with the event.
eventTypestringThe type of event.
timestampDateTimeThe timestamp when the event was written.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the asynchronous tracking operation.