Class FirestoreStalePositionDetector
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
GrpcCancelled
gRPC status code for CANCELLED.
public const int GrpcCancelled = 1
Field Value
GrpcDeadlineExceeded
gRPC status code for DEADLINE_EXCEEDED.
public const int GrpcDeadlineExceeded = 4
Field Value
GrpcInternal
gRPC status code for INTERNAL.
public const int GrpcInternal = 13
Field Value
GrpcNotFound
gRPC status code for NOT_FOUND.
public const int GrpcNotFound = 5
Field Value
GrpcPermissionDenied
gRPC status code for PERMISSION_DENIED.
public const int GrpcPermissionDenied = 7
Field Value
GrpcResourceExhausted
gRPC status code for RESOURCE_EXHAUSTED.
public const int GrpcResourceExhausted = 8
Field Value
GrpcUnavailable
gRPC status code for UNAVAILABLE.
public const int GrpcUnavailable = 14
Field Value
Properties
StalePositionStatusCodes
Gets the set of gRPC status codes that indicate a stale CDC position.
public static IReadOnlySet<int> StalePositionStatusCodes { get; }
Property Value
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
exceptionExceptionThe exception that was caught.
processorIdstringThe identifier of the CDC processor.
stalePositionFirestoreCdcPositionThe position that was detected as stale.
newPositionFirestoreCdcPositionThe new position to resume from, if known.
projectIdstringThe Firestore project ID, if known.
collectionPathstringThe affected collection path, if known.
documentIdstringThe 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
exceptionRpcExceptionThe 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
exceptionExceptionThe exception to analyze.
Returns
IsStalePositionException(Exception?)
Determines whether the specified exception indicates a stale CDC position.
public static bool IsStalePositionException(Exception? exception)
Parameters
exceptionExceptionThe exception to analyze.
Returns
IsStalePositionStatusCode(StatusCode)
Determines if a gRPC status code indicates a stale position scenario.
public static bool IsStalePositionStatusCode(StatusCode statusCode)
Parameters
statusCodeStatusCodeThe gRPC status code.
Returns
IsStalePositionStatusCode(int)
Determines if a gRPC status code indicates a stale position scenario.
public static bool IsStalePositionStatusCode(int statusCode)
Parameters
statusCodeintThe gRPC status code.