Table of Contents

Class CdcStateStore

Namespace
Excalibur.Cdc.SqlServer
Assembly
Excalibur.Cdc.SqlServer.dll

Provides methods to manage the CDC (Change Data Capture) processing state in a database.

public class CdcStateStore : ISqlServerCdcStateStore, ICdcStateStore, IAsyncDisposable, IDisposable
Inheritance
CdcStateStore
Implements
Inherited Members

Constructors

CdcStateStore(Func<IDbConnection>)

Initializes a new instance of the CdcStateStore class.

public CdcStateStore(Func<IDbConnection> connectionFactory)

Parameters

connectionFactory Func<IDbConnection>

Supplies a connection for each operation. The store opens the connection it is given, uses it for one statement, and disposes it, so pooled connections are returned promptly and two overlapping operations never share one.

Exceptions

ArgumentNullException

Thrown if connectionFactory is null .

CdcStateStore(Func<IDbConnection>, IOptions<SqlServerCdcStateStoreOptions>)

Initializes a new instance of the CdcStateStore class with options.

public CdcStateStore(Func<IDbConnection> connectionFactory, IOptions<SqlServerCdcStateStoreOptions> options)

Parameters

connectionFactory Func<IDbConnection>

Supplies a connection for each operation.

options IOptions<SqlServerCdcStateStoreOptions>

The CDC state store options.

Methods

Dispose()

Releases all resources used by the CdcStateStore.

public void Dispose()

Dispose(bool)

Core disposal implementation.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

True if disposing managed resources; otherwise, false.

DisposeAsync()

Asynchronously releases the unmanaged resources used by the CdcStateStore.

public ValueTask DisposeAsync()

Returns

ValueTask

A value task that represents the asynchronous dispose operation.

DisposeCoreAsync()

Core asynchronous disposal implementation.

protected virtual ValueTask DisposeCoreAsync()

Returns

ValueTask

A value task that represents the asynchronous disposal operation.

GetLastProcessedPositionAsync(string, string, CancellationToken)

Retrieves the last processed position for a specified database connection and name.

public Task<IEnumerable<CdcProcessingState>> GetLastProcessedPositionAsync(string databaseConnectionIdentifier, string databaseName, CancellationToken cancellationToken)

Parameters

databaseConnectionIdentifier string

The unique identifier for the database connection.

databaseName string

The name of the database to retrieve the processing state for.

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task<IEnumerable<CdcProcessingState>>

A task that represents the asynchronous operation, containing a collection of the last processed CdcProcessingState for each capture instance.

UpdateLastProcessedPositionAsync(string, string, string, byte[], byte[]?, DateTime?, long?, CancellationToken)

Updates the last processed position for a specified database connection and name.

public Task<int> UpdateLastProcessedPositionAsync(string databaseConnectionIdentifier, string databaseName, string tableName, byte[] position, byte[]? sequenceValue, DateTime? commitTime, long? fencingToken, CancellationToken cancellationToken)

Parameters

databaseConnectionIdentifier string

The unique identifier for the database connection.

databaseName string

The name of the database to update the processing state for.

tableName string

The name of the table to update the processing state for.

position byte[]

The LSN position to set as the last processed position.

sequenceValue byte[]

The sequence value associated with the last processed position, if any.

commitTime DateTime?

The commit time of the last processed LSN.

fencingToken long?

The current leadership tenure's fencing token, or null when leader-election fencing is not configured. When non-null, the checkpoint write is a non-decreasing compare-and-swap: it is applied only if the stored token is less than or equal to this token (a demoted leader presenting an older token is rejected, leaving the LSN checkpoint unchanged — no regression or skip). The return value is the number of rows written, so 0 with a non-null token signals a superseded leader.

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task<int>

The number of rows written (0 when a non-null fencing token was superseded).