Table of Contents

Struct MongoDbCdcPosition

Namespace
Excalibur.Cdc.MongoDB
Assembly
Excalibur.Cdc.MongoDB.dll

Represents a position in the MongoDB change stream using a resume token.

public readonly struct MongoDbCdcPosition : IEquatable<MongoDbCdcPosition>
Implements
Inherited Members

Remarks

The resume token is an opaque MongoDB.Bson.BsonDocument provided by MongoDB that allows resuming a change stream from a specific point.

Constructors

MongoDbCdcPosition(BsonDocument?)

Initializes a new instance of the MongoDbCdcPosition struct for an ordinary checkpoint, reopened with resumeAfter.

public MongoDbCdcPosition(BsonDocument? resumeToken)

Parameters

resumeToken BsonDocument

The resume token from a change stream event.

MongoDbCdcPosition(BsonDocument?, MongoDbChangeStreamResumeMode)

Initializes a new instance of the MongoDbCdcPosition struct.

public MongoDbCdcPosition(BsonDocument? resumeToken, MongoDbChangeStreamResumeMode resumeMode)

Parameters

resumeToken BsonDocument

The resume token from a change stream event.

resumeMode MongoDbChangeStreamResumeMode

Which change-stream option this token must be reopened with. A token taken from an invalidate event is only usable as StartAfter.

Fields

Start

Represents the start position (no resume token).

public static readonly MongoDbCdcPosition Start

Field Value

MongoDbCdcPosition

Properties

IsValid

Gets a value indicating whether this position is valid (has a resume token).

public bool IsValid { get; }

Property Value

bool

ResumeMode

Gets the change-stream option this token must be reopened with.

public MongoDbChangeStreamResumeMode ResumeMode { get; }

Property Value

MongoDbChangeStreamResumeMode

ResumeToken

Gets the resume token as a BSON document.

public BsonDocument? ResumeToken { get; }

Property Value

BsonDocument

TokenString

Gets the resume token as a JSON string for storage/serialization.

public string? TokenString { get; }

Property Value

string

Remarks

A StartAfter position serializes as an envelope carrying both the token and the mode, because a restarted process that reopened such a token with resumeAfter would land back before the invalidation it had already passed.

Methods

Equals(MongoDbCdcPosition)

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

public bool Equals(MongoDbCdcPosition other)

Parameters

other MongoDbCdcPosition

An object to compare with this object.

Returns

bool

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

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromChangePosition(ChangePosition?)

public static MongoDbCdcPosition FromChangePosition(ChangePosition? position)

Parameters

position ChangePosition

The change position to convert.

Returns

MongoDbCdcPosition

A MongoDbCdcPosition parsed from the token.

FromString(string?)

Creates a position from a JSON string representation of the resume token.

public static MongoDbCdcPosition FromString(string? tokenString)

Parameters

tokenString string

The JSON string representation.

Returns

MongoDbCdcPosition

A new MongoDbCdcPosition.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToChangePosition()

Converts this position to a ChangePosition for use with the unified ICdcStateStore contract.

public ChangePosition ToChangePosition()

Returns

ChangePosition

A TokenChangePosition representing this position.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

TryParse(string?, out MongoDbCdcPosition)

Tries to parse a JSON string into a MongoDbCdcPosition.

public static bool TryParse(string? tokenString, out MongoDbCdcPosition result)

Parameters

tokenString string

The JSON string to parse.

result MongoDbCdcPosition

The parsed position if successful.

Returns

bool

True if parsing succeeded; otherwise, false.

Operators

operator ==(MongoDbCdcPosition, MongoDbCdcPosition)

Determines whether two positions are equal.

public static bool operator ==(MongoDbCdcPosition left, MongoDbCdcPosition right)

Parameters

left MongoDbCdcPosition
right MongoDbCdcPosition

Returns

bool

operator !=(MongoDbCdcPosition, MongoDbCdcPosition)

Determines whether two positions are not equal.

public static bool operator !=(MongoDbCdcPosition left, MongoDbCdcPosition right)

Parameters

left MongoDbCdcPosition
right MongoDbCdcPosition

Returns

bool