Table of Contents

Class FirestoreStalePositionDetector

Namespace
Excalibur.Cdc.Firestore
Assembly
Excalibur.Cdc.Firestore.dll

Detects and classifies stale CDC position errors from Firestore exceptions.

public static class FirestoreStalePositionDetector
Inheritance
FirestoreStalePositionDetector
Inherited Members

Remarks

Firestore reports stale position scenarios through gRPC status codes:

  • DEADLINE_EXCEEDED (4) - Listener stream timed out
  • NOT_FOUND (5) - Collection or document not found
  • PERMISSION_DENIED (7) - Access denied
  • RESOURCE_EXHAUSTED (8) - Quota exceeded
  • ABORTED (10) - Request aborted
  • UNAVAILABLE (14) - Service unavailable

Fields

GrpcAborted

gRPC status code for ABORTED.

public const int GrpcAborted = 10

Field Value

int

GrpcCancelled

gRPC status code for CANCELLED.

public const int GrpcCancelled = 1

Field Value

int

GrpcDeadlineExceeded

gRPC status code for DEADLINE_EXCEEDED.

public const int GrpcDeadlineExceeded = 4

Field Value

int

GrpcInternal

gRPC status code for INTERNAL.

public const int GrpcInternal = 13

Field Value

int

GrpcNotFound

gRPC status code for NOT_FOUND.

public const int GrpcNotFound = 5

Field Value

int

GrpcPermissionDenied

gRPC status code for PERMISSION_DENIED.

public const int GrpcPermissionDenied = 7

Field Value

int

GrpcResourceExhausted

gRPC status code for RESOURCE_EXHAUSTED.

public const int GrpcResourceExhausted = 8

Field Value

int

GrpcUnavailable

gRPC status code for UNAVAILABLE.

public const int GrpcUnavailable = 14

Field Value

int

Properties

StalePositionStatusCodes

Gets the set of gRPC status codes that indicate a stale CDC position.

public static IReadOnlySet<int> StalePositionStatusCodes { get; }

Property Value

IReadOnlySet<int>

Methods

CreateEventArgs(Exception, string, FirestoreCdcPosition?, FirestoreCdcPosition?, string?, string?, string?)

Creates a CdcPositionResetEventArgs from an exception and context.

public static CdcPositionResetEventArgs CreateEventArgs(Exception exception, string processorId, FirestoreCdcPosition? stalePosition = null, FirestoreCdcPosition? newPosition = null, string? projectId = null, string? collectionPath = null, string? documentId = null)

Parameters

exception Exception

The exception that was caught.

processorId string

The identifier of the CDC processor.

stalePosition FirestoreCdcPosition

The position that was detected as stale.

newPosition FirestoreCdcPosition

The new position to resume from, if known.

projectId string

The Firestore project ID, if known.

collectionPath string

The affected collection path, if known.

documentId string

The affected document ID, if known.

Returns

CdcPositionResetEventArgs

A populated CdcPositionResetEventArgs instance.

GetReasonCode(RpcException?)

Determines the appropriate reason code from an RPC exception.

public static string GetReasonCode(RpcException? exception)

Parameters

exception RpcException

The RPC exception to analyze.

Returns

string

The reason code string.

GetStalePositionStatusCode(Exception?)

Extracts the gRPC status code that indicates a stale position from the exception.

public static int? GetStalePositionStatusCode(Exception? exception)

Parameters

exception Exception

The exception to analyze.

Returns

int?

The gRPC status code if found; otherwise, null.

IsStalePositionException(Exception?)

Determines whether the specified exception indicates a stale CDC position.

public static bool IsStalePositionException(Exception? exception)

Parameters

exception Exception

The exception to analyze.

Returns

bool

true if the exception indicates a stale position; otherwise, false.

IsStalePositionStatusCode(StatusCode)

Determines if a gRPC status code indicates a stale position scenario.

public static bool IsStalePositionStatusCode(StatusCode statusCode)

Parameters

statusCode StatusCode

The gRPC status code.

Returns

bool

true if the status code indicates stale position.

IsStalePositionStatusCode(int)

Determines if a gRPC status code indicates a stale position scenario.

public static bool IsStalePositionStatusCode(int statusCode)

Parameters

statusCode int

The gRPC status code.

Returns

bool

true if the status code indicates stale position.