@azure/cosmos 4.4.1-alpha.20250708.2 → 4.5.0-alpha.20250717.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/ClientContext.d.ts +19 -10
- package/dist/browser/ClientContext.d.ts.map +1 -1
- package/dist/browser/ClientContext.js +30 -11
- package/dist/browser/ClientContext.js.map +1 -1
- package/dist/browser/CosmosClient.d.ts.map +1 -1
- package/dist/browser/CosmosClient.js +10 -2
- package/dist/browser/CosmosClient.js.map +1 -1
- package/dist/browser/PartitionKeyRangeFailoverInfo.d.ts +49 -0
- package/dist/browser/PartitionKeyRangeFailoverInfo.d.ts.map +1 -0
- package/dist/browser/PartitionKeyRangeFailoverInfo.js +130 -0
- package/dist/browser/PartitionKeyRangeFailoverInfo.js.map +1 -0
- package/dist/browser/client/ClientUtils.d.ts +3 -1
- package/dist/browser/client/ClientUtils.d.ts.map +1 -1
- package/dist/browser/client/ClientUtils.js +10 -0
- package/dist/browser/client/ClientUtils.js.map +1 -1
- package/dist/browser/client/Item/Item.d.ts.map +1 -1
- package/dist/browser/client/Item/Item.js +13 -0
- package/dist/browser/client/Item/Item.js.map +1 -1
- package/dist/browser/client/Item/Items.d.ts.map +1 -1
- package/dist/browser/client/Item/Items.js +19 -3
- package/dist/browser/client/Item/Items.js.map +1 -1
- package/dist/browser/common/constants.d.ts +20 -0
- package/dist/browser/common/constants.d.ts.map +1 -1
- package/dist/browser/common/constants.js +23 -1
- package/dist/browser/common/constants.js.map +1 -1
- package/dist/browser/common/platform.d.ts +6 -1
- package/dist/browser/common/platform.d.ts.map +1 -1
- package/dist/browser/common/platform.js +23 -4
- package/dist/browser/common/platform.js.map +1 -1
- package/dist/browser/diagnostics/DiagnosticNodeInternal.d.ts +1 -0
- package/dist/browser/diagnostics/DiagnosticNodeInternal.d.ts.map +1 -1
- package/dist/browser/diagnostics/DiagnosticNodeInternal.js.map +1 -1
- package/dist/browser/documents/ConnectionPolicy.d.ts +6 -0
- package/dist/browser/documents/ConnectionPolicy.d.ts.map +1 -1
- package/dist/browser/documents/ConnectionPolicy.js +2 -0
- package/dist/browser/documents/ConnectionPolicy.js.map +1 -1
- package/dist/browser/documents/DatabaseAccount.d.ts.map +1 -1
- package/dist/browser/documents/DatabaseAccount.js +3 -0
- package/dist/browser/documents/DatabaseAccount.js.map +1 -1
- package/dist/browser/extractPartitionKey.d.ts.map +1 -1
- package/dist/browser/extractPartitionKey.js +33 -20
- package/dist/browser/extractPartitionKey.js.map +1 -1
- package/dist/browser/globalEndpointManager.d.ts +6 -0
- package/dist/browser/globalEndpointManager.d.ts.map +1 -1
- package/dist/browser/globalEndpointManager.js +9 -4
- package/dist/browser/globalEndpointManager.js.map +1 -1
- package/dist/browser/globalPartitionEndpointManager.d.ts +79 -0
- package/dist/browser/globalPartitionEndpointManager.d.ts.map +1 -0
- package/dist/browser/globalPartitionEndpointManager.js +279 -0
- package/dist/browser/globalPartitionEndpointManager.js.map +1 -0
- package/dist/browser/queryExecutionContext/Aggregators/index.d.ts.map +1 -1
- package/dist/browser/queryExecutionContext/Aggregators/index.js +1 -0
- package/dist/browser/queryExecutionContext/Aggregators/index.js.map +1 -1
- package/dist/browser/queryExecutionContext/documentProducer.d.ts +2 -3
- package/dist/browser/queryExecutionContext/documentProducer.d.ts.map +1 -1
- package/dist/browser/queryExecutionContext/documentProducer.js +16 -21
- package/dist/browser/queryExecutionContext/documentProducer.js.map +1 -1
- package/dist/browser/queryExecutionContext/parallelQueryExecutionContextBase.d.ts.map +1 -1
- package/dist/browser/queryExecutionContext/parallelQueryExecutionContextBase.js +2 -1
- package/dist/browser/queryExecutionContext/parallelQueryExecutionContextBase.js.map +1 -1
- package/dist/browser/queryIterator.js +1 -2
- package/dist/browser/queryIterator.js.map +1 -1
- package/dist/browser/request/ErrorResponse.d.ts +1 -1
- package/dist/browser/request/ErrorResponse.d.ts.map +1 -1
- package/dist/browser/request/ErrorResponse.js.map +1 -1
- package/dist/browser/request/RequestContext.d.ts +5 -0
- package/dist/browser/request/RequestContext.d.ts.map +1 -1
- package/dist/browser/request/RequestContext.js.map +1 -1
- package/dist/browser/request/RequestHandler.d.ts.map +1 -1
- package/dist/browser/request/RequestHandler.js +14 -4
- package/dist/browser/request/RequestHandler.js.map +1 -1
- package/dist/browser/retry/RetryPolicy.d.ts +2 -2
- package/dist/browser/retry/RetryPolicy.d.ts.map +1 -1
- package/dist/browser/retry/RetryPolicy.js.map +1 -1
- package/dist/browser/retry/defaultRetryPolicy.d.ts.map +1 -1
- package/dist/browser/retry/defaultRetryPolicy.js +4 -8
- package/dist/browser/retry/defaultRetryPolicy.js.map +1 -1
- package/dist/browser/retry/endpointDiscoveryRetryPolicy.d.ts +5 -3
- package/dist/browser/retry/endpointDiscoveryRetryPolicy.d.ts.map +1 -1
- package/dist/browser/retry/endpointDiscoveryRetryPolicy.js +9 -2
- package/dist/browser/retry/endpointDiscoveryRetryPolicy.js.map +1 -1
- package/dist/browser/retry/retryUtility.d.ts.map +1 -1
- package/dist/browser/retry/retryUtility.js +11 -5
- package/dist/browser/retry/retryUtility.js.map +1 -1
- package/dist/browser/retry/timeoutFailoverRetryPolicy.d.ts +6 -3
- package/dist/browser/retry/timeoutFailoverRetryPolicy.d.ts.map +1 -1
- package/dist/browser/retry/timeoutFailoverRetryPolicy.js +12 -4
- package/dist/browser/retry/timeoutFailoverRetryPolicy.js.map +1 -1
- package/dist/browser/routing/partitionKeyRangeCache.d.ts.map +1 -1
- package/dist/browser/routing/partitionKeyRangeCache.js +11 -0
- package/dist/browser/routing/partitionKeyRangeCache.js.map +1 -1
- package/dist/browser/utils/checkURL.js +6 -0
- package/dist/browser/utils/checkURL.js.map +1 -1
- package/dist/browser/utils/hashing/hash.d.ts +2 -0
- package/dist/browser/utils/hashing/hash.d.ts.map +1 -1
- package/dist/browser/utils/hashing/hash.js +19 -0
- package/dist/browser/utils/hashing/hash.js.map +1 -1
- package/dist/commonjs/ClientContext.d.ts +19 -10
- package/dist/commonjs/ClientContext.d.ts.map +1 -1
- package/dist/commonjs/ClientContext.js +30 -11
- package/dist/commonjs/ClientContext.js.map +1 -1
- package/dist/commonjs/CosmosClient.d.ts.map +1 -1
- package/dist/commonjs/CosmosClient.js +10 -2
- package/dist/commonjs/CosmosClient.js.map +1 -1
- package/dist/commonjs/PartitionKeyRangeFailoverInfo.d.ts +49 -0
- package/dist/commonjs/PartitionKeyRangeFailoverInfo.d.ts.map +1 -0
- package/dist/commonjs/PartitionKeyRangeFailoverInfo.js +135 -0
- package/dist/commonjs/PartitionKeyRangeFailoverInfo.js.map +1 -0
- package/dist/commonjs/client/ClientUtils.d.ts +3 -1
- package/dist/commonjs/client/ClientUtils.d.ts.map +1 -1
- package/dist/commonjs/client/ClientUtils.js +11 -0
- package/dist/commonjs/client/ClientUtils.js.map +1 -1
- package/dist/commonjs/client/Item/Item.d.ts.map +1 -1
- package/dist/commonjs/client/Item/Item.js +13 -0
- package/dist/commonjs/client/Item/Item.js.map +1 -1
- package/dist/commonjs/client/Item/Items.d.ts.map +1 -1
- package/dist/commonjs/client/Item/Items.js +17 -1
- package/dist/commonjs/client/Item/Items.js.map +1 -1
- package/dist/commonjs/common/constants.d.ts +20 -0
- package/dist/commonjs/common/constants.d.ts.map +1 -1
- package/dist/commonjs/common/constants.js +24 -2
- package/dist/commonjs/common/constants.js.map +1 -1
- package/dist/commonjs/common/platform.d.ts +6 -1
- package/dist/commonjs/common/platform.d.ts.map +1 -1
- package/dist/commonjs/common/platform.js +23 -3
- package/dist/commonjs/common/platform.js.map +1 -1
- package/dist/commonjs/diagnostics/DiagnosticNodeInternal.d.ts +1 -0
- package/dist/commonjs/diagnostics/DiagnosticNodeInternal.d.ts.map +1 -1
- package/dist/commonjs/diagnostics/DiagnosticNodeInternal.js.map +1 -1
- package/dist/commonjs/documents/ConnectionPolicy.d.ts +6 -0
- package/dist/commonjs/documents/ConnectionPolicy.d.ts.map +1 -1
- package/dist/commonjs/documents/ConnectionPolicy.js +2 -0
- package/dist/commonjs/documents/ConnectionPolicy.js.map +1 -1
- package/dist/commonjs/documents/DatabaseAccount.d.ts.map +1 -1
- package/dist/commonjs/documents/DatabaseAccount.js +3 -0
- package/dist/commonjs/documents/DatabaseAccount.js.map +1 -1
- package/dist/commonjs/extractPartitionKey.d.ts.map +1 -1
- package/dist/commonjs/extractPartitionKey.js +33 -20
- package/dist/commonjs/extractPartitionKey.js.map +1 -1
- package/dist/commonjs/globalEndpointManager.d.ts +6 -0
- package/dist/commonjs/globalEndpointManager.d.ts.map +1 -1
- package/dist/commonjs/globalEndpointManager.js +10 -5
- package/dist/commonjs/globalEndpointManager.js.map +1 -1
- package/dist/commonjs/globalPartitionEndpointManager.d.ts +79 -0
- package/dist/commonjs/globalPartitionEndpointManager.d.ts.map +1 -0
- package/dist/commonjs/globalPartitionEndpointManager.js +283 -0
- package/dist/commonjs/globalPartitionEndpointManager.js.map +1 -0
- package/dist/commonjs/queryExecutionContext/Aggregators/index.d.ts.map +1 -1
- package/dist/commonjs/queryExecutionContext/Aggregators/index.js +1 -0
- package/dist/commonjs/queryExecutionContext/Aggregators/index.js.map +1 -1
- package/dist/commonjs/queryExecutionContext/documentProducer.d.ts +2 -3
- package/dist/commonjs/queryExecutionContext/documentProducer.d.ts.map +1 -1
- package/dist/commonjs/queryExecutionContext/documentProducer.js +15 -20
- package/dist/commonjs/queryExecutionContext/documentProducer.js.map +1 -1
- package/dist/commonjs/queryExecutionContext/parallelQueryExecutionContextBase.d.ts.map +1 -1
- package/dist/commonjs/queryExecutionContext/parallelQueryExecutionContextBase.js +2 -1
- package/dist/commonjs/queryExecutionContext/parallelQueryExecutionContextBase.js.map +1 -1
- package/dist/commonjs/queryIterator.js +1 -2
- package/dist/commonjs/queryIterator.js.map +1 -1
- package/dist/commonjs/request/ErrorResponse.d.ts +1 -1
- package/dist/commonjs/request/ErrorResponse.d.ts.map +1 -1
- package/dist/commonjs/request/ErrorResponse.js.map +1 -1
- package/dist/commonjs/request/RequestContext.d.ts +5 -0
- package/dist/commonjs/request/RequestContext.d.ts.map +1 -1
- package/dist/commonjs/request/RequestContext.js.map +1 -1
- package/dist/commonjs/request/RequestHandler.d.ts.map +1 -1
- package/dist/commonjs/request/RequestHandler.js +12 -2
- package/dist/commonjs/request/RequestHandler.js.map +1 -1
- package/dist/commonjs/request/defaultAgent.js +4 -4
- package/dist/commonjs/request/defaultAgent.js.map +1 -1
- package/dist/commonjs/retry/RetryPolicy.d.ts +2 -2
- package/dist/commonjs/retry/RetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/retry/RetryPolicy.js.map +1 -1
- package/dist/commonjs/retry/defaultRetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/retry/defaultRetryPolicy.js +3 -7
- package/dist/commonjs/retry/defaultRetryPolicy.js.map +1 -1
- package/dist/commonjs/retry/endpointDiscoveryRetryPolicy.d.ts +5 -3
- package/dist/commonjs/retry/endpointDiscoveryRetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/retry/endpointDiscoveryRetryPolicy.js +9 -2
- package/dist/commonjs/retry/endpointDiscoveryRetryPolicy.js.map +1 -1
- package/dist/commonjs/retry/retryUtility.d.ts.map +1 -1
- package/dist/commonjs/retry/retryUtility.js +11 -5
- package/dist/commonjs/retry/retryUtility.js.map +1 -1
- package/dist/commonjs/retry/timeoutFailoverRetryPolicy.d.ts +6 -3
- package/dist/commonjs/retry/timeoutFailoverRetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/retry/timeoutFailoverRetryPolicy.js +12 -4
- package/dist/commonjs/retry/timeoutFailoverRetryPolicy.js.map +1 -1
- package/dist/commonjs/routing/partitionKeyRangeCache.d.ts.map +1 -1
- package/dist/commonjs/routing/partitionKeyRangeCache.js +11 -0
- package/dist/commonjs/routing/partitionKeyRangeCache.js.map +1 -1
- package/dist/commonjs/utils/checkURL.js +7 -0
- package/dist/commonjs/utils/checkURL.js.map +1 -1
- package/dist/commonjs/utils/hashing/hash.d.ts +2 -0
- package/dist/commonjs/utils/hashing/hash.d.ts.map +1 -1
- package/dist/commonjs/utils/hashing/hash.js +20 -0
- package/dist/commonjs/utils/hashing/hash.js.map +1 -1
- package/dist/esm/ClientContext.d.ts +19 -10
- package/dist/esm/ClientContext.d.ts.map +1 -1
- package/dist/esm/ClientContext.js +30 -11
- package/dist/esm/ClientContext.js.map +1 -1
- package/dist/esm/CosmosClient.d.ts.map +1 -1
- package/dist/esm/CosmosClient.js +10 -2
- package/dist/esm/CosmosClient.js.map +1 -1
- package/dist/esm/PartitionKeyRangeFailoverInfo.d.ts +49 -0
- package/dist/esm/PartitionKeyRangeFailoverInfo.d.ts.map +1 -0
- package/dist/esm/PartitionKeyRangeFailoverInfo.js +130 -0
- package/dist/esm/PartitionKeyRangeFailoverInfo.js.map +1 -0
- package/dist/esm/client/ClientUtils.d.ts +3 -1
- package/dist/esm/client/ClientUtils.d.ts.map +1 -1
- package/dist/esm/client/ClientUtils.js +10 -0
- package/dist/esm/client/ClientUtils.js.map +1 -1
- package/dist/esm/client/Item/Item.d.ts.map +1 -1
- package/dist/esm/client/Item/Item.js +13 -0
- package/dist/esm/client/Item/Item.js.map +1 -1
- package/dist/esm/client/Item/Items.d.ts.map +1 -1
- package/dist/esm/client/Item/Items.js +19 -3
- package/dist/esm/client/Item/Items.js.map +1 -1
- package/dist/esm/common/constants.d.ts +20 -0
- package/dist/esm/common/constants.d.ts.map +1 -1
- package/dist/esm/common/constants.js +23 -1
- package/dist/esm/common/constants.js.map +1 -1
- package/dist/esm/common/platform.d.ts +6 -1
- package/dist/esm/common/platform.d.ts.map +1 -1
- package/dist/esm/common/platform.js +23 -4
- package/dist/esm/common/platform.js.map +1 -1
- package/dist/esm/diagnostics/DiagnosticNodeInternal.d.ts +1 -0
- package/dist/esm/diagnostics/DiagnosticNodeInternal.d.ts.map +1 -1
- package/dist/esm/diagnostics/DiagnosticNodeInternal.js.map +1 -1
- package/dist/esm/documents/ConnectionPolicy.d.ts +6 -0
- package/dist/esm/documents/ConnectionPolicy.d.ts.map +1 -1
- package/dist/esm/documents/ConnectionPolicy.js +2 -0
- package/dist/esm/documents/ConnectionPolicy.js.map +1 -1
- package/dist/esm/documents/DatabaseAccount.d.ts.map +1 -1
- package/dist/esm/documents/DatabaseAccount.js +3 -0
- package/dist/esm/documents/DatabaseAccount.js.map +1 -1
- package/dist/esm/extractPartitionKey.d.ts.map +1 -1
- package/dist/esm/extractPartitionKey.js +33 -20
- package/dist/esm/extractPartitionKey.js.map +1 -1
- package/dist/esm/globalEndpointManager.d.ts +6 -0
- package/dist/esm/globalEndpointManager.d.ts.map +1 -1
- package/dist/esm/globalEndpointManager.js +9 -4
- package/dist/esm/globalEndpointManager.js.map +1 -1
- package/dist/esm/globalPartitionEndpointManager.d.ts +79 -0
- package/dist/esm/globalPartitionEndpointManager.d.ts.map +1 -0
- package/dist/esm/globalPartitionEndpointManager.js +279 -0
- package/dist/esm/globalPartitionEndpointManager.js.map +1 -0
- package/dist/esm/queryExecutionContext/Aggregators/index.d.ts.map +1 -1
- package/dist/esm/queryExecutionContext/Aggregators/index.js +1 -0
- package/dist/esm/queryExecutionContext/Aggregators/index.js.map +1 -1
- package/dist/esm/queryExecutionContext/documentProducer.d.ts +2 -3
- package/dist/esm/queryExecutionContext/documentProducer.d.ts.map +1 -1
- package/dist/esm/queryExecutionContext/documentProducer.js +16 -21
- package/dist/esm/queryExecutionContext/documentProducer.js.map +1 -1
- package/dist/esm/queryExecutionContext/parallelQueryExecutionContextBase.d.ts.map +1 -1
- package/dist/esm/queryExecutionContext/parallelQueryExecutionContextBase.js +2 -1
- package/dist/esm/queryExecutionContext/parallelQueryExecutionContextBase.js.map +1 -1
- package/dist/esm/queryIterator.js +1 -2
- package/dist/esm/queryIterator.js.map +1 -1
- package/dist/esm/request/ErrorResponse.d.ts +1 -1
- package/dist/esm/request/ErrorResponse.d.ts.map +1 -1
- package/dist/esm/request/ErrorResponse.js.map +1 -1
- package/dist/esm/request/RequestContext.d.ts +5 -0
- package/dist/esm/request/RequestContext.d.ts.map +1 -1
- package/dist/esm/request/RequestContext.js.map +1 -1
- package/dist/esm/request/RequestHandler.d.ts.map +1 -1
- package/dist/esm/request/RequestHandler.js +14 -4
- package/dist/esm/request/RequestHandler.js.map +1 -1
- package/dist/esm/request/defaultAgent.js +2 -2
- package/dist/esm/request/defaultAgent.js.map +1 -1
- package/dist/esm/retry/RetryPolicy.d.ts +2 -2
- package/dist/esm/retry/RetryPolicy.d.ts.map +1 -1
- package/dist/esm/retry/RetryPolicy.js.map +1 -1
- package/dist/esm/retry/defaultRetryPolicy.d.ts.map +1 -1
- package/dist/esm/retry/defaultRetryPolicy.js +4 -8
- package/dist/esm/retry/defaultRetryPolicy.js.map +1 -1
- package/dist/esm/retry/endpointDiscoveryRetryPolicy.d.ts +5 -3
- package/dist/esm/retry/endpointDiscoveryRetryPolicy.d.ts.map +1 -1
- package/dist/esm/retry/endpointDiscoveryRetryPolicy.js +9 -2
- package/dist/esm/retry/endpointDiscoveryRetryPolicy.js.map +1 -1
- package/dist/esm/retry/retryUtility.d.ts.map +1 -1
- package/dist/esm/retry/retryUtility.js +11 -5
- package/dist/esm/retry/retryUtility.js.map +1 -1
- package/dist/esm/retry/timeoutFailoverRetryPolicy.d.ts +6 -3
- package/dist/esm/retry/timeoutFailoverRetryPolicy.d.ts.map +1 -1
- package/dist/esm/retry/timeoutFailoverRetryPolicy.js +12 -4
- package/dist/esm/retry/timeoutFailoverRetryPolicy.js.map +1 -1
- package/dist/esm/routing/partitionKeyRangeCache.d.ts.map +1 -1
- package/dist/esm/routing/partitionKeyRangeCache.js +11 -0
- package/dist/esm/routing/partitionKeyRangeCache.js.map +1 -1
- package/dist/esm/utils/checkURL.js +6 -0
- package/dist/esm/utils/checkURL.js.map +1 -1
- package/dist/esm/utils/hashing/hash.d.ts +2 -0
- package/dist/esm/utils/hashing/hash.d.ts.map +1 -1
- package/dist/esm/utils/hashing/hash.js +19 -0
- package/dist/esm/utils/hashing/hash.js.map +1 -1
- package/dist/react-native/ClientContext.d.ts +19 -10
- package/dist/react-native/ClientContext.d.ts.map +1 -1
- package/dist/react-native/ClientContext.js +30 -11
- package/dist/react-native/ClientContext.js.map +1 -1
- package/dist/react-native/CosmosClient.d.ts.map +1 -1
- package/dist/react-native/CosmosClient.js +10 -2
- package/dist/react-native/CosmosClient.js.map +1 -1
- package/dist/react-native/PartitionKeyRangeFailoverInfo.d.ts +49 -0
- package/dist/react-native/PartitionKeyRangeFailoverInfo.d.ts.map +1 -0
- package/dist/react-native/PartitionKeyRangeFailoverInfo.js +130 -0
- package/dist/react-native/PartitionKeyRangeFailoverInfo.js.map +1 -0
- package/dist/react-native/client/ClientUtils.d.ts +3 -1
- package/dist/react-native/client/ClientUtils.d.ts.map +1 -1
- package/dist/react-native/client/ClientUtils.js +10 -0
- package/dist/react-native/client/ClientUtils.js.map +1 -1
- package/dist/react-native/client/Item/Item.d.ts.map +1 -1
- package/dist/react-native/client/Item/Item.js +13 -0
- package/dist/react-native/client/Item/Item.js.map +1 -1
- package/dist/react-native/client/Item/Items.d.ts.map +1 -1
- package/dist/react-native/client/Item/Items.js +19 -3
- package/dist/react-native/client/Item/Items.js.map +1 -1
- package/dist/react-native/common/constants.d.ts +20 -0
- package/dist/react-native/common/constants.d.ts.map +1 -1
- package/dist/react-native/common/constants.js +23 -1
- package/dist/react-native/common/constants.js.map +1 -1
- package/dist/react-native/common/platform.d.ts +6 -1
- package/dist/react-native/common/platform.d.ts.map +1 -1
- package/dist/react-native/common/platform.js +23 -4
- package/dist/react-native/common/platform.js.map +1 -1
- package/dist/react-native/diagnostics/DiagnosticNodeInternal.d.ts +1 -0
- package/dist/react-native/diagnostics/DiagnosticNodeInternal.d.ts.map +1 -1
- package/dist/react-native/diagnostics/DiagnosticNodeInternal.js.map +1 -1
- package/dist/react-native/documents/ConnectionPolicy.d.ts +6 -0
- package/dist/react-native/documents/ConnectionPolicy.d.ts.map +1 -1
- package/dist/react-native/documents/ConnectionPolicy.js +2 -0
- package/dist/react-native/documents/ConnectionPolicy.js.map +1 -1
- package/dist/react-native/documents/DatabaseAccount.d.ts.map +1 -1
- package/dist/react-native/documents/DatabaseAccount.js +3 -0
- package/dist/react-native/documents/DatabaseAccount.js.map +1 -1
- package/dist/react-native/extractPartitionKey.d.ts.map +1 -1
- package/dist/react-native/extractPartitionKey.js +33 -20
- package/dist/react-native/extractPartitionKey.js.map +1 -1
- package/dist/react-native/globalEndpointManager.d.ts +6 -0
- package/dist/react-native/globalEndpointManager.d.ts.map +1 -1
- package/dist/react-native/globalEndpointManager.js +9 -4
- package/dist/react-native/globalEndpointManager.js.map +1 -1
- package/dist/react-native/globalPartitionEndpointManager.d.ts +79 -0
- package/dist/react-native/globalPartitionEndpointManager.d.ts.map +1 -0
- package/dist/react-native/globalPartitionEndpointManager.js +279 -0
- package/dist/react-native/globalPartitionEndpointManager.js.map +1 -0
- package/dist/react-native/queryExecutionContext/Aggregators/index.d.ts.map +1 -1
- package/dist/react-native/queryExecutionContext/Aggregators/index.js +1 -0
- package/dist/react-native/queryExecutionContext/Aggregators/index.js.map +1 -1
- package/dist/react-native/queryExecutionContext/documentProducer.d.ts +2 -3
- package/dist/react-native/queryExecutionContext/documentProducer.d.ts.map +1 -1
- package/dist/react-native/queryExecutionContext/documentProducer.js +16 -21
- package/dist/react-native/queryExecutionContext/documentProducer.js.map +1 -1
- package/dist/react-native/queryExecutionContext/parallelQueryExecutionContextBase.d.ts.map +1 -1
- package/dist/react-native/queryExecutionContext/parallelQueryExecutionContextBase.js +2 -1
- package/dist/react-native/queryExecutionContext/parallelQueryExecutionContextBase.js.map +1 -1
- package/dist/react-native/queryIterator.js +1 -2
- package/dist/react-native/queryIterator.js.map +1 -1
- package/dist/react-native/request/ErrorResponse.d.ts +1 -1
- package/dist/react-native/request/ErrorResponse.d.ts.map +1 -1
- package/dist/react-native/request/ErrorResponse.js.map +1 -1
- package/dist/react-native/request/RequestContext.d.ts +5 -0
- package/dist/react-native/request/RequestContext.d.ts.map +1 -1
- package/dist/react-native/request/RequestContext.js.map +1 -1
- package/dist/react-native/request/RequestHandler.d.ts.map +1 -1
- package/dist/react-native/request/RequestHandler.js +14 -4
- package/dist/react-native/request/RequestHandler.js.map +1 -1
- package/dist/react-native/request/defaultAgent.js +2 -2
- package/dist/react-native/request/defaultAgent.js.map +1 -1
- package/dist/react-native/retry/RetryPolicy.d.ts +2 -2
- package/dist/react-native/retry/RetryPolicy.d.ts.map +1 -1
- package/dist/react-native/retry/RetryPolicy.js.map +1 -1
- package/dist/react-native/retry/defaultRetryPolicy.d.ts.map +1 -1
- package/dist/react-native/retry/defaultRetryPolicy.js +4 -8
- package/dist/react-native/retry/defaultRetryPolicy.js.map +1 -1
- package/dist/react-native/retry/endpointDiscoveryRetryPolicy.d.ts +5 -3
- package/dist/react-native/retry/endpointDiscoveryRetryPolicy.d.ts.map +1 -1
- package/dist/react-native/retry/endpointDiscoveryRetryPolicy.js +9 -2
- package/dist/react-native/retry/endpointDiscoveryRetryPolicy.js.map +1 -1
- package/dist/react-native/retry/retryUtility.d.ts.map +1 -1
- package/dist/react-native/retry/retryUtility.js +11 -5
- package/dist/react-native/retry/retryUtility.js.map +1 -1
- package/dist/react-native/retry/timeoutFailoverRetryPolicy.d.ts +6 -3
- package/dist/react-native/retry/timeoutFailoverRetryPolicy.d.ts.map +1 -1
- package/dist/react-native/retry/timeoutFailoverRetryPolicy.js +12 -4
- package/dist/react-native/retry/timeoutFailoverRetryPolicy.js.map +1 -1
- package/dist/react-native/routing/partitionKeyRangeCache.d.ts.map +1 -1
- package/dist/react-native/routing/partitionKeyRangeCache.js +11 -0
- package/dist/react-native/routing/partitionKeyRangeCache.js.map +1 -1
- package/dist/react-native/utils/checkURL.js +6 -0
- package/dist/react-native/utils/checkURL.js.map +1 -1
- package/dist/react-native/utils/hashing/hash.d.ts +2 -0
- package/dist/react-native/utils/hashing/hash.d.ts.map +1 -1
- package/dist/react-native/utils/hashing/hash.js +19 -0
- package/dist/react-native/utils/hashing/hash.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ import type { HTTPMethod, OperationType, ResourceType } from "../common/index.js
|
|
|
3
3
|
import type { Agent } from "../CosmosClientOptions.js";
|
|
4
4
|
import type { ConnectionPolicy, PartitionKey } from "../documents/index.js";
|
|
5
5
|
import type { GlobalEndpointManager } from "../globalEndpointManager.js";
|
|
6
|
+
import type { GlobalPartitionEndpointManager } from "../globalPartitionEndpointManager.js";
|
|
6
7
|
import type { PluginConfig } from "../plugins/Plugin.js";
|
|
7
8
|
import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders.js";
|
|
8
9
|
import type { FeedOptions } from "./FeedOptions.js";
|
|
@@ -31,5 +32,9 @@ export interface RequestContext {
|
|
|
31
32
|
partitionKey?: PartitionKey;
|
|
32
33
|
pipeline?: Pipeline;
|
|
33
34
|
httpClient?: HttpClient;
|
|
35
|
+
/**
|
|
36
|
+
* Global partition endpoint manager instance.
|
|
37
|
+
*/
|
|
38
|
+
globalPartitionEndpointManager?: GlobalPartitionEndpointManager;
|
|
34
39
|
}
|
|
35
40
|
//# sourceMappingURL=RequestContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestContext.d.ts","sourceRoot":"","sources":["../../../src/request/RequestContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;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E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestContext.js","sourceRoot":"","sources":["../../../src/request/RequestContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { ClientContext } from \"../ClientContext.js\";\nimport type { HTTPMethod, OperationType, ResourceType } from \"../common/index.js\";\nimport type { Agent } from \"../CosmosClientOptions.js\";\nimport type { ConnectionPolicy, PartitionKey } from \"../documents/index.js\";\nimport type { GlobalEndpointManager } from \"../globalEndpointManager.js\";\nimport type { PluginConfig } from \"../plugins/Plugin.js\";\nimport type { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders.js\";\nimport type { FeedOptions } from \"./FeedOptions.js\";\nimport type { RequestOptions } from \"./RequestOptions.js\";\nimport type { HttpClient, Pipeline } from \"@azure/core-rest-pipeline\";\n\n/**\n * @hidden\n */\nexport interface RequestContext {\n path?: string;\n operationType?: OperationType;\n client?: ClientContext;\n retryCount?: number;\n resourceType?: ResourceType;\n resourceId?: string;\n globalEndpointManager: GlobalEndpointManager;\n connectionPolicy: ConnectionPolicy;\n requestAgent: Agent;\n body?: any;\n headers?: CosmosHeaders;\n endpoint?: string;\n method: HTTPMethod;\n partitionKeyRangeId?: string;\n options: FeedOptions | RequestOptions;\n plugins: PluginConfig[];\n partitionKey?: PartitionKey;\n pipeline?: Pipeline;\n httpClient?: HttpClient;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RequestContext.js","sourceRoot":"","sources":["../../../src/request/RequestContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { ClientContext } from \"../ClientContext.js\";\nimport type { HTTPMethod, OperationType, ResourceType } from \"../common/index.js\";\nimport type { Agent } from \"../CosmosClientOptions.js\";\nimport type { ConnectionPolicy, PartitionKey } from \"../documents/index.js\";\nimport type { GlobalEndpointManager } from \"../globalEndpointManager.js\";\nimport type { GlobalPartitionEndpointManager } from \"../globalPartitionEndpointManager.js\";\nimport type { PluginConfig } from \"../plugins/Plugin.js\";\nimport type { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders.js\";\nimport type { FeedOptions } from \"./FeedOptions.js\";\nimport type { RequestOptions } from \"./RequestOptions.js\";\nimport type { HttpClient, Pipeline } from \"@azure/core-rest-pipeline\";\n\n/**\n * @hidden\n */\nexport interface RequestContext {\n path?: string;\n operationType?: OperationType;\n client?: ClientContext;\n retryCount?: number;\n resourceType?: ResourceType;\n resourceId?: string;\n globalEndpointManager: GlobalEndpointManager;\n connectionPolicy: ConnectionPolicy;\n requestAgent: Agent;\n body?: any;\n headers?: CosmosHeaders;\n endpoint?: string;\n method: HTTPMethod;\n partitionKeyRangeId?: string;\n options: FeedOptions | RequestOptions;\n plugins: PluginConfig[];\n partitionKey?: PartitionKey;\n pipeline?: Pipeline;\n httpClient?: HttpClient;\n /**\n * Global partition endpoint manager instance.\n */\n globalPartitionEndpointManager?: GlobalPartitionEndpointManager;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestHandler.d.ts","sourceRoot":"","sources":["../../../src/request/RequestHandler.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AAKhE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"RequestHandler.d.ts","sourceRoot":"","sources":["../../../src/request/RequestHandler.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AAKhE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AA2KvF;;GAEG;AACH,iBAAe,OAAO,CAAC,CAAC,EACtB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAmB5B;AAED,eAAO,MAAM,cAAc;;CAE1B,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { createPipelineRequest, createHttpHeaders } from "@azure/core-rest-pipeline";
|
|
4
|
-
import { prepareURL } from "../common/index.js";
|
|
5
|
-
import { Constants } from "../common/constants.js";
|
|
4
|
+
import { isReadRequest, prepareURL } from "../common/index.js";
|
|
5
|
+
import { Constants, ResourceType } from "../common/constants.js";
|
|
6
6
|
import { executePlugins, PluginOn } from "../plugins/Plugin.js";
|
|
7
7
|
import * as RetryUtility from "../retry/retryUtility.js";
|
|
8
8
|
import { defaultHttpAgent, defaultHttpsAgent } from "./defaultAgent.js";
|
|
@@ -37,9 +37,20 @@ async function httpRequest(requestContext, diagnosticNode) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
let requestTimeout = requestContext.connectionPolicy.requestTimeout;
|
|
41
|
+
// If the request is a read request and partition level failover or circuit breaker is enabled,
|
|
42
|
+
// set a shorter timeout to allow for quicker failover in case of partition unavailability.
|
|
43
|
+
// This is to ensure that read requests can quickly failover to another partition if the current one is unavailable.
|
|
44
|
+
if ((requestContext.connectionPolicy.enablePartitionLevelFailover ||
|
|
45
|
+
requestContext.connectionPolicy.enablePartitionLevelCircuitBreaker) &&
|
|
46
|
+
requestContext.partitionKeyRangeId &&
|
|
47
|
+
requestContext.resourceType === ResourceType.item &&
|
|
48
|
+
isReadRequest(requestContext.operationType)) {
|
|
49
|
+
requestTimeout = Math.min(requestContext.connectionPolicy.requestTimeout, Constants.RequestTimeoutForReadsInMs);
|
|
50
|
+
}
|
|
40
51
|
const timeout = setTimeout(() => {
|
|
41
52
|
controller.abort();
|
|
42
|
-
},
|
|
53
|
+
}, requestTimeout);
|
|
43
54
|
let response;
|
|
44
55
|
if (requestContext.body) {
|
|
45
56
|
requestContext.body = bodyFromData(requestContext.body);
|
|
@@ -78,7 +89,6 @@ async function httpRequest(requestContext, diagnosticNode) {
|
|
|
78
89
|
clearTimeout(timeout);
|
|
79
90
|
throw error;
|
|
80
91
|
}
|
|
81
|
-
// If the user didn't cancel, it must be an abort we called due to timeout
|
|
82
92
|
throw new TimeoutError(`Timeout Error! Request took more than ${requestContext.connectionPolicy.requestTimeout} ms`);
|
|
83
93
|
}
|
|
84
94
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestHandler.js","sourceRoot":"","sources":["../../../src/request/RequestHandler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,YAAY,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7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EACD,cAAc,EACd,kBAAkB,CAAC,gBAAgB,CACpC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO;CACR,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { createPipelineRequest, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { prepareURL } from \"../common/index.js\";\nimport { Constants } from \"../common/constants.js\";\nimport { executePlugins, PluginOn } from \"../plugins/Plugin.js\";\nimport * as RetryUtility from \"../retry/retryUtility.js\";\nimport { defaultHttpAgent, defaultHttpsAgent } from \"./defaultAgent.js\";\nimport { ErrorResponse } from \"./ErrorResponse.js\";\nimport { bodyFromData } from \"./request.js\";\nimport type { RequestContext } from \"./RequestContext.js\";\nimport type { Response as CosmosResponse } from \"./Response.js\";\nimport { TimeoutError } from \"./TimeoutError.js\";\nimport { getCachedDefaultHttpClient } from \"../utils/cachedClient.js\";\nimport type { AzureLogger } from \"@azure/logger\";\nimport { createClientLogger } from \"@azure/logger\";\nimport type { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport { DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport { addDiagnosticChild } from \"../utils/diagnostics.js\";\nimport { getCurrentTimestampInMs } from \"../utils/time.js\";\n\nconst logger: AzureLogger = createClientLogger(\"RequestHandler\");\n\nasync function executeRequest(\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n): Promise<CosmosResponse<any>> {\n return executePlugins(diagnosticNode, requestContext, httpRequest, PluginOn.request);\n}\n\n/**\n * @hidden\n */\nasync function httpRequest(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n): Promise<{\n headers: any;\n result: any;\n code: number;\n substatus: number;\n}> {\n const controller = new AbortController();\n const signal = controller.signal;\n\n // Wrap users passed abort events and call our own internal abort()\n const userSignal = requestContext.options && requestContext.options.abortSignal;\n if (userSignal) {\n if (userSignal.aborted) {\n controller.abort();\n } else {\n userSignal.addEventListener(\"abort\", () => {\n controller.abort();\n });\n }\n }\n\n const timeout = setTimeout(() => {\n controller.abort();\n }, requestContext.connectionPolicy.requestTimeout);\n\n let response: PipelineResponse;\n\n if (requestContext.body) {\n requestContext.body = bodyFromData(requestContext.body);\n }\n\n const httpsClient = requestContext.httpClient ?? getCachedDefaultHttpClient();\n const url = prepareURL(requestContext.endpoint, requestContext.path);\n const reqHeaders = createHttpHeaders(requestContext.headers as any);\n const pipelineRequest = createPipelineRequest({\n url,\n headers: reqHeaders,\n method: requestContext.method,\n abortSignal: signal,\n body: requestContext.body,\n });\n if (requestContext.requestAgent) {\n pipelineRequest.agent = requestContext.requestAgent;\n } else {\n const parsedUrl = new URL(url);\n pipelineRequest.agent = parsedUrl.protocol === \"http:\" ? defaultHttpAgent : defaultHttpsAgent;\n pipelineRequest.allowInsecureConnection = parsedUrl.protocol === \"http:\";\n }\n\n const startTimeUTCInMs = getCurrentTimestampInMs();\n try {\n if (requestContext.pipeline) {\n response = await requestContext.pipeline.sendRequest(httpsClient, pipelineRequest);\n } else {\n response = await httpsClient.sendRequest(pipelineRequest);\n }\n } catch (error: any) {\n if (error.name === \"AbortError\") {\n // If the user passed signal caused the abort, cancel the timeout and rethrow the error\n if (userSignal && userSignal.aborted === true) {\n clearTimeout(timeout);\n throw error;\n }\n // If the user didn't cancel, it must be an abort we called due to timeout\n throw new TimeoutError(\n `Timeout Error! Request took more than ${requestContext.connectionPolicy.requestTimeout} ms`,\n );\n }\n throw error;\n }\n\n clearTimeout(timeout);\n const result =\n response.status === 204 || response.status === 304 || response.bodyAsText === \"\"\n ? null\n : JSON.parse(response.bodyAsText);\n const responseHeaders = response.headers.toJSON();\n\n const substatus = responseHeaders[Constants.HttpHeaders.SubStatus]\n ? parseInt(responseHeaders[Constants.HttpHeaders.SubStatus], 10)\n : undefined;\n\n diagnosticNode.recordSuccessfulNetworkCall(\n startTimeUTCInMs,\n requestContext,\n response,\n substatus,\n url,\n );\n\n if (response.status >= 400) {\n const errorResponse: ErrorResponse = new ErrorResponse(result.message);\n logger.warning(\n response.status +\n \" \" +\n requestContext.endpoint +\n \" \" +\n requestContext.path +\n \" \" +\n result.message,\n );\n\n errorResponse.code = response.status;\n errorResponse.body = result;\n errorResponse.headers = responseHeaders;\n\n if (Constants.HttpHeaders.ActivityId in responseHeaders) {\n errorResponse.activityId = responseHeaders[Constants.HttpHeaders.ActivityId];\n }\n\n if (Constants.HttpHeaders.SubStatus in responseHeaders) {\n errorResponse.substatus = substatus;\n }\n\n if (Constants.HttpHeaders.RetryAfterInMs in responseHeaders) {\n errorResponse.retryAfterInMs = parseInt(\n responseHeaders[Constants.HttpHeaders.RetryAfterInMs],\n 10,\n );\n Object.defineProperty(errorResponse, \"retryAfterInMilliseconds\", {\n get: () => {\n return errorResponse.retryAfterInMs;\n },\n });\n }\n\n throw errorResponse;\n }\n return {\n headers: responseHeaders,\n result,\n code: response.status,\n substatus,\n };\n}\n\n/**\n * @hidden\n */\nasync function request<T>(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n): Promise<CosmosResponse<T>> {\n if (requestContext.body) {\n requestContext.body = bodyFromData(requestContext.body);\n if (!requestContext.body) {\n throw new Error(\"parameter data must be a javascript object, string, or Buffer\");\n }\n }\n\n return addDiagnosticChild(\n async (childNode: DiagnosticNodeInternal) => {\n return RetryUtility.execute({\n diagnosticNode: childNode,\n requestContext,\n executeRequest,\n });\n },\n diagnosticNode,\n DiagnosticNodeType.REQUEST_ATTEMPTS,\n );\n}\n\nexport const RequestHandler = {\n request,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"RequestHandler.js","sourceRoot":"","sources":["../../../src/request/RequestHandler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EA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Licensed under the MIT License.\n\nimport type { PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { createPipelineRequest, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { isReadRequest, prepareURL } from \"../common/index.js\";\nimport { Constants, ResourceType } from \"../common/constants.js\";\nimport { executePlugins, PluginOn } from \"../plugins/Plugin.js\";\nimport * as RetryUtility from \"../retry/retryUtility.js\";\nimport { defaultHttpAgent, defaultHttpsAgent } from \"./defaultAgent.js\";\nimport { ErrorResponse } from \"./ErrorResponse.js\";\nimport { bodyFromData } from \"./request.js\";\nimport type { RequestContext } from \"./RequestContext.js\";\nimport type { Response as CosmosResponse } from \"./Response.js\";\nimport { TimeoutError } from \"./TimeoutError.js\";\nimport { getCachedDefaultHttpClient } from \"../utils/cachedClient.js\";\nimport type { AzureLogger } from \"@azure/logger\";\nimport { createClientLogger } from \"@azure/logger\";\nimport type { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport { DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport { addDiagnosticChild } from \"../utils/diagnostics.js\";\nimport { getCurrentTimestampInMs } from \"../utils/time.js\";\n\nconst logger: AzureLogger = createClientLogger(\"RequestHandler\");\n\nasync function executeRequest(\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n): Promise<CosmosResponse<any>> {\n return executePlugins(diagnosticNode, requestContext, httpRequest, PluginOn.request);\n}\n\n/**\n * @hidden\n */\nasync function httpRequest(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n): Promise<{\n headers: any;\n result: any;\n code: number;\n substatus: number;\n}> {\n const controller = new AbortController();\n const signal = controller.signal;\n\n // Wrap users passed abort events and call our own internal abort()\n const userSignal = requestContext.options && requestContext.options.abortSignal;\n if (userSignal) {\n if (userSignal.aborted) {\n controller.abort();\n } else {\n userSignal.addEventListener(\"abort\", () => {\n controller.abort();\n });\n }\n }\n\n let requestTimeout = requestContext.connectionPolicy.requestTimeout;\n // If the request is a read request and partition level failover or circuit breaker is enabled,\n // set a shorter timeout to allow for quicker failover in case of partition unavailability.\n // This is to ensure that read requests can quickly failover to another partition if the current one is unavailable.\n if (\n (requestContext.connectionPolicy.enablePartitionLevelFailover ||\n requestContext.connectionPolicy.enablePartitionLevelCircuitBreaker) &&\n requestContext.partitionKeyRangeId &&\n requestContext.resourceType === ResourceType.item &&\n isReadRequest(requestContext.operationType)\n ) {\n requestTimeout = Math.min(\n requestContext.connectionPolicy.requestTimeout,\n Constants.RequestTimeoutForReadsInMs,\n );\n }\n const timeout = setTimeout(() => {\n controller.abort();\n }, requestTimeout);\n\n let response: PipelineResponse;\n\n if (requestContext.body) {\n requestContext.body = bodyFromData(requestContext.body);\n }\n\n const httpsClient = requestContext.httpClient ?? getCachedDefaultHttpClient();\n const url = prepareURL(requestContext.endpoint, requestContext.path);\n const reqHeaders = createHttpHeaders(requestContext.headers as any);\n const pipelineRequest = createPipelineRequest({\n url,\n headers: reqHeaders,\n method: requestContext.method,\n abortSignal: signal,\n body: requestContext.body,\n });\n if (requestContext.requestAgent) {\n pipelineRequest.agent = requestContext.requestAgent;\n } else {\n const parsedUrl = new URL(url);\n pipelineRequest.agent = parsedUrl.protocol === \"http:\" ? defaultHttpAgent : defaultHttpsAgent;\n pipelineRequest.allowInsecureConnection = parsedUrl.protocol === \"http:\";\n }\n\n const startTimeUTCInMs = getCurrentTimestampInMs();\n try {\n if (requestContext.pipeline) {\n response = await requestContext.pipeline.sendRequest(httpsClient, pipelineRequest);\n } else {\n response = await httpsClient.sendRequest(pipelineRequest);\n }\n } catch (error: any) {\n if (error.name === \"AbortError\") {\n // If the user passed signal caused the abort, cancel the timeout and rethrow the error\n if (userSignal && userSignal.aborted === true) {\n clearTimeout(timeout);\n throw error;\n }\n throw new TimeoutError(\n `Timeout Error! Request took more than ${requestContext.connectionPolicy.requestTimeout} ms`,\n );\n }\n throw error;\n }\n\n clearTimeout(timeout);\n const result =\n response.status === 204 || response.status === 304 || response.bodyAsText === \"\"\n ? null\n : JSON.parse(response.bodyAsText);\n const responseHeaders = response.headers.toJSON();\n\n const substatus = responseHeaders[Constants.HttpHeaders.SubStatus]\n ? parseInt(responseHeaders[Constants.HttpHeaders.SubStatus], 10)\n : undefined;\n\n diagnosticNode.recordSuccessfulNetworkCall(\n startTimeUTCInMs,\n requestContext,\n response,\n substatus,\n url,\n );\n\n if (response.status >= 400) {\n const errorResponse: ErrorResponse = new ErrorResponse(result.message);\n logger.warning(\n response.status +\n \" \" +\n requestContext.endpoint +\n \" \" +\n requestContext.path +\n \" \" +\n result.message,\n );\n\n errorResponse.code = response.status;\n errorResponse.body = result;\n errorResponse.headers = responseHeaders;\n\n if (Constants.HttpHeaders.ActivityId in responseHeaders) {\n errorResponse.activityId = responseHeaders[Constants.HttpHeaders.ActivityId];\n }\n\n if (Constants.HttpHeaders.SubStatus in responseHeaders) {\n errorResponse.substatus = substatus;\n }\n\n if (Constants.HttpHeaders.RetryAfterInMs in responseHeaders) {\n errorResponse.retryAfterInMs = parseInt(\n responseHeaders[Constants.HttpHeaders.RetryAfterInMs],\n 10,\n );\n Object.defineProperty(errorResponse, \"retryAfterInMilliseconds\", {\n get: () => {\n return errorResponse.retryAfterInMs;\n },\n });\n }\n\n throw errorResponse;\n }\n return {\n headers: responseHeaders,\n result,\n code: response.status,\n substatus,\n };\n}\n\n/**\n * @hidden\n */\nasync function request<T>(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n): Promise<CosmosResponse<T>> {\n if (requestContext.body) {\n requestContext.body = bodyFromData(requestContext.body);\n if (!requestContext.body) {\n throw new Error(\"parameter data must be a javascript object, string, or Buffer\");\n }\n }\n\n return addDiagnosticChild(\n async (childNode: DiagnosticNodeInternal) => {\n return RetryUtility.execute({\n diagnosticNode: childNode,\n requestContext,\n executeRequest,\n });\n },\n diagnosticNode,\n DiagnosticNodeType.REQUEST_ATTEMPTS,\n );\n}\n\nexport const RequestHandler = {\n request,\n};\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js";
|
|
2
|
-
import type { ErrorResponse } from "../request/index.js";
|
|
2
|
+
import type { ErrorResponse, RequestContext } from "../request/index.js";
|
|
3
3
|
import type { RetryContext } from "./RetryContext.js";
|
|
4
4
|
/**
|
|
5
5
|
* @hidden
|
|
6
6
|
*/
|
|
7
7
|
export interface RetryPolicy {
|
|
8
8
|
retryAfterInMs: number;
|
|
9
|
-
shouldRetry: (errorResponse: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext, locationEndpoint?: string) => Promise<boolean | [boolean, string]>;
|
|
9
|
+
shouldRetry: (errorResponse: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext, locationEndpoint?: string, requestContext?: RequestContext) => Promise<boolean | [boolean, string]>;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=RetryPolicy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/RetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"RetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/RetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,CACX,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,sBAAsB,EACtC,YAAY,CAAC,EAAE,YAAY,EAC3B,gBAAgB,CAAC,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,cAAc,KAC5B,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;CAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/RetryPolicy.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport type { ErrorResponse } from \"../request/index.js\";\nimport type { RetryContext } from \"./RetryContext.js\";\n\n/**\n * @hidden\n */\nexport interface RetryPolicy {\n retryAfterInMs: number;\n shouldRetry: (\n errorResponse: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n locationEndpoint?: string,\n ) => Promise<boolean | [boolean, string]>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/RetryPolicy.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport type { ErrorResponse, RequestContext } from \"../request/index.js\";\nimport type { RetryContext } from \"./RetryContext.js\";\n\n/**\n * @hidden\n */\nexport interface RetryPolicy {\n retryAfterInMs: number;\n shouldRetry: (\n errorResponse: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n locationEndpoint?: string,\n requestContext?: RequestContext,\n ) => Promise<boolean | [boolean, string]>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/defaultRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"defaultRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/defaultRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,aAAa,EAAe,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAiHpD;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IAKxC,OAAO,CAAC,aAAa;IAJjC,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,wBAAwB,CAAa;IACtC,cAAc,EAAE,MAAM,CAAQ;gBAEjB,aAAa,EAAE,aAAa;IAChD;;;OAGG;IACU,WAAW,CACtB,GAAG,EAAE,aAAa,EAClB,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,OAAO,CAAC;CAapB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OperationType } from "../common/index.js";
|
|
1
|
+
import { OperationType, StatusCodes } from "../common/index.js";
|
|
2
2
|
import { TimeoutErrorCode } from "../request/TimeoutError.js";
|
|
3
3
|
/**
|
|
4
4
|
* @hidden
|
|
@@ -101,13 +101,9 @@ const CONNECTION_ERROR_CODES = [
|
|
|
101
101
|
* @hidden
|
|
102
102
|
*/
|
|
103
103
|
function needsRetry(operationType, code) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
104
|
+
return (code === StatusCodes.ENOTFOUND ||
|
|
105
|
+
((operationType === OperationType.Read || operationType === OperationType.Query) &&
|
|
106
|
+
CONNECTION_ERROR_CODES.includes(code)));
|
|
111
107
|
}
|
|
112
108
|
/**
|
|
113
109
|
* This class implements the default connection retry policy for requests.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/defaultRetryPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"defaultRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/defaultRetryPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D;;GAEG;AACH,6BAA6B;AAC7B,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAC7C;;GAEG;AACH,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC;;GAEG;AACH,MAAM,uBAAuB,GAAG,KAAK,CAAC;AACtC;;GAEG;AACH,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC;;GAEG;AACH,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC;;GAEG;AACH,MAAM,qCAAqC,GAAG,KAAK,CAAC;AACpD;;GAEG;AACH,MAAM,6BAA6B,GAAG,KAAK,CAAC;AAC5C;;GAEG;AACH,MAAM,0BAA0B,GAAG,KAAK,CAAC;AACzC;;GAEG;AACH,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAC3C;;GAEG;AACH,MAAM,oCAAoC,GAAG,KAAK,CAAC;AACnD;;GAEG;AACH,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC;;GAEG;AACH,MAAM,wBAAwB,GAAG,KAAK,CAAC;AACvC;;GAEG;AACH,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC;;GAEG;AACH,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC;;GAEG;AACH,MAAM,oBAAoB,GAAG,KAAK,CAAC;AACn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BAC7D,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport { OperationType, StatusCodes } from \"../common/index.js\";\nimport type { ErrorResponse } from \"../request/index.js\";\nimport { TimeoutErrorCode } from \"../request/TimeoutError.js\";\nimport type { RetryPolicy } from \"./RetryPolicy.js\";\n\n/**\n * @hidden\n */\n// Windows Socket Error Codes\nconst WindowsInterruptedFunctionCall = 10004;\n/**\n * @hidden\n */\nconst WindowsFileHandleNotValid = 10009;\n/**\n * @hidden\n */\nconst WindowsPermissionDenied = 10013;\n/**\n * @hidden\n */\nconst WindowsBadAddress = 10014;\n/**\n * @hidden\n */\nconst WindowsInvalidArgumnet = 10022;\n/**\n * @hidden\n */\nconst WindowsResourceTemporarilyUnavailable = 10035;\n/**\n * @hidden\n */\nconst WindowsOperationNowInProgress = 10036;\n/**\n * @hidden\n */\nconst WindowsAddressAlreadyInUse = 10048;\n/**\n * @hidden\n */\nconst WindowsConnectionResetByPeer = 10054;\n/**\n * @hidden\n */\nconst WindowsCannotSendAfterSocketShutdown = 10058;\n/**\n * @hidden\n */\nconst WindowsConnectionTimedOut = 10060;\n/**\n * @hidden\n */\nconst WindowsConnectionRefused = 10061;\n/**\n * @hidden\n */\nconst WindowsNameTooLong = 10063;\n/**\n * @hidden\n */\nconst WindowsHostIsDown = 10064;\n/**\n * @hidden\n */\nconst WindowsNoRouteTohost = 10065;\n/**\n * @hidden\n */\n\n// Linux Error Codes\n/**\n * @hidden\n */\nconst LinuxConnectionReset = \"ECONNRESET\";\n\n// Node Error Codes\n/**\n * @hidden\n */\nconst BrokenPipe = \"EPIPE\";\n\n/**\n * @hidden\n */\nconst CONNECTION_ERROR_CODES = [\n WindowsInterruptedFunctionCall,\n WindowsFileHandleNotValid,\n WindowsPermissionDenied,\n WindowsBadAddress,\n WindowsInvalidArgumnet,\n WindowsResourceTemporarilyUnavailable,\n WindowsOperationNowInProgress,\n WindowsAddressAlreadyInUse,\n WindowsConnectionResetByPeer,\n WindowsCannotSendAfterSocketShutdown,\n WindowsConnectionTimedOut,\n WindowsConnectionRefused,\n WindowsNameTooLong,\n WindowsHostIsDown,\n WindowsNoRouteTohost,\n LinuxConnectionReset,\n TimeoutErrorCode,\n BrokenPipe,\n];\n\n/**\n * @hidden\n */\nfunction needsRetry(operationType: OperationType, code: number | string): boolean {\n return (\n code === StatusCodes.ENOTFOUND ||\n ((operationType === OperationType.Read || operationType === OperationType.Query) &&\n CONNECTION_ERROR_CODES.includes(code))\n );\n}\n/**\n * This class implements the default connection retry policy for requests.\n * @hidden\n */\nexport class DefaultRetryPolicy implements RetryPolicy {\n private maxTries: number = 10;\n private currentRetryAttemptCount: number = 0;\n public retryAfterInMs: number = 1000;\n\n constructor(private operationType: OperationType) {}\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<boolean> {\n if (err) {\n if (\n this.currentRetryAttemptCount < this.maxTries &&\n needsRetry(this.operationType, err.code)\n ) {\n diagnosticNode.addData({ successfulRetryPolicy: \"default\" });\n this.currentRetryAttemptCount++;\n return true;\n }\n }\n return false;\n }\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js";
|
|
2
2
|
import type { OperationType } from "../common/index.js";
|
|
3
3
|
import type { GlobalEndpointManager } from "../globalEndpointManager.js";
|
|
4
|
-
import type { ErrorResponse } from "../request/index.js";
|
|
4
|
+
import type { ErrorResponse, RequestContext } from "../request/index.js";
|
|
5
5
|
import type { RetryContext } from "./RetryContext.js";
|
|
6
6
|
import type { RetryPolicy } from "./RetryPolicy.js";
|
|
7
|
+
import { GlobalPartitionEndpointManager } from "../globalPartitionEndpointManager.js";
|
|
7
8
|
/**
|
|
8
9
|
* This class implements the retry policy for endpoint discovery.
|
|
9
10
|
* @hidden
|
|
@@ -11,6 +12,7 @@ import type { RetryPolicy } from "./RetryPolicy.js";
|
|
|
11
12
|
export declare class EndpointDiscoveryRetryPolicy implements RetryPolicy {
|
|
12
13
|
private globalEndpointManager;
|
|
13
14
|
private operationType;
|
|
15
|
+
private globalPartitionEndpointManager?;
|
|
14
16
|
/** Current retry attempt count. */
|
|
15
17
|
currentRetryAttemptCount: number;
|
|
16
18
|
/** Retry interval in milliseconds. */
|
|
@@ -22,11 +24,11 @@ export declare class EndpointDiscoveryRetryPolicy implements RetryPolicy {
|
|
|
22
24
|
/**
|
|
23
25
|
* @param globalEndpointManager - The GlobalEndpointManager instance.
|
|
24
26
|
*/
|
|
25
|
-
constructor(globalEndpointManager: GlobalEndpointManager, operationType: OperationType);
|
|
27
|
+
constructor(globalEndpointManager: GlobalEndpointManager, operationType: OperationType, globalPartitionEndpointManager?: GlobalPartitionEndpointManager);
|
|
26
28
|
/**
|
|
27
29
|
* Determines whether the request should be retried or not.
|
|
28
30
|
* @param err - Error returned by the request.
|
|
29
31
|
*/
|
|
30
|
-
shouldRetry(err: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext, locationEndpoint?: string): Promise<boolean | [boolean, string]>;
|
|
32
|
+
shouldRetry(err: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext, locationEndpoint?: string, requestContext?: RequestContext): Promise<boolean | [boolean, string]>;
|
|
31
33
|
}
|
|
32
34
|
//# sourceMappingURL=endpointDiscoveryRetryPolicy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointDiscoveryRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/endpointDiscoveryRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK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8B;IAOzE;;;OAGG;IACU,WAAW,CACtB,GAAG,EAAE,aAAa,EAClB,cAAc,EAAE,sBAAsB,EACtC,YAAY,CAAC,EAAE,YAAY,EAC3B,gBAAgB,CAAC,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;CA+CxC"}
|
|
@@ -7,9 +7,10 @@ export class EndpointDiscoveryRetryPolicy {
|
|
|
7
7
|
/**
|
|
8
8
|
* @param globalEndpointManager - The GlobalEndpointManager instance.
|
|
9
9
|
*/
|
|
10
|
-
constructor(globalEndpointManager, operationType) {
|
|
10
|
+
constructor(globalEndpointManager, operationType, globalPartitionEndpointManager) {
|
|
11
11
|
this.globalEndpointManager = globalEndpointManager;
|
|
12
12
|
this.operationType = operationType;
|
|
13
|
+
this.globalPartitionEndpointManager = globalPartitionEndpointManager;
|
|
13
14
|
this.maxTries = EndpointDiscoveryRetryPolicy.maxTries;
|
|
14
15
|
this.currentRetryAttemptCount = 0;
|
|
15
16
|
this.retryAfterInMs = EndpointDiscoveryRetryPolicy.retryAfterInMs;
|
|
@@ -18,7 +19,7 @@ export class EndpointDiscoveryRetryPolicy {
|
|
|
18
19
|
* Determines whether the request should be retried or not.
|
|
19
20
|
* @param err - Error returned by the request.
|
|
20
21
|
*/
|
|
21
|
-
async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint) {
|
|
22
|
+
async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint, requestContext) {
|
|
22
23
|
if (!err) {
|
|
23
24
|
return false;
|
|
24
25
|
}
|
|
@@ -28,6 +29,12 @@ export class EndpointDiscoveryRetryPolicy {
|
|
|
28
29
|
if (!this.globalEndpointManager.enableEndpointDiscovery) {
|
|
29
30
|
return false;
|
|
30
31
|
}
|
|
32
|
+
if (this.globalPartitionEndpointManager) {
|
|
33
|
+
const didFailover = await this.globalPartitionEndpointManager.tryPartitionLevelFailover(requestContext, diagnosticNode);
|
|
34
|
+
if (didFailover) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
31
38
|
if (this.currentRetryAttemptCount >= this.maxTries) {
|
|
32
39
|
return false;
|
|
33
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointDiscoveryRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/endpointDiscoveryRetryPolicy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"endpointDiscoveryRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/endpointDiscoveryRetryPolicy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IAWvC;;OAEG;IACH,YACU,qBAA4C,EAC5C,aAA4B,EAC5B,8BAA+D;QAF/D,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,kBAAa,GAAb,aAAa,CAAe;QAC5B,mCAA8B,GAA9B,8BAA8B,CAAiC;QAEvE,IAAI,CAAC,QAAQ,GAAG,4BAA4B,CAAC,QAAQ,CAAC;QACtD,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,4BAA4B,CAAC,cAAc,CAAC;IACpE,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW,CACtB,GAAkB,EAClB,cAAsC,EACtC,YAA2B,EAC3B,gBAAyB,EACzB,cAA+B;QAE/B,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,YAAY,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,uBAAuB,EAAE,CAAC;YACxD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,8BAA8B,EAAE,CAAC;YACxC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,8BAA8B,CAAC,yBAAyB,CACrF,cAAc,EACd,cAAc,CACf,CAAC;YACF,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,wBAAwB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAEhC,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,CAAC,qBAAqB,CAAC,qCAAqC,CACpE,cAAc,EACd,gBAAgB,CACjB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC,qBAAqB,CAAC,sCAAsC,CACrE,cAAc,EACd,gBAAgB,CACjB,CAAC;QACJ,CAAC;QAED,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,wBAAwB,CAAC;QACxD,YAAY,CAAC,6BAA6B,GAAG,KAAK,CAAC;QACnD,YAAY,CAAC,gCAAgC,GAAG,KAAK,CAAC;QACtD,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC;IACd,CAAC;;AAxEuB,qCAAQ,GAAG,GAAG,CAAC,CAAC,kBAAkB;AAClC,2CAAc,GAAG,IAAI,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport type { OperationType } from \"../common/index.js\";\nimport { isReadRequest } from \"../common/helper.js\";\nimport type { GlobalEndpointManager } from \"../globalEndpointManager.js\";\nimport type { ErrorResponse, RequestContext } from \"../request/index.js\";\nimport type { RetryContext } from \"./RetryContext.js\";\nimport type { RetryPolicy } from \"./RetryPolicy.js\";\nimport { GlobalPartitionEndpointManager } from \"../globalPartitionEndpointManager.js\";\n\n/**\n * This class implements the retry policy for endpoint discovery.\n * @hidden\n */\nexport class EndpointDiscoveryRetryPolicy implements RetryPolicy {\n /** Current retry attempt count. */\n public currentRetryAttemptCount: number;\n /** Retry interval in milliseconds. */\n public retryAfterInMs: number;\n\n /** Max number of retry attempts to perform. */\n private maxTries: number;\n private static readonly maxTries = 120; // TODO: Constant?\n private static readonly retryAfterInMs = 1000;\n\n /**\n * @param globalEndpointManager - The GlobalEndpointManager instance.\n */\n constructor(\n private globalEndpointManager: GlobalEndpointManager,\n private operationType: OperationType,\n private globalPartitionEndpointManager?: GlobalPartitionEndpointManager,\n ) {\n this.maxTries = EndpointDiscoveryRetryPolicy.maxTries;\n this.currentRetryAttemptCount = 0;\n this.retryAfterInMs = EndpointDiscoveryRetryPolicy.retryAfterInMs;\n }\n\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n locationEndpoint?: string,\n requestContext?: RequestContext,\n ): Promise<boolean | [boolean, string]> {\n if (!err) {\n return false;\n }\n\n if (!retryContext || !locationEndpoint) {\n return false;\n }\n\n if (!this.globalEndpointManager.enableEndpointDiscovery) {\n return false;\n }\n\n if (this.globalPartitionEndpointManager) {\n const didFailover = await this.globalPartitionEndpointManager.tryPartitionLevelFailover(\n requestContext,\n diagnosticNode,\n );\n if (didFailover) {\n return true;\n }\n }\n\n if (this.currentRetryAttemptCount >= this.maxTries) {\n return false;\n }\n\n this.currentRetryAttemptCount++;\n\n if (isReadRequest(this.operationType)) {\n await this.globalEndpointManager.markCurrentLocationUnavailableForRead(\n diagnosticNode,\n locationEndpoint,\n );\n } else {\n await this.globalEndpointManager.markCurrentLocationUnavailableForWrite(\n diagnosticNode,\n locationEndpoint,\n );\n }\n\n retryContext.retryCount = this.currentRetryAttemptCount;\n retryContext.clearSessionTokenNotAvailable = false;\n retryContext.retryRequestOnPreferredLocations = false;\n diagnosticNode.addData({ successfulRetryPolicy: \"endpointDiscovery\" });\n return true;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryUtility.d.ts","sourceRoot":"","sources":["../../../src/retry/retryUtility.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAEvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E;;GAEG;AACH,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,cAAc,EAAE,sBAAsB,CAAC;IACvC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,CACd,cAAc,EAAE,sBAAsB,EACtC,cAAc,EAAE,cAAc,KAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,UAAU,aAAa;IACrB,4BAA4B,EAAE,4BAA4B,CAAC;IAC3D,2BAA2B,EAAE,2BAA2B,CAAC;IACzD,sBAAsB,EAAE,kBAAkB,CAAC;IAC3C,kBAAkB,EAAE,kBAAkB,CAAC;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3C,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,0BAA0B,EAAE,0BAA0B,CAAC;CACxD;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,EAC5B,cAAc,EACd,YAAgC,EAChC,aAAa,EACb,cAAc,EACd,cAAc,GACf,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAkJtC"}
|
|
@@ -22,11 +22,11 @@ export async function execute({ diagnosticNode, retryContext = { retryCount: 0 }
|
|
|
22
22
|
localDiagnosticNode.addData({ requestAttempNumber: retryContext.retryCount });
|
|
23
23
|
if (!retryPolicies) {
|
|
24
24
|
retryPolicies = {
|
|
25
|
-
endpointDiscoveryRetryPolicy: new EndpointDiscoveryRetryPolicy(requestContext.globalEndpointManager, requestContext.operationType),
|
|
25
|
+
endpointDiscoveryRetryPolicy: new EndpointDiscoveryRetryPolicy(requestContext.globalEndpointManager, requestContext.operationType, requestContext.globalPartitionEndpointManager),
|
|
26
26
|
resourceThrottleRetryPolicy: new ResourceThrottleRetryPolicy((_a = requestContext.connectionPolicy.retryOptions) !== null && _a !== void 0 ? _a : {}),
|
|
27
27
|
sessionReadRetryPolicy: new SessionRetryPolicy(requestContext.globalEndpointManager, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy),
|
|
28
28
|
defaultRetryPolicy: new DefaultRetryPolicy(requestContext.operationType),
|
|
29
|
-
timeoutFailoverRetryPolicy: new TimeoutFailoverRetryPolicy(requestContext.globalEndpointManager, requestContext.headers, requestContext.method, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy.enableEndpointDiscovery),
|
|
29
|
+
timeoutFailoverRetryPolicy: new TimeoutFailoverRetryPolicy(requestContext.globalEndpointManager, requestContext.headers, requestContext.method, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy.enableEndpointDiscovery, requestContext.connectionPolicy.enablePartitionLevelFailover, requestContext.globalPartitionEndpointManager),
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
if (retryContext && retryContext.clearSessionTokenNotAvailable) {
|
|
@@ -41,6 +41,13 @@ export async function execute({ diagnosticNode, retryContext = { retryCount: 0 }
|
|
|
41
41
|
}
|
|
42
42
|
const startTimeUTCInMs = getCurrentTimestampInMs();
|
|
43
43
|
const correlatedActivityId = requestContext.headers[Constants.HttpHeaders.CorrelatedActivityId];
|
|
44
|
+
if (requestContext.globalPartitionEndpointManager) {
|
|
45
|
+
// Try partition level location override
|
|
46
|
+
// This is used to override the partition level location for the request
|
|
47
|
+
// if there has been a partition level failover
|
|
48
|
+
requestContext =
|
|
49
|
+
await requestContext.globalPartitionEndpointManager.tryAddPartitionLevelLocationOverride(requestContext, localDiagnosticNode);
|
|
50
|
+
}
|
|
44
51
|
try {
|
|
45
52
|
const response = await executeRequest(localDiagnosticNode, requestContext);
|
|
46
53
|
response.headers[Constants.ThrottleRetryCount] =
|
|
@@ -59,8 +66,7 @@ export async function execute({ diagnosticNode, retryContext = { retryCount: 0 }
|
|
|
59
66
|
if (correlatedActivityId) {
|
|
60
67
|
headers[Constants.HttpHeaders.CorrelatedActivityId] = correlatedActivityId;
|
|
61
68
|
}
|
|
62
|
-
if (err.code ===
|
|
63
|
-
err.code === "REQUEST_SEND_ERROR" ||
|
|
69
|
+
if (err.code === "REQUEST_SEND_ERROR" ||
|
|
64
70
|
(err.code === StatusCodes.Forbidden &&
|
|
65
71
|
(err.substatus === SubStatusCodes.DatabaseAccountNotFound ||
|
|
66
72
|
err.substatus === SubStatusCodes.WriteForbidden))) {
|
|
@@ -79,7 +85,7 @@ export async function execute({ diagnosticNode, retryContext = { retryCount: 0 }
|
|
|
79
85
|
else {
|
|
80
86
|
retryPolicy = retryPolicies.defaultRetryPolicy;
|
|
81
87
|
}
|
|
82
|
-
const results = await retryPolicy.shouldRetry(err, localDiagnosticNode, retryContext, requestContext.endpoint);
|
|
88
|
+
const results = await retryPolicy.shouldRetry(err, localDiagnosticNode, retryContext, requestContext.endpoint, requestContext);
|
|
83
89
|
if (!results) {
|
|
84
90
|
headers[Constants.ThrottleRetryCount] =
|
|
85
91
|
retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryUtility.js","sourceRoot":"","sources":["../../../src/retry/retryUtility.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAG9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAG/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AA2B7E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,EAC5B,cAAc,EACd,YAAY,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,EAChC,aAAa,EACb,cAAc,EACd,cAAc,GACF;IACZ,qBAAqB;IACrB,OAAO,kBAAkB,CACvB,KAAK,EAAE,mBAA2C,EAAE,EAAE;;QACpD,mBAAmB,CAAC,OAAO,CAAC,EAAE,mBAAmB,EAAE,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,aAAa,EAAE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;oBACzB,cAAc,CAAC,QAAQ,GAAG,MAAM,CAAC;gBACnC,CAAC;gBACD,mBAAmB,CAAC,uBAAuB,CACzC,gBAAgB,EAChB,cAAc,EACd,YAAY,CAAC,UAAU,EACvB,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,cAAc,EAClB,OAAO,CACR,CAAC;gBACF,MAAM,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBACxC,OAAO,OAAO,CAAC;oBACb,cAAc;oBACd,cAAc;oBACd,cAAc;oBACd,YAAY;oBACZ,aAAa;iBACd,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,EACD,cAAc,EACd,kBAAkB,CAAC,YAAY,CAChC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,cAA8B;IACnD,OAAO,CACL,cAAc,CAAC,aAAa,KAAK,OAAO;QACxC,CAAC,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { Constants } from \"../common/constants.js\";\nimport { sleep } from \"../common/helper.js\";\nimport { StatusCodes, SubStatusCodes } from \"../common/statusCodes.js\";\nimport type { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport { DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport type { Response } from \"../request/index.js\";\nimport type { RequestContext } from \"../request/RequestContext.js\";\nimport { TimeoutErrorCode } from \"../request/TimeoutError.js\";\nimport { addDiagnosticChild } from \"../utils/diagnostics.js\";\nimport { getCurrentTimestampInMs } from \"../utils/time.js\";\nimport { DefaultRetryPolicy } from \"./defaultRetryPolicy.js\";\nimport { EndpointDiscoveryRetryPolicy } from \"./endpointDiscoveryRetryPolicy.js\";\nimport { ResourceThrottleRetryPolicy } from \"./resourceThrottleRetryPolicy.js\";\nimport type { RetryContext } from \"./RetryContext.js\";\nimport type { RetryPolicy } from \"./RetryPolicy.js\";\nimport { SessionRetryPolicy } from \"./sessionRetryPolicy.js\";\nimport { TimeoutFailoverRetryPolicy } from \"./timeoutFailoverRetryPolicy.js\";\n\n/**\n * @hidden\n */\ninterface ExecuteArgs {\n retryContext?: RetryContext;\n diagnosticNode: DiagnosticNodeInternal;\n retryPolicies?: RetryPolicies;\n requestContext: RequestContext;\n executeRequest: (\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n ) => Promise<Response<any>>;\n}\n\n/**\n * @hidden\n */\ninterface RetryPolicies {\n endpointDiscoveryRetryPolicy: EndpointDiscoveryRetryPolicy;\n resourceThrottleRetryPolicy: ResourceThrottleRetryPolicy;\n sessionReadRetryPolicy: SessionRetryPolicy;\n defaultRetryPolicy: DefaultRetryPolicy;\n timeoutFailoverRetryPolicy: TimeoutFailoverRetryPolicy;\n}\n\n/**\n * @hidden\n */\nexport async function execute({\n diagnosticNode,\n retryContext = { retryCount: 0 },\n retryPolicies,\n requestContext,\n executeRequest,\n}: ExecuteArgs): Promise<Response<any>> {\n // TODO: any response\n return addDiagnosticChild(\n async (localDiagnosticNode: DiagnosticNodeInternal) => {\n localDiagnosticNode.addData({ requestAttempNumber: retryContext.retryCount });\n if (!retryPolicies) {\n retryPolicies = {\n endpointDiscoveryRetryPolicy: new EndpointDiscoveryRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.operationType,\n ),\n resourceThrottleRetryPolicy: new ResourceThrottleRetryPolicy(\n requestContext.connectionPolicy.retryOptions ?? {},\n ),\n sessionReadRetryPolicy: new SessionRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.resourceType,\n requestContext.operationType,\n requestContext.connectionPolicy,\n ),\n defaultRetryPolicy: new DefaultRetryPolicy(requestContext.operationType),\n timeoutFailoverRetryPolicy: new TimeoutFailoverRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.headers,\n requestContext.method,\n requestContext.resourceType,\n requestContext.operationType,\n requestContext.connectionPolicy.enableEndpointDiscovery,\n ),\n };\n }\n if (retryContext && retryContext.clearSessionTokenNotAvailable) {\n requestContext.client.clearSessionToken(requestContext.path);\n delete requestContext.headers[\"x-ms-session-token\"];\n }\n if (retryContext && retryContext.retryLocationServerIndex) {\n requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(\n localDiagnosticNode,\n requestContext.resourceType,\n requestContext.operationType,\n retryContext.retryLocationServerIndex,\n );\n } else {\n requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(\n localDiagnosticNode,\n requestContext.resourceType,\n requestContext.operationType,\n );\n }\n const startTimeUTCInMs = getCurrentTimestampInMs();\n const correlatedActivityId =\n requestContext.headers[Constants.HttpHeaders.CorrelatedActivityId];\n try {\n const response = await executeRequest(localDiagnosticNode, requestContext);\n response.headers[Constants.ThrottleRetryCount] =\n retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;\n response.headers[Constants.ThrottleRetryWaitTimeInMs] =\n retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs;\n if (correlatedActivityId) {\n response.headers[Constants.HttpHeaders.CorrelatedActivityId] = correlatedActivityId;\n }\n return response;\n } catch (err: any) {\n // TODO: any error\n let retryPolicy: RetryPolicy = null;\n const headers = err.headers || {};\n if (correlatedActivityId) {\n headers[Constants.HttpHeaders.CorrelatedActivityId] = correlatedActivityId;\n }\n if (\n err.code === StatusCodes.ENOTFOUND ||\n err.code === \"REQUEST_SEND_ERROR\" ||\n (err.code === StatusCodes.Forbidden &&\n (err.substatus === SubStatusCodes.DatabaseAccountNotFound ||\n err.substatus === SubStatusCodes.WriteForbidden))\n ) {\n retryPolicy = retryPolicies.endpointDiscoveryRetryPolicy;\n } else if (err.code === StatusCodes.TooManyRequests && !isBulkRequest(requestContext)) {\n retryPolicy = retryPolicies.resourceThrottleRetryPolicy;\n } else if (\n err.code === StatusCodes.NotFound &&\n err.substatus === SubStatusCodes.ReadSessionNotAvailable\n ) {\n retryPolicy = retryPolicies.sessionReadRetryPolicy;\n } else if (err.code === StatusCodes.ServiceUnavailable || err.code === TimeoutErrorCode) {\n retryPolicy = retryPolicies.timeoutFailoverRetryPolicy;\n } else {\n retryPolicy = retryPolicies.defaultRetryPolicy;\n }\n const results = await retryPolicy.shouldRetry(\n err,\n localDiagnosticNode,\n retryContext,\n requestContext.endpoint,\n );\n if (!results) {\n headers[Constants.ThrottleRetryCount] =\n retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;\n headers[Constants.ThrottleRetryWaitTimeInMs] =\n retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs;\n err.headers = { ...err.headers, ...headers };\n throw err;\n } else {\n requestContext.retryCount++;\n const newUrl = (results as any)[1]; // TODO: any hack\n if (newUrl !== undefined) {\n requestContext.endpoint = newUrl;\n }\n localDiagnosticNode.recordFailedNetworkCall(\n startTimeUTCInMs,\n requestContext,\n retryContext.retryCount,\n err.code,\n err.subsstatusCode,\n headers,\n );\n await sleep(retryPolicy.retryAfterInMs);\n return execute({\n diagnosticNode,\n executeRequest,\n requestContext,\n retryContext,\n retryPolicies,\n });\n }\n }\n },\n diagnosticNode,\n DiagnosticNodeType.HTTP_REQUEST,\n );\n}\n\n/**\n * @hidden\n */\nfunction isBulkRequest(requestContext: RequestContext): boolean {\n return (\n requestContext.operationType === \"batch\" &&\n !requestContext.headers[Constants.HttpHeaders.IsBatchAtomic]\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"retryUtility.js","sourceRoot":"","sources":["../../../src/retry/retryUtility.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;A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ACR,CAAC;gBACF,MAAM,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBACxC,OAAO,OAAO,CAAC;oBACb,cAAc;oBACd,cAAc;oBACd,cAAc;oBACd,YAAY;oBACZ,aAAa;iBACd,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,EACD,cAAc,EACd,kBAAkB,CAAC,YAAY,CAChC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,cAA8B;IACnD,OAAO,CACL,cAAc,CAAC,aAAa,KAAK,OAAO;QACxC,CAAC,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { Constants } from \"../common/constants.js\";\nimport { sleep } from \"../common/helper.js\";\nimport { StatusCodes, SubStatusCodes } from \"../common/statusCodes.js\";\nimport type { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport { DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal.js\";\nimport type { Response } from \"../request/index.js\";\nimport type { RequestContext } from \"../request/RequestContext.js\";\nimport { TimeoutErrorCode } from \"../request/TimeoutError.js\";\nimport { addDiagnosticChild } from \"../utils/diagnostics.js\";\nimport { getCurrentTimestampInMs } from \"../utils/time.js\";\nimport { DefaultRetryPolicy } from \"./defaultRetryPolicy.js\";\nimport { EndpointDiscoveryRetryPolicy } from \"./endpointDiscoveryRetryPolicy.js\";\nimport { ResourceThrottleRetryPolicy } from \"./resourceThrottleRetryPolicy.js\";\nimport type { RetryContext } from \"./RetryContext.js\";\nimport type { RetryPolicy } from \"./RetryPolicy.js\";\nimport { SessionRetryPolicy } from \"./sessionRetryPolicy.js\";\nimport { TimeoutFailoverRetryPolicy } from \"./timeoutFailoverRetryPolicy.js\";\n\n/**\n * @hidden\n */\ninterface ExecuteArgs {\n retryContext?: RetryContext;\n diagnosticNode: DiagnosticNodeInternal;\n retryPolicies?: RetryPolicies;\n requestContext: RequestContext;\n executeRequest: (\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n ) => Promise<Response<any>>;\n}\n\n/**\n * @hidden\n */\ninterface RetryPolicies {\n endpointDiscoveryRetryPolicy: EndpointDiscoveryRetryPolicy;\n resourceThrottleRetryPolicy: ResourceThrottleRetryPolicy;\n sessionReadRetryPolicy: SessionRetryPolicy;\n defaultRetryPolicy: DefaultRetryPolicy;\n timeoutFailoverRetryPolicy: TimeoutFailoverRetryPolicy;\n}\n\n/**\n * @hidden\n */\nexport async function execute({\n diagnosticNode,\n retryContext = { retryCount: 0 },\n retryPolicies,\n requestContext,\n executeRequest,\n}: ExecuteArgs): Promise<Response<any>> {\n // TODO: any response\n return addDiagnosticChild(\n async (localDiagnosticNode: DiagnosticNodeInternal) => {\n localDiagnosticNode.addData({ requestAttempNumber: retryContext.retryCount });\n if (!retryPolicies) {\n retryPolicies = {\n endpointDiscoveryRetryPolicy: new EndpointDiscoveryRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.operationType,\n requestContext.globalPartitionEndpointManager,\n ),\n resourceThrottleRetryPolicy: new ResourceThrottleRetryPolicy(\n requestContext.connectionPolicy.retryOptions ?? {},\n ),\n sessionReadRetryPolicy: new SessionRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.resourceType,\n requestContext.operationType,\n requestContext.connectionPolicy,\n ),\n defaultRetryPolicy: new DefaultRetryPolicy(requestContext.operationType),\n timeoutFailoverRetryPolicy: new TimeoutFailoverRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.headers,\n requestContext.method,\n requestContext.resourceType,\n requestContext.operationType,\n requestContext.connectionPolicy.enableEndpointDiscovery,\n requestContext.connectionPolicy.enablePartitionLevelFailover,\n requestContext.globalPartitionEndpointManager,\n ),\n };\n }\n if (retryContext && retryContext.clearSessionTokenNotAvailable) {\n requestContext.client.clearSessionToken(requestContext.path);\n delete requestContext.headers[\"x-ms-session-token\"];\n }\n if (retryContext && retryContext.retryLocationServerIndex) {\n requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(\n localDiagnosticNode,\n requestContext.resourceType,\n requestContext.operationType,\n retryContext.retryLocationServerIndex,\n );\n } else {\n requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(\n localDiagnosticNode,\n requestContext.resourceType,\n requestContext.operationType,\n );\n }\n const startTimeUTCInMs = getCurrentTimestampInMs();\n const correlatedActivityId =\n requestContext.headers[Constants.HttpHeaders.CorrelatedActivityId];\n\n if (requestContext.globalPartitionEndpointManager) {\n // Try partition level location override\n // This is used to override the partition level location for the request\n // if there has been a partition level failover\n requestContext =\n await requestContext.globalPartitionEndpointManager.tryAddPartitionLevelLocationOverride(\n requestContext,\n localDiagnosticNode,\n );\n }\n\n try {\n const response = await executeRequest(localDiagnosticNode, requestContext);\n response.headers[Constants.ThrottleRetryCount] =\n retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;\n response.headers[Constants.ThrottleRetryWaitTimeInMs] =\n retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs;\n if (correlatedActivityId) {\n response.headers[Constants.HttpHeaders.CorrelatedActivityId] = correlatedActivityId;\n }\n return response;\n } catch (err: any) {\n // TODO: any error\n let retryPolicy: RetryPolicy = null;\n const headers = err.headers || {};\n if (correlatedActivityId) {\n headers[Constants.HttpHeaders.CorrelatedActivityId] = correlatedActivityId;\n }\n\n if (\n err.code === \"REQUEST_SEND_ERROR\" ||\n (err.code === StatusCodes.Forbidden &&\n (err.substatus === SubStatusCodes.DatabaseAccountNotFound ||\n err.substatus === SubStatusCodes.WriteForbidden))\n ) {\n retryPolicy = retryPolicies.endpointDiscoveryRetryPolicy;\n } else if (err.code === StatusCodes.TooManyRequests && !isBulkRequest(requestContext)) {\n retryPolicy = retryPolicies.resourceThrottleRetryPolicy;\n } else if (\n err.code === StatusCodes.NotFound &&\n err.substatus === SubStatusCodes.ReadSessionNotAvailable\n ) {\n retryPolicy = retryPolicies.sessionReadRetryPolicy;\n } else if (err.code === StatusCodes.ServiceUnavailable || err.code === TimeoutErrorCode) {\n retryPolicy = retryPolicies.timeoutFailoverRetryPolicy;\n } else {\n retryPolicy = retryPolicies.defaultRetryPolicy;\n }\n const results = await retryPolicy.shouldRetry(\n err,\n localDiagnosticNode,\n retryContext,\n requestContext.endpoint,\n requestContext,\n );\n if (!results) {\n headers[Constants.ThrottleRetryCount] =\n retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;\n headers[Constants.ThrottleRetryWaitTimeInMs] =\n retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs;\n err.headers = { ...err.headers, ...headers };\n throw err;\n } else {\n requestContext.retryCount++;\n const newUrl = (results as any)[1]; // TODO: any hack\n if (newUrl !== undefined) {\n requestContext.endpoint = newUrl;\n }\n localDiagnosticNode.recordFailedNetworkCall(\n startTimeUTCInMs,\n requestContext,\n retryContext.retryCount,\n err.code,\n err.subsstatusCode,\n headers,\n );\n await sleep(retryPolicy.retryAfterInMs);\n return execute({\n diagnosticNode,\n executeRequest,\n requestContext,\n retryContext,\n retryPolicies,\n });\n }\n }\n },\n diagnosticNode,\n DiagnosticNodeType.HTTP_REQUEST,\n );\n}\n\n/**\n * @hidden\n */\nfunction isBulkRequest(requestContext: RequestContext): boolean {\n return (\n requestContext.operationType === \"batch\" &&\n !requestContext.headers[Constants.HttpHeaders.IsBatchAtomic]\n );\n}\n"]}
|
|
@@ -4,8 +4,9 @@ import { HTTPMethod } from "../common/index.js";
|
|
|
4
4
|
import type { OperationType, ResourceType } from "../common/constants.js";
|
|
5
5
|
import type { RetryContext } from "./RetryContext.js";
|
|
6
6
|
import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders.js";
|
|
7
|
-
import type { ErrorResponse } from "../request/index.js";
|
|
7
|
+
import type { ErrorResponse, RequestContext } from "../request/index.js";
|
|
8
8
|
import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js";
|
|
9
|
+
import { GlobalPartitionEndpointManager } from "../globalPartitionEndpointManager.js";
|
|
9
10
|
/**
|
|
10
11
|
* This class TimeoutFailoverRetryPolicy handles retries for read operations
|
|
11
12
|
* (including data plane,metadata, and query plan) in case of request timeouts
|
|
@@ -20,20 +21,22 @@ export declare class TimeoutFailoverRetryPolicy implements RetryPolicy {
|
|
|
20
21
|
private resourceType;
|
|
21
22
|
private operationType;
|
|
22
23
|
private enableEndPointDiscovery;
|
|
24
|
+
private enablePartitionLevelFailover;
|
|
25
|
+
private globalPartitionEndpointManager?;
|
|
23
26
|
private maxRetryAttemptCount;
|
|
24
27
|
private maxServiceUnavailableRetryCount;
|
|
25
28
|
retryAfterInMs: number;
|
|
26
29
|
failoverRetryCount: number;
|
|
27
30
|
request: any;
|
|
28
31
|
locationEndpoint: any;
|
|
29
|
-
constructor(globalEndpointManager: GlobalEndpointManager, headers: CosmosHeaders, methodType: HTTPMethod, resourceType: ResourceType, operationType: OperationType, enableEndPointDiscovery: boolean);
|
|
32
|
+
constructor(globalEndpointManager: GlobalEndpointManager, headers: CosmosHeaders, methodType: HTTPMethod, resourceType: ResourceType, operationType: OperationType, enableEndPointDiscovery: boolean, enablePartitionLevelFailover: boolean, globalPartitionEndpointManager?: GlobalPartitionEndpointManager);
|
|
30
33
|
/**
|
|
31
34
|
* Checks if a timeout request is valid for the timeout failover retry policy.
|
|
32
35
|
* A valid request should be a data plane, metadata, or query plan request.
|
|
33
36
|
* @returns
|
|
34
37
|
*/
|
|
35
38
|
private isValidRequestForTimeoutError;
|
|
36
|
-
shouldRetry(err: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext, locationEndpoint?: string): Promise<boolean>;
|
|
39
|
+
shouldRetry(err: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext, locationEndpoint?: string, requestContext?: RequestContext): Promise<boolean>;
|
|
37
40
|
/**
|
|
38
41
|
* Determines index of endpoint to be used for retry based upon failoverRetryCount and avalable locations
|
|
39
42
|
* @param failoverRetryCount - count of failovers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeoutFailoverRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/timeoutFailoverRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"timeoutFailoverRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/timeoutFailoverRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAEtF;;;;;;GAMG;AACH,qBAAa,0BAA2B,YAAW,WAAW;IAS1D,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,uBAAuB;IAC/B,OAAO,CAAC,4BAA4B;IACpC,OAAO,CAAC,8BAA8B,CAAC;IAfzC,OAAO,CAAC,oBAAoB,CAAO;IACnC,OAAO,CAAC,+BAA+B,CAAK;IACrC,cAAc,SAAK;IACnB,kBAAkB,SAAK;IACvB,OAAO,EAAE,GAAG,CAAC;IACb,gBAAgB,EAAE,GAAG,CAAC;gBAGnB,qBAAqB,EAAE,qBAAqB,EAC5C,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,uBAAuB,EAAE,OAAO,EAChC,4BAA4B,EAAE,OAAO,EACrC,8BAA8B,CAAC,EAAE,8BAA8B;IAGzE;;;;OAIG;IACH,OAAO,CAAC,6BAA6B;IASxB,WAAW,CACtB,GAAG,EAAE,aAAa,EAClB,cAAc,EAAE,sBAAsB,EACtC,YAAY,CAAC,EAAE,YAAY,EAC3B,gBAAgB,CAAC,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,OAAO,CAAC;IAoDnB;;;;OAIG;YACW,iBAAiB;CAyBhC"}
|
|
@@ -10,13 +10,15 @@ import { TimeoutErrorCode } from "../request/TimeoutError.js";
|
|
|
10
10
|
* @hidden
|
|
11
11
|
*/
|
|
12
12
|
export class TimeoutFailoverRetryPolicy {
|
|
13
|
-
constructor(globalEndpointManager, headers, methodType, resourceType, operationType, enableEndPointDiscovery) {
|
|
13
|
+
constructor(globalEndpointManager, headers, methodType, resourceType, operationType, enableEndPointDiscovery, enablePartitionLevelFailover, globalPartitionEndpointManager) {
|
|
14
14
|
this.globalEndpointManager = globalEndpointManager;
|
|
15
15
|
this.headers = headers;
|
|
16
16
|
this.methodType = methodType;
|
|
17
17
|
this.resourceType = resourceType;
|
|
18
18
|
this.operationType = operationType;
|
|
19
19
|
this.enableEndPointDiscovery = enableEndPointDiscovery;
|
|
20
|
+
this.enablePartitionLevelFailover = enablePartitionLevelFailover;
|
|
21
|
+
this.globalPartitionEndpointManager = globalPartitionEndpointManager;
|
|
20
22
|
this.maxRetryAttemptCount = 120;
|
|
21
23
|
this.maxServiceUnavailableRetryCount = 1;
|
|
22
24
|
this.retryAfterInMs = 0;
|
|
@@ -35,13 +37,18 @@ export class TimeoutFailoverRetryPolicy {
|
|
|
35
37
|
}
|
|
36
38
|
return false;
|
|
37
39
|
}
|
|
38
|
-
async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint) {
|
|
40
|
+
async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint, requestContext) {
|
|
39
41
|
if (!err) {
|
|
40
42
|
return false;
|
|
41
43
|
}
|
|
42
44
|
if (!retryContext || !locationEndpoint) {
|
|
43
45
|
return false;
|
|
44
46
|
}
|
|
47
|
+
// Mark the partition as unavailable.
|
|
48
|
+
// Let the Retry logic decide if the request should be retried
|
|
49
|
+
if (requestContext && this.globalPartitionEndpointManager) {
|
|
50
|
+
await this.globalPartitionEndpointManager.tryPartitionLevelFailover(requestContext, diagnosticNode);
|
|
51
|
+
}
|
|
45
52
|
// Check if the error is a timeout error (TimeoutErrorCode) and if it is not a valid HTTP network timeout request
|
|
46
53
|
if (err.code === TimeoutErrorCode && !this.isValidRequestForTimeoutError()) {
|
|
47
54
|
return false;
|
|
@@ -58,8 +65,9 @@ export class TimeoutFailoverRetryPolicy {
|
|
|
58
65
|
}
|
|
59
66
|
const canUseMultipleWriteLocations = this.globalEndpointManager.canUseMultipleWriteLocations(this.resourceType, this.operationType);
|
|
60
67
|
const readRequest = isReadRequest(this.operationType);
|
|
61
|
-
if (!canUseMultipleWriteLocations && !readRequest) {
|
|
62
|
-
// Write requests on single master cannot be retried
|
|
68
|
+
if (!canUseMultipleWriteLocations && !readRequest && !this.enablePartitionLevelFailover) {
|
|
69
|
+
// Write requests on single master cannot be retried if partition level failover is disabled.
|
|
70
|
+
// This means there are no other regions available to serve the writes.
|
|
63
71
|
return false;
|
|
64
72
|
}
|
|
65
73
|
this.failoverRetryCount++;
|