Table of Contents

Class TokenChangePosition

Namespace
Excalibur.Dispatch
Assembly
Excalibur.Dispatch.Abstractions.dll

Represents a simple token-based change position for providers that use string continuation tokens.

public sealed class TokenChangePosition : ChangePosition, IEquatable<ChangePosition>
Inheritance
TokenChangePosition
Implements
Inherited Members
Extension Methods

Remarks

This implementation is suitable for providers like CosmosDB and DynamoDB that use opaque string tokens for position tracking. For providers with structured positions (e.g., Postgres LSN, SQL Server LSN/SeqVal), derive directly from ChangePosition.

Constructors

TokenChangePosition(string, DateTimeOffset?)

Initializes a new instance of the TokenChangePosition class.

public TokenChangePosition(string token, DateTimeOffset? timestamp = null)

Parameters

token string

The continuation token representing this position.

timestamp DateTimeOffset?

Optional timestamp associated with this position.

Fields

Empty

Represents an invalid or uninitialized position.

public static readonly TokenChangePosition Empty

Field Value

TokenChangePosition

Properties

IsValid

Gets a value indicating whether this position represents a valid point in the CDC stream.

public override bool IsValid { get; }

Property Value

bool

true if this position can be used to resume CDC processing; false if this is an invalid or uninitialized position.

Remarks

Invalid positions typically represent:

  • Uninitialized default positions
  • Positions that have been invalidated (e.g., WAL segment recycled)
  • Sentinel values indicating "start from beginning" or "no checkpoint"

Timestamp

Gets the timestamp associated with this position, if available.

public override DateTimeOffset? Timestamp { get; }

Property Value

DateTimeOffset?

The timestamp when the change at this position occurred, or null if the provider does not support position timestamps.

Remarks

Not all providers include timestamps in their position representation. When available, this can be used for time-based CDC resumption or monitoring.

Token

Gets the continuation token representing this position.

public string Token { get; }

Property Value

string

Methods

Equals(ChangePosition?)

Indicates whether the current object is equal to another object of the same type.

public override bool Equals(ChangePosition? other)

Parameters

other ChangePosition

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Parse(string)

Parses a token string to create a TokenChangePosition.

public static TokenChangePosition Parse(string token)

Parameters

token string

The token to parse.

Returns

TokenChangePosition

A new TokenChangePosition.

ToToken()

Converts this position to a string token suitable for storage and resumption.

public override string ToToken()

Returns

string

A string representation of this position that can be persisted and later used to resume CDC processing from this point.

Remarks

The token format is provider-specific but must be round-trippable through the corresponding Parse method on the derived type.

TryParse(string?, out TokenChangePosition)

Tries to parse a token string to create a TokenChangePosition.

public static bool TryParse(string? token, out TokenChangePosition position)

Parameters

token string

The token to parse.

position TokenChangePosition

When successful, contains the parsed position.

Returns

bool

true if parsing succeeded; otherwise, false.