Table of Contents

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

client ElasticsearchClient
options IOptions<ElasticSearchProjectionManagementOptions>
logger ILogger<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

projectionType string

The type of projection to check.

cancellationToken CancellationToken

The 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

fromTime DateTime

The start time for metrics calculation.

toTime DateTime

The end time for metrics calculation.

cancellationToken CancellationToken

The 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

expectedProcessingTime TimeSpan

The expected maximum processing time.

maxResults int

Maximum number of results to return.

cancellationToken CancellationToken

The 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

eventId string

The event identifier to check.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

True if the event has been fully processed; otherwise, false.

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

eventId string

The event identifier that triggered the projection update.

projectionType string

The type of projection updated.

timestamp DateTime

The timestamp when the projection was updated.

cancellationToken CancellationToken

The 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

eventId string

The unique identifier of the event.

aggregateId string

The aggregate identifier associated with the event.

eventType string

The type of event.

timestamp DateTime

The timestamp when the event was written.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task representing the asynchronous tracking operation.