@azure/cosmos 4.4.1 → 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 +1 -0
- package/dist/browser/client/Item/Items.d.ts.map +1 -1
- package/dist/browser/client/Item/Items.js +20 -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/documents/PartitionKeyDefinition.d.ts +1 -1
- package/dist/browser/documents/PartitionKeyDefinition.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/hybridQueryExecutionContext.d.ts +3 -1
- package/dist/browser/queryExecutionContext/hybridQueryExecutionContext.d.ts.map +1 -1
- package/dist/browser/queryExecutionContext/hybridQueryExecutionContext.js +10 -2
- package/dist/browser/queryExecutionContext/hybridQueryExecutionContext.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.d.ts.map +1 -1
- package/dist/browser/queryIterator.js +2 -3
- 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 +1 -0
- package/dist/commonjs/client/Item/Items.d.ts.map +1 -1
- package/dist/commonjs/client/Item/Items.js +18 -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/documents/PartitionKeyDefinition.d.ts +1 -1
- package/dist/commonjs/documents/PartitionKeyDefinition.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/hybridQueryExecutionContext.d.ts +3 -1
- package/dist/commonjs/queryExecutionContext/hybridQueryExecutionContext.d.ts.map +1 -1
- package/dist/commonjs/queryExecutionContext/hybridQueryExecutionContext.js +10 -2
- package/dist/commonjs/queryExecutionContext/hybridQueryExecutionContext.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.d.ts.map +1 -1
- package/dist/commonjs/queryIterator.js +2 -3
- 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/tsdoc-metadata.json +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 +1 -0
- package/dist/esm/client/Item/Items.d.ts.map +1 -1
- package/dist/esm/client/Item/Items.js +20 -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/documents/PartitionKeyDefinition.d.ts +1 -1
- package/dist/esm/documents/PartitionKeyDefinition.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/hybridQueryExecutionContext.d.ts +3 -1
- package/dist/esm/queryExecutionContext/hybridQueryExecutionContext.d.ts.map +1 -1
- package/dist/esm/queryExecutionContext/hybridQueryExecutionContext.js +10 -2
- package/dist/esm/queryExecutionContext/hybridQueryExecutionContext.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.d.ts.map +1 -1
- package/dist/esm/queryIterator.js +2 -3
- 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 +1 -0
- package/dist/react-native/client/Item/Items.d.ts.map +1 -1
- package/dist/react-native/client/Item/Items.js +20 -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/documents/PartitionKeyDefinition.d.ts +1 -1
- package/dist/react-native/documents/PartitionKeyDefinition.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/hybridQueryExecutionContext.d.ts +3 -1
- package/dist/react-native/queryExecutionContext/hybridQueryExecutionContext.d.ts.map +1 -1
- package/dist/react-native/queryExecutionContext/hybridQueryExecutionContext.js +10 -2
- package/dist/react-native/queryExecutionContext/hybridQueryExecutionContext.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.d.ts.map +1 -1
- package/dist/react-native/queryIterator.js +2 -3
- 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 +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorResponse.js","sourceRoot":"","sources":["../../../src/request/ErrorResponse.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ErrorResponse.js","sourceRoot":"","sources":["../../../src/request/ErrorResponse.ts"],"names":[],"mappings":";;;AAwGA;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;CAsBvC;AAtBD,sCAsBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { CosmosDiagnostics, CosmosHeaders } from \"../index.js\";\n\nexport interface ErrorBody {\n code: string;\n message: string;\n /**\n * @hidden\n */\n additionalErrorInfo?: PartitionedQueryExecutionInfo;\n}\n\n/**\n * @hidden\n */\nexport interface PartitionedQueryExecutionInfo {\n partitionedQueryExecutionInfoVersion: number;\n queryInfo?: QueryInfo;\n /**\n * Represents hybrid query information.\n */\n hybridSearchQueryInfo?: HybridSearchQueryInfo;\n queryRanges: QueryRange[];\n}\n\n/**\n * @hidden\n */\nexport interface QueryRange {\n min: string;\n max: string;\n isMinInclusive: boolean;\n isMaxInclusive: boolean;\n}\n\n/**\n * @hidden\n */\nexport interface QueryInfo {\n top?: any;\n orderBy?: any[];\n orderByExpressions?: any[];\n offset?: number;\n limit?: number;\n aggregates?: AggregateType[];\n groupByExpressions?: GroupByExpressions;\n groupByAliasToAggregateType: GroupByAliasToAggregateType;\n rewrittenQuery?: any;\n distinctType: string;\n hasSelectValue: boolean;\n /**\n * determines whether the query is of non streaming orderby type.\n */\n hasNonStreamingOrderBy: boolean;\n}\n\n/**\n * @hidden\n * Represents the hybrid search query information\n */\nexport interface HybridSearchQueryInfo {\n /**\n * The query to be used for fetching global statistics\n */\n globalStatisticsQuery: string;\n /**\n * Query information for the subsequent queries\n */\n componentQueryInfos: QueryInfo[];\n /**\n * The number of results in the final result set\n */\n take: number;\n /**\n * The number of results to skip in the final result set\n */\n skip: number;\n /**\n * Whether the query requires global statistics\n */\n requiresGlobalStatistics: boolean;\n /**\n * Represents the weights for each component in a hybrid search query.\n */\n componentWeights?: number[];\n}\n\nexport type GroupByExpressions = string[];\n\nexport type AggregateType =\n | \"Average\"\n | \"Count\"\n | \"Max\"\n | \"Min\"\n | \"Sum\"\n | \"MakeSet\"\n | \"MakeList\"\n | \"CountIf\";\n\nexport interface GroupByAliasToAggregateType {\n [key: string]: AggregateType;\n}\n\n/**\n * Represents an error response returned in operations.\n */\nexport class ErrorResponse extends Error {\n /** status or error code returned */\n code?: number | string;\n /** substatus code returned */\n substatus?: number;\n /** body of the error response, typically including error details */\n body?: ErrorBody;\n /** HTTP headers */\n headers?: CosmosHeaders;\n /** unique identifier for the operation's activity */\n activityId?: string;\n /** delay (in milliseconds) before retrying the operation. */\n retryAfterInMs?: number;\n /** delay (in milliseconds) before retrying the operation. */\n /** Note: Use retryAfterInMs instead */\n retryAfterInMilliseconds?: number;\n /** any additional property */\n [key: string]: any;\n /** Detailed diagnostic information associated with the error.*/\n diagnostics?: CosmosDiagnostics;\n /** The request charge of the operation, representing the resource cost incurred.*/\n requestCharge?: number;\n}\n"]}
|
|
@@ -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;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,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M,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,KAAK,CAAC;IACpB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC;IACtC,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;OAEG;IACH,8BAA8B,CAAC,EAAE,8BAA8B,CAAC;CACjE"}
|
|
@@ -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"}
|
|
@@ -41,9 +41,20 @@ async function httpRequest(requestContext, diagnosticNode) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
let requestTimeout = requestContext.connectionPolicy.requestTimeout;
|
|
45
|
+
// If the request is a read request and partition level failover or circuit breaker is enabled,
|
|
46
|
+
// set a shorter timeout to allow for quicker failover in case of partition unavailability.
|
|
47
|
+
// This is to ensure that read requests can quickly failover to another partition if the current one is unavailable.
|
|
48
|
+
if ((requestContext.connectionPolicy.enablePartitionLevelFailover ||
|
|
49
|
+
requestContext.connectionPolicy.enablePartitionLevelCircuitBreaker) &&
|
|
50
|
+
requestContext.partitionKeyRangeId &&
|
|
51
|
+
requestContext.resourceType === constants_js_1.ResourceType.item &&
|
|
52
|
+
(0, index_js_1.isReadRequest)(requestContext.operationType)) {
|
|
53
|
+
requestTimeout = Math.min(requestContext.connectionPolicy.requestTimeout, constants_js_1.Constants.RequestTimeoutForReadsInMs);
|
|
54
|
+
}
|
|
44
55
|
const timeout = setTimeout(() => {
|
|
45
56
|
controller.abort();
|
|
46
|
-
},
|
|
57
|
+
}, requestTimeout);
|
|
47
58
|
let response;
|
|
48
59
|
if (requestContext.body) {
|
|
49
60
|
requestContext.body = (0, request_js_1.bodyFromData)(requestContext.body);
|
|
@@ -82,7 +93,6 @@ async function httpRequest(requestContext, diagnosticNode) {
|
|
|
82
93
|
clearTimeout(timeout);
|
|
83
94
|
throw error;
|
|
84
95
|
}
|
|
85
|
-
// If the user didn't cancel, it must be an abort we called due to timeout
|
|
86
96
|
throw new TimeoutError_js_1.TimeoutError(`Timeout Error! Request took more than ${requestContext.connectionPolicy.requestTimeout} ms`);
|
|
87
97
|
}
|
|
88
98
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestHandler.js","sourceRoot":"","sources":["../../../src/request/RequestHandler.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAGlC,kEAAqF;AACrF,iDAAgD;AAChD,yDAAmD;AACnD,oDAAgE;AAChE,+EAAyD;AACzD,uDAAwE;AACxE,yDAAmD;AACnD,6CAA4C;AAG5C,uDAAiD;AACjD,8DAAsE;AAEtE,0CAAmD;AAEnD,wFAA8E;AAC9E,4DAA6D;AAC7D,8CAA2D;AAE3D,MAAM,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AC;IACL,CAAC,EACD,cAAc,EACd,8CAAkB,CAAC,gBAAgB,CACpC,CAAC;AACJ,CAAC;AAEY,QAAA,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,kEAAqF;AACrF,iDAA+D;AAC/D,yDAAiE;AACjE,oDAAgE;AAChE,+EAAyD;A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AO;QACL,OAAO,EAAE,eAAe;QACxB,MAAM;QACN,IAAI,EAAE,QAAQ,CAAC,MAAM;QACrB,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,OAAO,CACpB,cAA8B,EAC9B,cAAsC;IAEtC,IAAI,cAAc,CAAC,IAAI,EAAE,CAAC;QACxB,cAAc,CAAC,IAAI,GAAG,IAAA,yBAAY,EAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACxD,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;IAED,OAAO,IAAA,mCAAkB,EACvB,KAAK,EAAE,SAAiC,EAAE,EAAE;QAC1C,OAAO,YAAY,CAAC,OAAO,CAAC;YAC1B,cAAc,EAAE,SAAS;YACzB,cAAc;YACd,cAAc;SACf,CAAC,CAAC;IACL,CAAC,EACD,cAAc,EACd,8CAAkB,CAAC,gBAAgB,CACpC,CAAC;AACJ,CAAC;AAEY,QAAA,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 { 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"]}
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultHttpAgent = exports.defaultHttpsAgent = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const node_https_1 = tslib_1.__importDefault(require("node:https"));
|
|
6
|
+
const node_http_1 = tslib_1.__importDefault(require("node:http"));
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
exports.defaultHttpsAgent = new
|
|
10
|
+
exports.defaultHttpsAgent = new node_https_1.default.Agent({
|
|
11
11
|
keepAlive: true,
|
|
12
12
|
minVersion: "TLSv1.2",
|
|
13
13
|
});
|
|
14
14
|
/**
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
|
-
exports.defaultHttpAgent = new
|
|
17
|
+
exports.defaultHttpAgent = new node_http_1.default.Agent({
|
|
18
18
|
keepAlive: true,
|
|
19
19
|
});
|
|
20
20
|
//# sourceMappingURL=defaultAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultAgent.js","sourceRoot":"","sources":["../../../src/request/defaultAgent.ts"],"names":[],"mappings":";;;;AAGA,
|
|
1
|
+
{"version":3,"file":"defaultAgent.js","sourceRoot":"","sources":["../../../src/request/defaultAgent.ts"],"names":[],"mappings":";;;;AAGA,oEAA+B;AAC/B,kEAA6B;AAE7B;;GAEG;AACU,QAAA,iBAAiB,GAAU,IAAI,oBAAK,CAAC,KAAK,CAAC;IACtD,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,SAAS;CACtB,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,gBAAgB,GAAU,IAAI,mBAAI,CAAC,KAAK,CAAC;IACpD,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Agent } from \"node:http\";\nimport https from \"node:https\";\nimport http from \"node:http\";\n\n/**\n * @internal\n */\nexport const defaultHttpsAgent: Agent = new https.Agent({\n keepAlive: true,\n minVersion: \"TLSv1.2\",\n});\n\n/**\n * @internal\n */\nexport const defaultHttpAgent: Agent = new http.Agent({\n keepAlive: true,\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"}
|
|
@@ -104,13 +104,9 @@ const CONNECTION_ERROR_CODES = [
|
|
|
104
104
|
* @hidden
|
|
105
105
|
*/
|
|
106
106
|
function needsRetry(operationType, code) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
107
|
+
return (code === index_js_1.StatusCodes.ENOTFOUND ||
|
|
108
|
+
((operationType === index_js_1.OperationType.Read || operationType === index_js_1.OperationType.Query) &&
|
|
109
|
+
CONNECTION_ERROR_CODES.includes(code)));
|
|
114
110
|
}
|
|
115
111
|
/**
|
|
116
112
|
* 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,
|
|
1
|
+
{"version":3,"file":"defaultRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/defaultRetryPolicy.ts"],"names":[],"mappings":";;;AAGA,iDAAgE;AAEhE,gEAA8D;AAG9D;;GAEG;AACH,6BAA6B;AAC7B,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAC7C;;GAEG;AACH,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC;;GAEG;AACH,MAAM,uBAAuB,GA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AI,IAAI,aAAa,KAAK,wBAAa,CAAC,KAAK,CAAC;YAC9E,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACzC,CAAC;AACJ,CAAC;AACD;;;GAGG;AACH,MAAa,kBAAkB;IAK7B,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAJxC,aAAQ,GAAW,EAAE,CAAC;QACtB,6BAAwB,GAAW,CAAC,CAAC;QACtC,mBAAc,GAAW,IAAI,CAAC;IAEc,CAAC;IACpD;;;OAGG;IACI,KAAK,CAAC,WAAW,CACtB,GAAkB,EAClB,cAAsC;QAEtC,IAAI,GAAG,EAAE,CAAC;YACR,IACE,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,QAAQ;gBAC7C,UAAU,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,CAAC,EACxC,CAAC;gBACD,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,EAAE,SAAS,EAAE,CAAC,CAAC;gBAC7D,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA1BD,gDA0BC","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,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"endpointDiscoveryRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/endpointDiscoveryRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAEtF;;;GAGG;AACH,qBAAa,4BAA6B,YAAW,WAAW;IAe5D,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,8BAA8B,CAAC;IAhBzC,mCAAmC;IAC5B,wBAAwB,EAAE,MAAM,CAAC;IACxC,sCAAsC;IAC/B,cAAc,EAAE,MAAM,CAAC;IAE9B,+CAA+C;IAC/C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAO;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAQ;IAE9C;;OAEG;gBAEO,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa,EAC5B,8BAA8B,CAAC,EAAE,8BAA8B;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"}
|
|
@@ -10,9 +10,10 @@ class EndpointDiscoveryRetryPolicy {
|
|
|
10
10
|
/**
|
|
11
11
|
* @param globalEndpointManager - The GlobalEndpointManager instance.
|
|
12
12
|
*/
|
|
13
|
-
constructor(globalEndpointManager, operationType) {
|
|
13
|
+
constructor(globalEndpointManager, operationType, globalPartitionEndpointManager) {
|
|
14
14
|
this.globalEndpointManager = globalEndpointManager;
|
|
15
15
|
this.operationType = operationType;
|
|
16
|
+
this.globalPartitionEndpointManager = globalPartitionEndpointManager;
|
|
16
17
|
this.maxTries = EndpointDiscoveryRetryPolicy.maxTries;
|
|
17
18
|
this.currentRetryAttemptCount = 0;
|
|
18
19
|
this.retryAfterInMs = EndpointDiscoveryRetryPolicy.retryAfterInMs;
|
|
@@ -21,7 +22,7 @@ class EndpointDiscoveryRetryPolicy {
|
|
|
21
22
|
* Determines whether the request should be retried or not.
|
|
22
23
|
* @param err - Error returned by the request.
|
|
23
24
|
*/
|
|
24
|
-
async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint) {
|
|
25
|
+
async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint, requestContext) {
|
|
25
26
|
if (!err) {
|
|
26
27
|
return false;
|
|
27
28
|
}
|
|
@@ -31,6 +32,12 @@ class EndpointDiscoveryRetryPolicy {
|
|
|
31
32
|
if (!this.globalEndpointManager.enableEndpointDiscovery) {
|
|
32
33
|
return false;
|
|
33
34
|
}
|
|
35
|
+
if (this.globalPartitionEndpointManager) {
|
|
36
|
+
const didFailover = await this.globalPartitionEndpointManager.tryPartitionLevelFailover(requestContext, diagnosticNode);
|
|
37
|
+
if (didFailover) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
34
41
|
if (this.currentRetryAttemptCount >= this.maxTries) {
|
|
35
42
|
return false;
|
|
36
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointDiscoveryRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/endpointDiscoveryRetryPolicy.ts"],"names":[],"mappings":";;;AAIA,mDAAoD;
|
|
1
|
+
{"version":3,"file":"endpointDiscoveryRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/endpointDiscoveryRetryPolicy.ts"],"names":[],"mappings":";;;AAIA,mDAAoD;AAOpD;;;GAGG;AACH,MAAa,4BAA4B;IAWvC;;OAEG;IACH,YACU,qBAA4C,EAC5C,aAA4B,EAC5B,8BAA+D;QAF/D,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,kBAAa,GAAb,aAAa,CAA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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;;AAhFH,oEAiFC;AAzEyB,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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,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;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"}
|
|
@@ -25,11 +25,11 @@ async function execute({ diagnosticNode, retryContext = { retryCount: 0 }, retry
|
|
|
25
25
|
localDiagnosticNode.addData({ requestAttempNumber: retryContext.retryCount });
|
|
26
26
|
if (!retryPolicies) {
|
|
27
27
|
retryPolicies = {
|
|
28
|
-
endpointDiscoveryRetryPolicy: new endpointDiscoveryRetryPolicy_js_1.EndpointDiscoveryRetryPolicy(requestContext.globalEndpointManager, requestContext.operationType),
|
|
28
|
+
endpointDiscoveryRetryPolicy: new endpointDiscoveryRetryPolicy_js_1.EndpointDiscoveryRetryPolicy(requestContext.globalEndpointManager, requestContext.operationType, requestContext.globalPartitionEndpointManager),
|
|
29
29
|
resourceThrottleRetryPolicy: new resourceThrottleRetryPolicy_js_1.ResourceThrottleRetryPolicy((_a = requestContext.connectionPolicy.retryOptions) !== null && _a !== void 0 ? _a : {}),
|
|
30
30
|
sessionReadRetryPolicy: new sessionRetryPolicy_js_1.SessionRetryPolicy(requestContext.globalEndpointManager, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy),
|
|
31
31
|
defaultRetryPolicy: new defaultRetryPolicy_js_1.DefaultRetryPolicy(requestContext.operationType),
|
|
32
|
-
timeoutFailoverRetryPolicy: new timeoutFailoverRetryPolicy_js_1.TimeoutFailoverRetryPolicy(requestContext.globalEndpointManager, requestContext.headers, requestContext.method, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy.enableEndpointDiscovery),
|
|
32
|
+
timeoutFailoverRetryPolicy: new timeoutFailoverRetryPolicy_js_1.TimeoutFailoverRetryPolicy(requestContext.globalEndpointManager, requestContext.headers, requestContext.method, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy.enableEndpointDiscovery, requestContext.connectionPolicy.enablePartitionLevelFailover, requestContext.globalPartitionEndpointManager),
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
if (retryContext && retryContext.clearSessionTokenNotAvailable) {
|
|
@@ -44,6 +44,13 @@ async function execute({ diagnosticNode, retryContext = { retryCount: 0 }, retry
|
|
|
44
44
|
}
|
|
45
45
|
const startTimeUTCInMs = (0, time_js_1.getCurrentTimestampInMs)();
|
|
46
46
|
const correlatedActivityId = requestContext.headers[constants_js_1.Constants.HttpHeaders.CorrelatedActivityId];
|
|
47
|
+
if (requestContext.globalPartitionEndpointManager) {
|
|
48
|
+
// Try partition level location override
|
|
49
|
+
// This is used to override the partition level location for the request
|
|
50
|
+
// if there has been a partition level failover
|
|
51
|
+
requestContext =
|
|
52
|
+
await requestContext.globalPartitionEndpointManager.tryAddPartitionLevelLocationOverride(requestContext, localDiagnosticNode);
|
|
53
|
+
}
|
|
47
54
|
try {
|
|
48
55
|
const response = await executeRequest(localDiagnosticNode, requestContext);
|
|
49
56
|
response.headers[constants_js_1.Constants.ThrottleRetryCount] =
|
|
@@ -62,8 +69,7 @@ async function execute({ diagnosticNode, retryContext = { retryCount: 0 }, retry
|
|
|
62
69
|
if (correlatedActivityId) {
|
|
63
70
|
headers[constants_js_1.Constants.HttpHeaders.CorrelatedActivityId] = correlatedActivityId;
|
|
64
71
|
}
|
|
65
|
-
if (err.code ===
|
|
66
|
-
err.code === "REQUEST_SEND_ERROR" ||
|
|
72
|
+
if (err.code === "REQUEST_SEND_ERROR" ||
|
|
67
73
|
(err.code === statusCodes_js_1.StatusCodes.Forbidden &&
|
|
68
74
|
(err.substatus === statusCodes_js_1.SubStatusCodes.DatabaseAccountNotFound ||
|
|
69
75
|
err.substatus === statusCodes_js_1.SubStatusCodes.WriteForbidden))) {
|
|
@@ -82,7 +88,7 @@ async function execute({ diagnosticNode, retryContext = { retryCount: 0 }, retry
|
|
|
82
88
|
else {
|
|
83
89
|
retryPolicy = retryPolicies.defaultRetryPolicy;
|
|
84
90
|
}
|
|
85
|
-
const results = await retryPolicy.shouldRetry(err, localDiagnosticNode, retryContext, requestContext.endpoint);
|
|
91
|
+
const results = await retryPolicy.shouldRetry(err, localDiagnosticNode, retryContext, requestContext.endpoint, requestContext);
|
|
86
92
|
if (!results) {
|
|
87
93
|
headers[constants_js_1.Constants.ThrottleRetryCount] =
|
|
88
94
|
retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryUtility.js","sourceRoot":"","sources":["../../../src/retry/retryUtility.ts"],"names":[],"mappings":";;AAgDA,0BAwIC;AAxLD,uCAAuC;AACvC,kCAAkC;AAClC,yDAAmD;AACnD,mDAA4C;AAC5C,6DAAuE;AAEvE,wFAA8E;AAG9E,gEAA8D;AAC9D,4DAA6D;AAC7D,8CAA2D;AAC3D,mEAA6D;AAC7D,uFAAiF;AACjF,q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AC,2BAA2B,CAAC,wBAAwB,CAAC;gBACrE,OAAO,CAAC,wBAAS,CAAC,yBAAyB,CAAC;oBAC1C,aAAa,CAAC,2BAA2B,CAAC,uBAAuB,CAAC;gBACpE,GAAG,CAAC,OAAO,mCAAQ,GAAG,CAAC,OAAO,GAAK,OAAO,CAAE,CAAC;gBAC7C,MAAM,GAAG,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,cAAc,CAAC,UAAU,EAAE,CAAC;gBAC5B,MAAM,MAAM,GAAI,OAAe,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB;gBACrD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;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,IAAA,iBAAK,EAAC,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,8CAAkB,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,wBAAS,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":";;AAgDA,0BAwJC;AAxMD,uCAAuC;AACvC,kCAAkC;AAClC,yDAAmD;AACnD,mDAA4C;AAC5C,6DAAuE;AAEvE,wFAA8E;AAG9E,gEAA8D;AAC9D,4DAA6D;AAC7D,8CAA2D;AAC3D,mEAA6D;AAC7D,uFAAiF;AACjF,qFAA+E;AAG/E,mEAA6D;AAC7D,mFAA6E;AA2B7E;;GAEG;AACI,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,IAAA,mCAAkB,EACvB,KAAK,EAAE,mBAA2C,EAAE,EAAE;;QACpD,mBAAmB,CAAC,OAAO,CAAC,EAAE,mBAAmB,EAAE,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,aAAa,GAAG;gBACd,4BAA4B,EAAE,IAAI,8DAA4B,CAC5D,cAAc,CAAC,qBAAqB,EACpC,cAAc,CAAC,aAAa,EAC5B,cAAc,CAAC,8BAA8B,CAC9C;gBACD,2BAA2B,EAAE,IAAI,4DAA2B,CAC1D,MAAA,cAAc,CAAC,gBAAgB,CAAC,YAAY,mCAAI,EAAE,CACnD;gBACD,sBAAsB,EAAE,IAAI,0CAAkB,CAC5C,cAAc,CAAC,qBAAqB,EACpC,cAAc,CAAC,YAAY,EAC3B,cAAc,CAAC,aAAa,EAC5B,cAAc,CAAC,gBAAgB,CAChC;gBACD,kBAAkB,EAAE,IAAI,0CAAkB,CAAC,cAAc,CAAC,aAAa,CAAC;gBACxE,0BAA0B,EAAE,IAAI,0DAA0B,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AM,IAAA,iBAAK,EAAC,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,8CAAkB,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,wBAAS,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"}
|
|
@@ -13,13 +13,15 @@ const TimeoutError_js_1 = require("../request/TimeoutError.js");
|
|
|
13
13
|
* @hidden
|
|
14
14
|
*/
|
|
15
15
|
class TimeoutFailoverRetryPolicy {
|
|
16
|
-
constructor(globalEndpointManager, headers, methodType, resourceType, operationType, enableEndPointDiscovery) {
|
|
16
|
+
constructor(globalEndpointManager, headers, methodType, resourceType, operationType, enableEndPointDiscovery, enablePartitionLevelFailover, globalPartitionEndpointManager) {
|
|
17
17
|
this.globalEndpointManager = globalEndpointManager;
|
|
18
18
|
this.headers = headers;
|
|
19
19
|
this.methodType = methodType;
|
|
20
20
|
this.resourceType = resourceType;
|
|
21
21
|
this.operationType = operationType;
|
|
22
22
|
this.enableEndPointDiscovery = enableEndPointDiscovery;
|
|
23
|
+
this.enablePartitionLevelFailover = enablePartitionLevelFailover;
|
|
24
|
+
this.globalPartitionEndpointManager = globalPartitionEndpointManager;
|
|
23
25
|
this.maxRetryAttemptCount = 120;
|
|
24
26
|
this.maxServiceUnavailableRetryCount = 1;
|
|
25
27
|
this.retryAfterInMs = 0;
|
|
@@ -38,13 +40,18 @@ class TimeoutFailoverRetryPolicy {
|
|
|
38
40
|
}
|
|
39
41
|
return false;
|
|
40
42
|
}
|
|
41
|
-
async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint) {
|
|
43
|
+
async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint, requestContext) {
|
|
42
44
|
if (!err) {
|
|
43
45
|
return false;
|
|
44
46
|
}
|
|
45
47
|
if (!retryContext || !locationEndpoint) {
|
|
46
48
|
return false;
|
|
47
49
|
}
|
|
50
|
+
// Mark the partition as unavailable.
|
|
51
|
+
// Let the Retry logic decide if the request should be retried
|
|
52
|
+
if (requestContext && this.globalPartitionEndpointManager) {
|
|
53
|
+
await this.globalPartitionEndpointManager.tryPartitionLevelFailover(requestContext, diagnosticNode);
|
|
54
|
+
}
|
|
48
55
|
// Check if the error is a timeout error (TimeoutErrorCode) and if it is not a valid HTTP network timeout request
|
|
49
56
|
if (err.code === TimeoutError_js_1.TimeoutErrorCode && !this.isValidRequestForTimeoutError()) {
|
|
50
57
|
return false;
|
|
@@ -61,8 +68,9 @@ class TimeoutFailoverRetryPolicy {
|
|
|
61
68
|
}
|
|
62
69
|
const canUseMultipleWriteLocations = this.globalEndpointManager.canUseMultipleWriteLocations(this.resourceType, this.operationType);
|
|
63
70
|
const readRequest = (0, index_js_1.isReadRequest)(this.operationType);
|
|
64
|
-
if (!canUseMultipleWriteLocations && !readRequest) {
|
|
65
|
-
// Write requests on single master cannot be retried
|
|
71
|
+
if (!canUseMultipleWriteLocations && !readRequest && !this.enablePartitionLevelFailover) {
|
|
72
|
+
// Write requests on single master cannot be retried if partition level failover is disabled.
|
|
73
|
+
// This means there are no other regions available to serve the writes.
|
|
66
74
|
return false;
|
|
67
75
|
}
|
|
68
76
|
this.failoverRetryCount++;
|