UNPKG

@azure/cosmos

Version:
77 lines 4.48 kB
import { DiagnosticNodeInternal, type RequestContext } from "./index.js"; /** * @hidden * This class is used to failover single partitions to different regions. */ export declare class GlobalPartitionEndpointManager { private globalEndpointManager; private readonly partitionKeyRangeToLocationForWrite; private readonly partitionKeyRangeToLocationForReadAndWrite; private preferredLocations; preferredLocationsCount: number; private circuitBreakerFailbackBackgroundRefresher?; /** * Checks eligibility of the request for partition failover and * tries to mark the endpoint unavailable for the partition key range. Future * requests will be routed to the next location if available. */ tryPartitionLevelFailover(requestContext: RequestContext, diagnosticNode: DiagnosticNodeInternal): Promise<boolean>; /** * Updates the DocumentServiceRequest routing location to point * new a location based if a partition level failover occurred. */ tryAddPartitionLevelLocationOverride(requestContext: RequestContext, diagnosticNode: DiagnosticNodeInternal): Promise<RequestContext>; /** * This method clears the background refresher for circuit breaker failback * and stops the periodic checks for unhealthy endpoints. */ dispose(): void; private tryMarkEndpointUnavailableForPartitionKeyRange; /** * Increments the failure counter for the specified partition and checks if the partition can fail over. * This method is used to determine if a partition should be failed over based on the number of request failures. */ private incrementFailureCounterAndCheckFailover; /** Validates if the given request is eligible for partition failover. */ private isRequestEligibleForPartitionFailover; /** Determines if partition level failover locations can be used for the given request. */ private canUsePartitionLevelFailoverLocations; /** * Determines if a request is eligible for per-partition automatic failover. * A request is eligible if it is a write request, partition level failover is enabled, * and the global endpoint manager cannot use multiple write locations for the request. */ private isRequestEligibleForPerPartitionAutomaticFailover; /** * Determines if a request is eligible for partition-level circuit breaker. * This method checks if partition-level circuit breaker is enabled, and if the request is a read-only request or * the global endpoint manager can use multiple write locations for the request. */ private isRequestEligibleForPartitionLevelCircuitBreaker; /** * Attempts to add or update the partition failover information and move to the next available location. * This method checks if the current location for the partition key range has failed and updates the failover * information to route the request to the next available location. If all locations have been tried, it removes * the failover information for the partition key range. Return True if the failover information was successfully * updated and the request was routed to a new location, otherwise false. */ private tryAddOrUpdatePartitionFailoverInfoAndMoveToNextLocation; /** * Initiates a background loop that periodically checks for unhealthy endpoints * and attempts to open connections to them. If a connection is successfully * established, it initiates a failback to the original location for the partition key range. * This is useful for scenarios where a partition key range has been marked as unavailable * due to a circuit breaker, and we want to periodically check if the original location * has become healthy again. * The loop runs at a defined interval specified by Constants.StalePartitionUnavailabilityRefreshIntervalInMs. */ private initiateCircuitBreakerFailbackLoop; /** * Attempts to open connections to unhealthy endpoints and initiates failback if the connections are successful. * This method checks the partition key ranges that have failed locations and tries to re-establish connections * to those locations. If a connection is successfully re-established, it initiates a failback to the original * location for the partition key range. */ private openConnectionToUnhealthyEndpointsWithFailback; } //# sourceMappingURL=globalPartitionEndpointManager.d.ts.map