@azure/cosmos
Version:
Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API
49 lines • 2.6 kB
TypeScript
import { DiagnosticNodeInternal } from "./index.js";
/**
* @hidden
* This class manages the failover information for partition key ranges in Cosmos DB.
* It tracks the current endpoint, failed endpoints, and the number of consecutive read/write request failures.
*/
export declare class PartitionKeyRangeFailoverInfo {
private failedEndPoints;
private currentEndPoint;
private consecutiveReadRequestFailureCount;
private consecutiveWriteRequestFailureCount;
private firstRequestFailureTime;
private lastRequestFailureTime;
private failureCountSemaphore;
private tryMoveNextLocationSemaphore;
/**
* Checks if the circuit breaker can trigger a partition failover based on the failure counts.
* Returns true if the number of consecutive failures exceeds the defined thresholds for read or write requests.
*/
canCircuitBreakerTriggerPartitionFailOver(isReadOnlyRequest: boolean): Promise<boolean>;
/**
* Increments the failure counts for read or write requests and updates the timestamps.
* If the time since the last failure exceeds the reset window, it resets the failure counts.
*/
incrementRequestFailureCounts(isReadOnlyRequest: boolean, currentTimeInMilliseconds: number): Promise<void>;
/**
* Returns a snapshot of the first and last request failure timestamps.
* This method is used to retrieve the current state of failure timestamps without modifying them.
*/
snapshotPartitionFailoverTimestamps(): Promise<{
firstRequestFailureTime: number;
lastRequestFailureTime: number;
}>;
/**
* Attempts to move to the next available location for the partition key range.
* If the current endpoint is the same as the failed endpoint, it tries to find a new endpoint
* from the provided list of endpoints. If a new endpoint is found, it updates the current endpoint
* and returns true. If no new endpoint is found, it returns false.
*/
tryMoveNextLocation(endPoints: readonly string[], failedEndPoint: string, diagnosticNode: DiagnosticNodeInternal, partitionKeyRangeId: string): Promise<boolean>;
/** Returns the current endpoint being used for partition key range operations.*/
getCurrentEndPoint(): string;
/**
* Returns a snapshot of the current consecutive request failure counts for read and write requests.
* This method is used to retrieve the current state of failure counts without modifying them.
*/
private snapshotConsecutiveRequestFailureCount;
}
//# sourceMappingURL=PartitionKeyRangeFailoverInfo.d.ts.map