@azure/event-hubs 5.13.0-beta.1 → 6.0.0-alpha.20250128.2
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/README.md +32 -31
- package/dist/browser/batchingPartitionChannel.d.ts +94 -0
- package/dist/browser/batchingPartitionChannel.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/batchingPartitionChannel.js +4 -4
- package/dist/browser/batchingPartitionChannel.js.map +1 -0
- package/dist/browser/connectionContext.d.ts +108 -0
- package/dist/browser/connectionContext.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/connectionContext.js +9 -11
- package/dist/browser/connectionContext.js.map +1 -0
- package/dist/browser/dataTransformer.d.ts +53 -0
- package/dist/browser/dataTransformer.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/dataTransformer.js +2 -2
- package/dist/browser/dataTransformer.js.map +1 -0
- package/dist/browser/diagnostics/instrumentEventData.d.ts +28 -0
- package/dist/browser/diagnostics/instrumentEventData.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/diagnostics/instrumentEventData.js +3 -3
- package/dist/browser/diagnostics/instrumentEventData.js.map +1 -0
- package/dist/browser/diagnostics/tracing.d.ts +19 -0
- package/dist/browser/diagnostics/tracing.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/diagnostics/tracing.js +2 -2
- package/dist/browser/diagnostics/tracing.js.map +1 -0
- package/dist/browser/eventData.d.ts +295 -0
- package/dist/browser/eventData.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventData.js +39 -5
- package/dist/browser/eventData.js.map +1 -0
- package/dist/browser/eventDataAdapter.d.ts +69 -0
- package/dist/browser/eventDataAdapter.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventDataAdapter.js +1 -1
- package/dist/browser/eventDataAdapter.js.map +1 -0
- package/dist/browser/eventDataBatch.d.ts +225 -0
- package/dist/browser/eventDataBatch.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventDataBatch.js +7 -4
- package/dist/browser/eventDataBatch.js.map +1 -0
- package/dist/browser/eventHubBufferedProducerClient.d.ts +323 -0
- package/dist/browser/eventHubBufferedProducerClient.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventHubBufferedProducerClient.js +10 -9
- package/dist/browser/eventHubBufferedProducerClient.js.map +1 -0
- package/dist/browser/eventHubConsumerClient.d.ts +277 -0
- package/dist/browser/eventHubConsumerClient.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventHubConsumerClient.js +12 -12
- package/dist/browser/eventHubConsumerClient.js.map +1 -0
- package/dist/browser/eventHubConsumerClientModels.d.ts +218 -0
- package/dist/browser/eventHubConsumerClientModels.d.ts.map +1 -0
- package/dist/browser/eventHubConsumerClientModels.js +4 -0
- package/dist/browser/eventHubConsumerClientModels.js.map +1 -0
- package/dist/browser/eventHubProducerClient.d.ts +266 -0
- package/dist/browser/eventHubProducerClient.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventHubProducerClient.js +12 -10
- package/dist/browser/eventHubProducerClient.js.map +1 -0
- package/dist/browser/eventHubSender.d.ts +227 -0
- package/dist/browser/eventHubSender.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventHubSender.js +12 -12
- package/dist/browser/eventHubSender.js.map +1 -0
- package/dist/browser/eventPosition.d.ts +73 -0
- package/dist/browser/eventPosition.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventPosition.js +1 -1
- package/{dist-esm/src → dist/browser}/eventPosition.js.map +1 -1
- package/dist/browser/eventProcessor.d.ts +232 -0
- package/dist/browser/eventProcessor.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventProcessor.js +18 -18
- package/dist/browser/eventProcessor.js.map +1 -0
- package/dist/browser/eventhubConnectionConfig.d.ts +96 -0
- package/dist/browser/eventhubConnectionConfig.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/eventhubConnectionConfig.js +2 -2
- package/dist/browser/eventhubConnectionConfig.js.map +1 -0
- package/dist/browser/impl/awaitableQueue.d.ts +25 -0
- package/dist/browser/impl/awaitableQueue.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/impl/awaitableQueue.js +1 -1
- package/dist/browser/impl/awaitableQueue.js.map +1 -0
- package/dist/browser/impl/partitionAssigner.d.ts +29 -0
- package/dist/browser/impl/partitionAssigner.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/impl/partitionAssigner.js +2 -2
- package/dist/browser/impl/partitionAssigner.js.map +1 -0
- package/dist/browser/impl/partitionGate.d.ts +27 -0
- package/dist/browser/impl/partitionGate.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/impl/partitionGate.js +1 -1
- package/{dist-esm/src → dist/browser}/impl/partitionGate.js.map +1 -1
- package/dist/browser/impl/partitionKeyToIdMapper.d.ts +6 -0
- package/dist/browser/impl/partitionKeyToIdMapper.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/impl/partitionKeyToIdMapper.js +1 -1
- package/{dist-esm/src → dist/browser}/impl/partitionKeyToIdMapper.js.map +1 -1
- package/dist/browser/inMemoryCheckpointStore.d.ts +44 -0
- package/dist/browser/inMemoryCheckpointStore.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/inMemoryCheckpointStore.js +3 -3
- package/dist/browser/inMemoryCheckpointStore.js.map +1 -0
- package/dist/browser/index.d.ts +21 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/index.js +9 -9
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/loadBalancerStrategies/balancedStrategy.d.ts +30 -0
- package/dist/browser/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/loadBalancerStrategies/balancedStrategy.js +2 -2
- package/dist/browser/loadBalancerStrategies/balancedStrategy.js.map +1 -0
- package/dist/browser/loadBalancerStrategies/greedyStrategy.d.ts +24 -0
- package/dist/browser/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/loadBalancerStrategies/greedyStrategy.js +2 -2
- package/dist/browser/loadBalancerStrategies/greedyStrategy.js.map +1 -0
- package/dist/browser/loadBalancerStrategies/loadBalancingStrategy.d.ts +28 -0
- package/dist/browser/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/loadBalancerStrategies/loadBalancingStrategy.js +2 -2
- package/dist/browser/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -0
- package/dist/browser/loadBalancerStrategies/unbalancedStrategy.d.ts +20 -0
- package/dist/browser/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/loadBalancerStrategies/unbalancedStrategy.js +1 -1
- package/dist/browser/loadBalancerStrategies/unbalancedStrategy.js.map +1 -0
- package/dist/browser/logger.d.ts +37 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/logger.js +1 -1
- package/dist/browser/logger.js.map +1 -0
- package/dist/browser/managementClient.d.ts +145 -0
- package/dist/browser/managementClient.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/managementClient.js +8 -8
- package/dist/browser/managementClient.js.map +1 -0
- package/dist/browser/models/private.d.ts +185 -0
- package/dist/browser/models/private.d.ts.map +1 -0
- package/dist/browser/models/private.js +4 -0
- package/dist/browser/models/private.js.map +1 -0
- package/dist/browser/models/public.d.ts +240 -0
- package/dist/browser/models/public.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/models/public.js +1 -1
- package/dist/browser/models/public.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/partitionProcessor.d.ts +134 -0
- package/dist/browser/partitionProcessor.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/partitionProcessor.js +2 -2
- package/dist/browser/partitionProcessor.js.map +1 -0
- package/dist/browser/partitionPump.d.ts +38 -0
- package/dist/browser/partitionPump.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/partitionPump.js +6 -7
- package/dist/browser/partitionPump.js.map +1 -0
- package/dist/browser/partitionReceiver.d.ts +82 -0
- package/dist/browser/partitionReceiver.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/partitionReceiver.js +14 -12
- package/dist/browser/partitionReceiver.js.map +1 -0
- package/dist/browser/pumpManager.d.ts +72 -0
- package/dist/browser/pumpManager.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/pumpManager.js +4 -4
- package/dist/browser/pumpManager.js.map +1 -0
- package/dist/browser/util/connectionStringUtils.d.ts +52 -0
- package/dist/browser/util/connectionStringUtils.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/connectionStringUtils.js +1 -1
- package/{dist-esm/src → dist/browser}/util/connectionStringUtils.js.map +1 -1
- package/dist/browser/util/constants.d.ts +25 -0
- package/dist/browser/util/constants.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/constants.js +4 -2
- package/dist/browser/util/constants.js.map +1 -0
- package/dist/browser/util/delayWithoutThrow.d.ts +8 -0
- package/dist/browser/util/delayWithoutThrow.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/delayWithoutThrow.js +1 -1
- package/dist/browser/util/delayWithoutThrow.js.map +1 -0
- package/dist/browser/util/error.d.ts +39 -0
- package/dist/browser/util/error.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/error.js +2 -2
- package/dist/browser/util/error.js.map +1 -0
- package/dist/browser/util/getPromiseParts.d.ts +10 -0
- package/dist/browser/util/getPromiseParts.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/getPromiseParts.js +1 -1
- package/{dist-esm/src → dist/browser}/util/getPromiseParts.js.map +1 -1
- package/dist/browser/util/operationOptions.d.ts +16 -0
- package/dist/browser/util/operationOptions.d.ts.map +1 -0
- package/dist/browser/util/operationOptions.js +4 -0
- package/dist/browser/util/operationOptions.js.map +1 -0
- package/dist/browser/util/parseEndpoint.d.ts +11 -0
- package/dist/browser/util/parseEndpoint.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/parseEndpoint.js +1 -1
- package/{dist-esm/src → dist/browser}/util/parseEndpoint.js.map +1 -1
- package/dist/browser/util/retries.d.ts +6 -0
- package/dist/browser/util/retries.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/retries.js +1 -1
- package/dist/browser/util/retries.js.map +1 -0
- package/dist/browser/util/runtimeInfo-browser.d.mts.map +1 -0
- package/dist/browser/util/runtimeInfo-browser.mjs.map +1 -0
- package/dist/browser/util/runtimeInfo.d.ts +6 -0
- package/{dist-esm/src/util/runtimeInfo.browser.js → dist/browser/util/runtimeInfo.js} +2 -2
- package/dist/browser/util/timerLoop.d.ts +26 -0
- package/dist/browser/util/timerLoop.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/timerLoop.js +1 -1
- package/{dist-esm/src → dist/browser}/util/timerLoop.js.map +1 -1
- package/dist/browser/util/typeGuards.d.ts +8 -0
- package/dist/browser/util/typeGuards.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/typeGuards.js +2 -2
- package/dist/browser/util/typeGuards.js.map +1 -0
- package/dist/browser/util/utils.d.ts +7 -0
- package/dist/browser/util/utils.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/utils.js +1 -1
- package/{dist-esm/src → dist/browser}/util/utils.js.map +1 -1
- package/dist/browser/withAuth.d.ts +25 -0
- package/dist/browser/withAuth.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/withAuth.js +4 -4
- package/dist/browser/withAuth.js.map +1 -0
- package/dist/commonjs/batchingPartitionChannel.d.ts +94 -0
- package/dist/commonjs/batchingPartitionChannel.d.ts.map +1 -0
- package/dist/commonjs/batchingPartitionChannel.js +252 -0
- package/dist/commonjs/batchingPartitionChannel.js.map +1 -0
- package/dist/commonjs/connectionContext.d.ts +108 -0
- package/dist/commonjs/connectionContext.d.ts.map +1 -0
- package/dist/commonjs/connectionContext.js +322 -0
- package/dist/commonjs/connectionContext.js.map +1 -0
- package/dist/commonjs/dataTransformer.d.ts +53 -0
- package/dist/commonjs/dataTransformer.d.ts.map +1 -0
- package/dist/commonjs/dataTransformer.js +138 -0
- package/dist/commonjs/dataTransformer.js.map +1 -0
- package/dist/commonjs/diagnostics/instrumentEventData.d.ts +28 -0
- package/dist/commonjs/diagnostics/instrumentEventData.d.ts.map +1 -0
- package/dist/commonjs/diagnostics/instrumentEventData.js +73 -0
- package/dist/commonjs/diagnostics/instrumentEventData.js.map +1 -0
- package/dist/commonjs/diagnostics/tracing.d.ts +19 -0
- package/dist/commonjs/diagnostics/tracing.d.ts.map +1 -0
- package/dist/commonjs/diagnostics/tracing.js +44 -0
- package/dist/commonjs/diagnostics/tracing.js.map +1 -0
- package/dist/commonjs/eventData.d.ts +295 -0
- package/dist/commonjs/eventData.d.ts.map +1 -0
- package/dist/commonjs/eventData.js +253 -0
- package/dist/commonjs/eventData.js.map +1 -0
- package/dist/commonjs/eventDataAdapter.d.ts +69 -0
- package/dist/commonjs/eventDataAdapter.d.ts.map +1 -0
- package/dist/commonjs/eventDataAdapter.js +38 -0
- package/dist/commonjs/eventDataAdapter.js.map +1 -0
- package/dist/commonjs/eventDataBatch.d.ts +225 -0
- package/dist/commonjs/eventDataBatch.d.ts.map +1 -0
- package/dist/commonjs/eventDataBatch.js +254 -0
- package/dist/commonjs/eventDataBatch.js.map +1 -0
- package/dist/commonjs/eventHubBufferedProducerClient.d.ts +323 -0
- package/dist/commonjs/eventHubBufferedProducerClient.d.ts.map +1 -0
- package/dist/commonjs/eventHubBufferedProducerClient.js +289 -0
- package/dist/commonjs/eventHubBufferedProducerClient.js.map +1 -0
- package/dist/commonjs/eventHubConsumerClient.d.ts +277 -0
- package/dist/commonjs/eventHubConsumerClient.d.ts.map +1 -0
- package/dist/commonjs/eventHubConsumerClient.js +298 -0
- package/dist/commonjs/eventHubConsumerClient.js.map +1 -0
- package/dist/commonjs/eventHubConsumerClientModels.d.ts +218 -0
- package/dist/commonjs/eventHubConsumerClientModels.d.ts.map +1 -0
- package/dist/commonjs/eventHubConsumerClientModels.js +5 -0
- package/dist/commonjs/eventHubConsumerClientModels.js.map +1 -0
- package/dist/commonjs/eventHubProducerClient.d.ts +266 -0
- package/dist/commonjs/eventHubProducerClient.d.ts.map +1 -0
- package/dist/commonjs/eventHubProducerClient.js +319 -0
- package/dist/commonjs/eventHubProducerClient.js.map +1 -0
- package/dist/commonjs/eventHubSender.d.ts +227 -0
- package/dist/commonjs/eventHubSender.d.ts.map +1 -0
- package/dist/commonjs/eventHubSender.js +547 -0
- package/dist/commonjs/eventHubSender.js.map +1 -0
- package/dist/commonjs/eventPosition.d.ts +73 -0
- package/dist/commonjs/eventPosition.d.ts.map +1 -0
- package/dist/commonjs/eventPosition.js +128 -0
- package/dist/commonjs/eventPosition.js.map +1 -0
- package/dist/commonjs/eventProcessor.d.ts +232 -0
- package/dist/commonjs/eventProcessor.d.ts.map +1 -0
- package/dist/commonjs/eventProcessor.js +371 -0
- package/dist/commonjs/eventProcessor.js.map +1 -0
- package/dist/commonjs/eventhubConnectionConfig.d.ts +96 -0
- package/dist/commonjs/eventhubConnectionConfig.d.ts.map +1 -0
- package/dist/commonjs/eventhubConnectionConfig.js +101 -0
- package/dist/commonjs/eventhubConnectionConfig.js.map +1 -0
- package/dist/commonjs/impl/awaitableQueue.d.ts +25 -0
- package/dist/commonjs/impl/awaitableQueue.d.ts.map +1 -0
- package/dist/commonjs/impl/awaitableQueue.js +51 -0
- package/dist/commonjs/impl/awaitableQueue.js.map +1 -0
- package/dist/commonjs/impl/partitionAssigner.d.ts +29 -0
- package/dist/commonjs/impl/partitionAssigner.d.ts.map +1 -0
- package/dist/commonjs/impl/partitionAssigner.js +58 -0
- package/dist/commonjs/impl/partitionAssigner.js.map +1 -0
- package/dist/commonjs/impl/partitionGate.d.ts +27 -0
- package/dist/commonjs/impl/partitionGate.d.ts.map +1 -0
- package/dist/commonjs/impl/partitionGate.js +44 -0
- package/dist/commonjs/impl/partitionGate.js.map +1 -0
- package/dist/commonjs/impl/partitionKeyToIdMapper.d.ts +6 -0
- package/dist/commonjs/impl/partitionKeyToIdMapper.d.ts.map +1 -0
- package/dist/commonjs/impl/partitionKeyToIdMapper.js +115 -0
- package/dist/commonjs/impl/partitionKeyToIdMapper.js.map +1 -0
- package/dist/commonjs/inMemoryCheckpointStore.d.ts +44 -0
- package/dist/commonjs/inMemoryCheckpointStore.d.ts.map +1 -0
- package/dist/commonjs/inMemoryCheckpointStore.js +96 -0
- package/dist/commonjs/inMemoryCheckpointStore.js.map +1 -0
- package/dist/commonjs/index.d.ts +21 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +26 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/loadBalancerStrategies/balancedStrategy.d.ts +30 -0
- package/dist/commonjs/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -0
- package/dist/commonjs/loadBalancerStrategies/balancedStrategy.js +43 -0
- package/dist/commonjs/loadBalancerStrategies/balancedStrategy.js.map +1 -0
- package/dist/commonjs/loadBalancerStrategies/greedyStrategy.d.ts +24 -0
- package/dist/commonjs/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -0
- package/dist/commonjs/loadBalancerStrategies/greedyStrategy.js +32 -0
- package/dist/commonjs/loadBalancerStrategies/greedyStrategy.js.map +1 -0
- package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.d.ts +28 -0
- package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -0
- package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.js +248 -0
- package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -0
- package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.d.ts +20 -0
- package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -0
- package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.js +26 -0
- package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.js.map +1 -0
- package/dist/commonjs/logger.d.ts +37 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +65 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/managementClient.d.ts +145 -0
- package/dist/commonjs/managementClient.d.ts.map +1 -0
- package/dist/commonjs/managementClient.js +275 -0
- package/dist/commonjs/managementClient.js.map +1 -0
- package/dist/commonjs/models/private.d.ts +185 -0
- package/dist/commonjs/models/private.d.ts.map +1 -0
- package/dist/commonjs/models/private.js +5 -0
- package/dist/commonjs/models/private.js.map +1 -0
- package/dist/commonjs/models/public.d.ts +240 -0
- package/dist/commonjs/models/public.d.ts.map +1 -0
- package/dist/commonjs/models/public.js +21 -0
- package/dist/commonjs/models/public.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/partitionProcessor.d.ts +134 -0
- package/dist/commonjs/partitionProcessor.d.ts.map +1 -0
- package/dist/commonjs/partitionProcessor.js +138 -0
- package/dist/commonjs/partitionProcessor.js.map +1 -0
- package/dist/commonjs/partitionPump.d.ts +38 -0
- package/dist/commonjs/partitionPump.d.ts.map +1 -0
- package/dist/commonjs/partitionPump.js +171 -0
- package/dist/commonjs/partitionPump.js.map +1 -0
- package/dist/commonjs/partitionReceiver.d.ts +82 -0
- package/dist/commonjs/partitionReceiver.d.ts.map +1 -0
- package/dist/commonjs/partitionReceiver.js +335 -0
- package/dist/commonjs/partitionReceiver.js.map +1 -0
- package/dist/commonjs/pumpManager.d.ts +72 -0
- package/dist/commonjs/pumpManager.d.ts.map +1 -0
- package/dist/commonjs/pumpManager.js +122 -0
- package/dist/commonjs/pumpManager.js.map +1 -0
- package/{types/latest → dist/commonjs}/tsdoc-metadata.json +1 -1
- package/dist/commonjs/util/connectionStringUtils.d.ts +52 -0
- package/dist/commonjs/util/connectionStringUtils.d.ts.map +1 -0
- package/dist/commonjs/util/connectionStringUtils.js +51 -0
- package/dist/commonjs/util/connectionStringUtils.js.map +1 -0
- package/dist/commonjs/util/constants.d.ts +25 -0
- package/dist/commonjs/util/constants.d.ts.map +1 -0
- package/dist/commonjs/util/constants.js +30 -0
- package/dist/commonjs/util/constants.js.map +1 -0
- package/dist/commonjs/util/delayWithoutThrow.d.ts +8 -0
- package/dist/commonjs/util/delayWithoutThrow.d.ts.map +1 -0
- package/dist/commonjs/util/delayWithoutThrow.js +20 -0
- package/dist/commonjs/util/delayWithoutThrow.js.map +1 -0
- package/dist/commonjs/util/error.d.ts +39 -0
- package/dist/commonjs/util/error.d.ts.map +1 -0
- package/dist/commonjs/util/error.js +110 -0
- package/dist/commonjs/util/error.js.map +1 -0
- package/dist/commonjs/util/getPromiseParts.d.ts +10 -0
- package/dist/commonjs/util/getPromiseParts.d.ts.map +1 -0
- package/dist/commonjs/util/getPromiseParts.js +23 -0
- package/dist/commonjs/util/getPromiseParts.js.map +1 -0
- package/dist/commonjs/util/operationOptions.d.ts +16 -0
- package/dist/commonjs/util/operationOptions.d.ts.map +1 -0
- package/dist/commonjs/util/operationOptions.js +5 -0
- package/dist/commonjs/util/operationOptions.js.map +1 -0
- package/dist/commonjs/util/parseEndpoint.d.ts +11 -0
- package/dist/commonjs/util/parseEndpoint.d.ts.map +1 -0
- package/dist/commonjs/util/parseEndpoint.js +20 -0
- package/dist/commonjs/util/parseEndpoint.js.map +1 -0
- package/dist/commonjs/util/retries.d.ts +6 -0
- package/dist/commonjs/util/retries.d.ts.map +1 -0
- package/dist/commonjs/util/retries.js +16 -0
- package/dist/commonjs/util/retries.js.map +1 -0
- package/dist/commonjs/util/runtimeInfo.d.ts +6 -0
- package/dist/commonjs/util/runtimeInfo.d.ts.map +1 -0
- package/dist/commonjs/util/runtimeInfo.js +15 -0
- package/dist/commonjs/util/runtimeInfo.js.map +1 -0
- package/dist/commonjs/util/timerLoop.d.ts +26 -0
- package/dist/commonjs/util/timerLoop.d.ts.map +1 -0
- package/dist/commonjs/util/timerLoop.js +30 -0
- package/dist/commonjs/util/timerLoop.js.map +1 -0
- package/dist/commonjs/util/typeGuards.d.ts +8 -0
- package/dist/commonjs/util/typeGuards.d.ts.map +1 -0
- package/dist/commonjs/util/typeGuards.js +15 -0
- package/dist/commonjs/util/typeGuards.js.map +1 -0
- package/dist/commonjs/util/utils.d.ts +7 -0
- package/dist/commonjs/util/utils.d.ts.map +1 -0
- package/dist/commonjs/util/utils.js +16 -0
- package/dist/commonjs/util/utils.js.map +1 -0
- package/dist/commonjs/withAuth.d.ts +25 -0
- package/dist/commonjs/withAuth.d.ts.map +1 -0
- package/dist/commonjs/withAuth.js +88 -0
- package/dist/commonjs/withAuth.js.map +1 -0
- package/dist/esm/batchingPartitionChannel.d.ts +94 -0
- package/dist/esm/batchingPartitionChannel.d.ts.map +1 -0
- package/dist/esm/batchingPartitionChannel.js +248 -0
- package/dist/esm/batchingPartitionChannel.js.map +1 -0
- package/dist/esm/connectionContext.d.ts +108 -0
- package/dist/esm/connectionContext.d.ts.map +1 -0
- package/dist/esm/connectionContext.js +318 -0
- package/dist/esm/connectionContext.js.map +1 -0
- package/dist/esm/dataTransformer.d.ts +53 -0
- package/dist/esm/dataTransformer.d.ts.map +1 -0
- package/dist/esm/dataTransformer.js +133 -0
- package/dist/esm/dataTransformer.js.map +1 -0
- package/dist/esm/diagnostics/instrumentEventData.d.ts +28 -0
- package/dist/esm/diagnostics/instrumentEventData.d.ts.map +1 -0
- package/dist/esm/diagnostics/instrumentEventData.js +68 -0
- package/dist/esm/diagnostics/instrumentEventData.js.map +1 -0
- package/dist/esm/diagnostics/tracing.d.ts +19 -0
- package/dist/esm/diagnostics/tracing.d.ts.map +1 -0
- package/dist/esm/diagnostics/tracing.js +40 -0
- package/dist/esm/diagnostics/tracing.js.map +1 -0
- package/dist/esm/eventData.d.ts +295 -0
- package/dist/esm/eventData.d.ts.map +1 -0
- package/dist/esm/eventData.js +245 -0
- package/dist/esm/eventData.js.map +1 -0
- package/dist/esm/eventDataAdapter.d.ts +69 -0
- package/dist/esm/eventDataAdapter.d.ts.map +1 -0
- package/dist/esm/eventDataAdapter.js +35 -0
- package/dist/esm/eventDataAdapter.js.map +1 -0
- package/dist/esm/eventDataBatch.d.ts +225 -0
- package/dist/esm/eventDataBatch.d.ts.map +1 -0
- package/dist/esm/eventDataBatch.js +249 -0
- package/dist/esm/eventDataBatch.js.map +1 -0
- package/dist/esm/eventHubBufferedProducerClient.d.ts +323 -0
- package/dist/esm/eventHubBufferedProducerClient.d.ts.map +1 -0
- package/dist/esm/eventHubBufferedProducerClient.js +285 -0
- package/dist/esm/eventHubBufferedProducerClient.js.map +1 -0
- package/dist/esm/eventHubConsumerClient.d.ts +277 -0
- package/dist/esm/eventHubConsumerClient.d.ts.map +1 -0
- package/dist/esm/eventHubConsumerClient.js +293 -0
- package/dist/esm/eventHubConsumerClient.js.map +1 -0
- package/dist/esm/eventHubConsumerClientModels.d.ts +218 -0
- package/dist/esm/eventHubConsumerClientModels.d.ts.map +1 -0
- package/dist/esm/eventHubConsumerClientModels.js +4 -0
- package/dist/esm/eventHubConsumerClientModels.js.map +1 -0
- package/dist/esm/eventHubProducerClient.d.ts +266 -0
- package/dist/esm/eventHubProducerClient.d.ts.map +1 -0
- package/dist/esm/eventHubProducerClient.js +315 -0
- package/dist/esm/eventHubProducerClient.js.map +1 -0
- package/dist/esm/eventHubSender.d.ts +227 -0
- package/dist/esm/eventHubSender.d.ts.map +1 -0
- package/dist/esm/eventHubSender.js +541 -0
- package/dist/esm/eventHubSender.js.map +1 -0
- package/dist/esm/eventPosition.d.ts +73 -0
- package/dist/esm/eventPosition.d.ts.map +1 -0
- package/dist/esm/eventPosition.js +121 -0
- package/dist/esm/eventPosition.js.map +1 -0
- package/dist/esm/eventProcessor.d.ts +232 -0
- package/dist/esm/eventProcessor.d.ts.map +1 -0
- package/dist/esm/eventProcessor.js +367 -0
- package/dist/esm/eventProcessor.js.map +1 -0
- package/dist/esm/eventhubConnectionConfig.d.ts +96 -0
- package/dist/esm/eventhubConnectionConfig.d.ts.map +1 -0
- package/dist/esm/eventhubConnectionConfig.js +98 -0
- package/dist/esm/eventhubConnectionConfig.js.map +1 -0
- package/dist/esm/impl/awaitableQueue.d.ts +25 -0
- package/dist/esm/impl/awaitableQueue.d.ts.map +1 -0
- package/dist/esm/impl/awaitableQueue.js +47 -0
- package/dist/esm/impl/awaitableQueue.js.map +1 -0
- package/dist/esm/impl/partitionAssigner.d.ts +29 -0
- package/dist/esm/impl/partitionAssigner.d.ts.map +1 -0
- package/dist/esm/impl/partitionAssigner.js +54 -0
- package/dist/esm/impl/partitionAssigner.js.map +1 -0
- package/dist/esm/impl/partitionGate.d.ts +27 -0
- package/dist/esm/impl/partitionGate.d.ts.map +1 -0
- package/dist/esm/impl/partitionGate.js +40 -0
- package/dist/esm/impl/partitionGate.js.map +1 -0
- package/dist/esm/impl/partitionKeyToIdMapper.d.ts +6 -0
- package/dist/esm/impl/partitionKeyToIdMapper.d.ts.map +1 -0
- package/dist/esm/impl/partitionKeyToIdMapper.js +111 -0
- package/dist/esm/impl/partitionKeyToIdMapper.js.map +1 -0
- package/dist/esm/inMemoryCheckpointStore.d.ts +44 -0
- package/dist/esm/inMemoryCheckpointStore.d.ts.map +1 -0
- package/dist/esm/inMemoryCheckpointStore.js +92 -0
- package/dist/esm/inMemoryCheckpointStore.js.map +1 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loadBalancerStrategies/balancedStrategy.d.ts +30 -0
- package/dist/esm/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -0
- package/dist/esm/loadBalancerStrategies/balancedStrategy.js +39 -0
- package/dist/esm/loadBalancerStrategies/balancedStrategy.js.map +1 -0
- package/dist/esm/loadBalancerStrategies/greedyStrategy.d.ts +24 -0
- package/dist/esm/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -0
- package/dist/esm/loadBalancerStrategies/greedyStrategy.js +28 -0
- package/dist/esm/loadBalancerStrategies/greedyStrategy.js.map +1 -0
- package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.d.ts +28 -0
- package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -0
- package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.js +245 -0
- package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -0
- package/dist/esm/loadBalancerStrategies/unbalancedStrategy.d.ts +20 -0
- package/dist/esm/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -0
- package/dist/esm/loadBalancerStrategies/unbalancedStrategy.js +22 -0
- package/dist/esm/loadBalancerStrategies/unbalancedStrategy.js.map +1 -0
- package/dist/esm/logger.d.ts +37 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +56 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/managementClient.d.ts +145 -0
- package/dist/esm/managementClient.d.ts.map +1 -0
- package/dist/esm/managementClient.js +271 -0
- package/dist/esm/managementClient.js.map +1 -0
- package/dist/esm/models/private.d.ts +185 -0
- package/dist/esm/models/private.d.ts.map +1 -0
- package/dist/esm/models/private.js +4 -0
- package/dist/esm/models/private.js.map +1 -0
- package/dist/esm/models/public.d.ts +240 -0
- package/dist/esm/models/public.d.ts.map +1 -0
- package/dist/esm/models/public.js +18 -0
- package/dist/esm/models/public.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/partitionProcessor.d.ts +134 -0
- package/dist/esm/partitionProcessor.d.ts.map +1 -0
- package/dist/esm/partitionProcessor.js +134 -0
- package/dist/esm/partitionProcessor.js.map +1 -0
- package/dist/esm/partitionPump.d.ts +38 -0
- package/dist/esm/partitionPump.d.ts.map +1 -0
- package/dist/esm/partitionPump.js +166 -0
- package/dist/esm/partitionPump.js.map +1 -0
- package/dist/esm/partitionReceiver.d.ts +82 -0
- package/dist/esm/partitionReceiver.d.ts.map +1 -0
- package/dist/esm/partitionReceiver.js +330 -0
- package/dist/esm/partitionReceiver.js.map +1 -0
- package/dist/esm/pumpManager.d.ts +72 -0
- package/dist/esm/pumpManager.d.ts.map +1 -0
- package/dist/esm/pumpManager.js +118 -0
- package/dist/esm/pumpManager.js.map +1 -0
- package/dist/esm/util/connectionStringUtils.d.ts +52 -0
- package/dist/esm/util/connectionStringUtils.d.ts.map +1 -0
- package/dist/esm/util/connectionStringUtils.js +48 -0
- package/dist/esm/util/connectionStringUtils.js.map +1 -0
- package/dist/esm/util/constants.d.ts +25 -0
- package/dist/esm/util/constants.d.ts.map +1 -0
- package/dist/esm/util/constants.js +27 -0
- package/dist/esm/util/constants.js.map +1 -0
- package/dist/esm/util/delayWithoutThrow.d.ts +8 -0
- package/dist/esm/util/delayWithoutThrow.d.ts.map +1 -0
- package/dist/esm/util/delayWithoutThrow.js +17 -0
- package/dist/esm/util/delayWithoutThrow.js.map +1 -0
- package/dist/esm/util/error.d.ts +39 -0
- package/dist/esm/util/error.d.ts.map +1 -0
- package/dist/esm/util/error.js +103 -0
- package/dist/esm/util/error.js.map +1 -0
- package/dist/esm/util/getPromiseParts.d.ts +10 -0
- package/dist/esm/util/getPromiseParts.d.ts.map +1 -0
- package/dist/esm/util/getPromiseParts.js +20 -0
- package/dist/esm/util/getPromiseParts.js.map +1 -0
- package/dist/esm/util/operationOptions.d.ts +16 -0
- package/dist/esm/util/operationOptions.d.ts.map +1 -0
- package/dist/esm/util/operationOptions.js +4 -0
- package/dist/esm/util/operationOptions.js.map +1 -0
- package/dist/esm/util/parseEndpoint.d.ts +11 -0
- package/dist/esm/util/parseEndpoint.d.ts.map +1 -0
- package/dist/esm/util/parseEndpoint.js +17 -0
- package/dist/esm/util/parseEndpoint.js.map +1 -0
- package/dist/esm/util/retries.d.ts +6 -0
- package/dist/esm/util/retries.d.ts.map +1 -0
- package/dist/esm/util/retries.js +13 -0
- package/dist/esm/util/retries.js.map +1 -0
- package/dist/esm/util/runtimeInfo.d.ts +6 -0
- package/dist/esm/util/runtimeInfo.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/util/runtimeInfo.js +1 -1
- package/{dist-esm/src → dist/esm}/util/runtimeInfo.js.map +1 -1
- package/dist/esm/util/timerLoop.d.ts +26 -0
- package/dist/esm/util/timerLoop.d.ts.map +1 -0
- package/dist/esm/util/timerLoop.js +27 -0
- package/dist/esm/util/timerLoop.js.map +1 -0
- package/dist/esm/util/typeGuards.d.ts +8 -0
- package/dist/esm/util/typeGuards.d.ts.map +1 -0
- package/dist/esm/util/typeGuards.js +12 -0
- package/dist/esm/util/typeGuards.js.map +1 -0
- package/dist/esm/util/utils.d.ts +7 -0
- package/dist/esm/util/utils.d.ts.map +1 -0
- package/dist/esm/util/utils.js +13 -0
- package/dist/esm/util/utils.js.map +1 -0
- package/dist/esm/withAuth.d.ts +25 -0
- package/dist/esm/withAuth.d.ts.map +1 -0
- package/dist/esm/withAuth.js +84 -0
- package/dist/esm/withAuth.js.map +1 -0
- package/package.json +85 -80
- package/dist/index.js +0 -5372
- package/dist/index.js.map +0 -1
- package/dist-esm/src/batchingPartitionChannel.js.map +0 -1
- package/dist-esm/src/connectionContext.js.map +0 -1
- package/dist-esm/src/dataTransformer.js.map +0 -1
- package/dist-esm/src/diagnostics/instrumentEventData.js.map +0 -1
- package/dist-esm/src/diagnostics/tracing.js.map +0 -1
- package/dist-esm/src/eventData.js.map +0 -1
- package/dist-esm/src/eventDataAdapter.js.map +0 -1
- package/dist-esm/src/eventDataBatch.js.map +0 -1
- package/dist-esm/src/eventHubBufferedProducerClient.js.map +0 -1
- package/dist-esm/src/eventHubConsumerClient.js.map +0 -1
- package/dist-esm/src/eventHubConsumerClientModels.js +0 -4
- package/dist-esm/src/eventHubConsumerClientModels.js.map +0 -1
- package/dist-esm/src/eventHubProducerClient.js.map +0 -1
- package/dist-esm/src/eventHubSender.js.map +0 -1
- package/dist-esm/src/eventProcessor.js.map +0 -1
- package/dist-esm/src/eventhubConnectionConfig.js.map +0 -1
- package/dist-esm/src/impl/awaitableQueue.js.map +0 -1
- package/dist-esm/src/impl/partitionAssigner.js.map +0 -1
- package/dist-esm/src/inMemoryCheckpointStore.js.map +0 -1
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/src/loadBalancerStrategies/balancedStrategy.js.map +0 -1
- package/dist-esm/src/loadBalancerStrategies/greedyStrategy.js.map +0 -1
- package/dist-esm/src/loadBalancerStrategies/loadBalancingStrategy.js.map +0 -1
- package/dist-esm/src/loadBalancerStrategies/unbalancedStrategy.js.map +0 -1
- package/dist-esm/src/logger.js.map +0 -1
- package/dist-esm/src/managementClient.js.map +0 -1
- package/dist-esm/src/models/private.js +0 -4
- package/dist-esm/src/models/private.js.map +0 -1
- package/dist-esm/src/models/public.js.map +0 -1
- package/dist-esm/src/partitionProcessor.js.map +0 -1
- package/dist-esm/src/partitionPump.js.map +0 -1
- package/dist-esm/src/partitionReceiver.js.map +0 -1
- package/dist-esm/src/pumpManager.js.map +0 -1
- package/dist-esm/src/util/constants.js.map +0 -1
- package/dist-esm/src/util/delayWithoutThrow.js.map +0 -1
- package/dist-esm/src/util/error.js.map +0 -1
- package/dist-esm/src/util/operationOptions.js +0 -4
- package/dist-esm/src/util/operationOptions.js.map +0 -1
- package/dist-esm/src/util/retries.js.map +0 -1
- package/dist-esm/src/util/runtimeInfo.browser.js.map +0 -1
- package/dist-esm/src/util/typeGuards.js.map +0 -1
- package/dist-esm/src/withAuth.js.map +0 -1
- package/types/latest/event-hubs.d.ts +0 -1877
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batchingPartitionChannel.js","sourceRoot":"","sources":["../../src/batchingPartitionChannel.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAwB,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQ/D,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAgB,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OA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,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC;YAC9D,OAAO;QACT,CAAC;QAED,KAAK,CAAC,OAAO,EAAE,CAAC;QAEhB,IAAI,CAAC,WAAW,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AmqpAnnotatedMessage, delay } from \"@azure/core-amqp\";\nimport {\n EventData,\n EventDataBatch,\n EventHubBufferedProducerClientOptions,\n EventHubProducerClient,\n OperationOptions,\n} from \"./index\";\nimport { isDefined, isObjectWithProperties, AbortOptions } from \"@azure/core-util\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AwaitableQueue } from \"./impl/awaitableQueue\";\nimport { getPromiseParts } from \"./util/getPromiseParts\";\nimport { logger } from \"./logger\";\nimport { cancelablePromiseRace } from \"@azure/core-util\";\n\nexport interface BatchingPartitionChannelProps {\n loopAbortSignal: AbortSignalLike;\n maxBufferSize: number;\n maxWaitTimeInMs: number;\n partitionId: string;\n producer: EventHubProducerClient;\n /**\n * The handler to call once a batch has successfully published.\n */\n onSendEventsSuccessHandler?: EventHubBufferedProducerClientOptions[\"onSendEventsSuccessHandler\"];\n /**\n * The handler to call when a batch fails to publish.\n */\n onSendEventsErrorHandler: EventHubBufferedProducerClientOptions[\"onSendEventsErrorHandler\"];\n}\n\n/**\n * The `BatchingPartitionChannel` is responsible for accepting enqueued events\n * and optimally batching and sending them to an Event Hub.\n * @internal\n */\nexport class BatchingPartitionChannel {\n private _eventQueue = new AwaitableQueue<EventData | AmqpAnnotatedMessage>();\n private _batchedEvents: Array<EventData | AmqpAnnotatedMessage> = [];\n private _bufferCount: number = 0;\n private _readyQueue: Array<{\n resolve: (value: void) => void;\n reject: (reason?: any) => void;\n }> = [];\n private _flushState:\n | { isFlushing: false }\n | { isFlushing: true; currentPromise: Promise<void>; resolve: () => void } = {\n isFlushing: false,\n };\n private _isRunning: boolean = false;\n private _lastBatchCreationTime: number = 0;\n private _loopAbortSignal: AbortSignalLike;\n private _maxBufferSize: number;\n private _maxWaitTimeInMs: number;\n private _onSendEventsErrorHandler: EventHubBufferedProducerClientOptions[\"onSendEventsErrorHandler\"];\n private _onSendEventsSuccessHandler?: EventHubBufferedProducerClientOptions[\"onSendEventsSuccessHandler\"];\n\n private _partitionId: string;\n private _producer: EventHubProducerClient;\n\n constructor({\n loopAbortSignal,\n maxBufferSize,\n maxWaitTimeInMs,\n onSendEventsErrorHandler,\n onSendEventsSuccessHandler,\n partitionId,\n producer,\n }: BatchingPartitionChannelProps) {\n this._loopAbortSignal = loopAbortSignal;\n this._maxBufferSize = maxBufferSize;\n this._maxWaitTimeInMs = maxWaitTimeInMs;\n this._onSendEventsErrorHandler = onSendEventsErrorHandler;\n this._onSendEventsSuccessHandler = onSendEventsSuccessHandler;\n this._partitionId = partitionId;\n this._producer = producer;\n }\n\n getCurrentBufferedCount(): number {\n return this._bufferCount;\n }\n\n async enqueueEvent(event: EventData | AmqpAnnotatedMessage): Promise<void> {\n await this._ready();\n this._eventQueue.push(event);\n this._bufferCount++;\n\n if (!this._isRunning) {\n this._isRunning = true;\n this._startPublishLoop().catch((e) => {\n logger.error(\n `The following error occured during batch creation or sending: ${JSON.stringify(\n e,\n undefined,\n \" \",\n )}`,\n );\n });\n }\n }\n\n /**\n * Sets the flush state so that no new events can be enqueued until\n * all the currently buffered events are sent to the Event Hub.\n *\n * Returns a promise that resolves once flushing is complete.\n */\n async flush(_options: OperationOptions = {}): Promise<void> {\n const state = this._flushState;\n if (state.isFlushing) {\n return state.currentPromise;\n }\n\n if (this.getCurrentBufferedCount() === 0) {\n return Promise.resolve();\n }\n\n const { promise, resolve } = getPromiseParts<void>();\n this._flushState = { isFlushing: true, currentPromise: promise, resolve };\n\n return promise;\n }\n\n /**\n * Returns a promise that resolves once there is room for events to be added\n * to the buffer.\n */\n private _ready(): Promise<void> {\n const currentBufferedCount = this.getCurrentBufferedCount();\n\n // If the buffer isn't full and we don't have any pending `ready()` calls,\n // then it's safe to return right away.\n if (\n currentBufferedCount < this._maxBufferSize &&\n !this._readyQueue.length &&\n !this._flushState.isFlushing\n ) {\n return Promise.resolve();\n }\n\n const { promise: readyPromise, reject, resolve } = getPromiseParts<void>();\n this._readyQueue.push({ resolve, reject });\n\n return readyPromise;\n }\n\n /**\n * Starts the loop that creates batches and sends them to the Event Hub.\n *\n * The loop will run until the `_loopAbortSignal` is aborted.\n */\n private async _startPublishLoop() {\n let batch: EventDataBatch | undefined;\n // `eventToAddToBatch` is used to keep track of an event that has been removed\n // from the queue, but has not yet been added to a batch.\n // This prevents losing an event if a `sendBatch` or `createBatch` call fails\n // before the event is added to a batch.\n let eventToAddToBatch: EventData | AmqpAnnotatedMessage | undefined;\n while (!this._loopAbortSignal.aborted) {\n try {\n if (!isDefined(batch)) {\n batch = await this._createBatch();\n }\n const timeSinceLastBatchCreation = Date.now() - this._lastBatchCreationTime;\n const maximumTimeToWaitForEvent = batch.count\n ? Math.max(this._maxWaitTimeInMs - timeSinceLastBatchCreation, 0)\n : this._maxWaitTimeInMs;\n\n const event =\n eventToAddToBatch ??\n (await cancelablePromiseRace<[EventData | AmqpAnnotatedMessage, void]>(\n [\n (abortOptions: AbortOptions) => this._eventQueue.shift(abortOptions),\n (abortOptions: AbortOptions) =>\n delay<void>(\n maximumTimeToWaitForEvent,\n abortOptions.abortSignal,\n abortOptions.abortErrorMsg,\n ),\n ],\n { abortSignal: this._loopAbortSignal },\n ));\n\n if (!event) {\n // We didn't receive an event within the allotted time.\n // Send the existing batch if it has events in it.\n if (batch.count) {\n await this._producer.sendBatch(batch);\n this._reportSuccess();\n batch = await this._createBatch();\n }\n continue;\n } else if (!eventToAddToBatch) {\n eventToAddToBatch = event;\n }\n\n const didAdd = batch.tryAdd(event);\n if (didAdd) {\n // This event will definitely make it to one of the user-provided handlers\n // since it was added to a batch.\n // Store it so we can return it in a handler later.\n this._batchedEvents.push(event);\n // Clear reference to existing event since it has been added to the batch.\n eventToAddToBatch = undefined;\n }\n\n if (didAdd && batch.count >= this._maxBufferSize) {\n // Whenever batch.count exceeds the max count of buffered events, send the batch.\n await this._producer.sendBatch(batch);\n this._reportSuccess();\n batch = await this._createBatch();\n } else if (!didAdd && batch.count) {\n // If the event wasn't able to be added and the current batch isn't empty,\n // attempt to send the current batch and add the event to a new batch.\n await this._producer.sendBatch(batch);\n this._reportSuccess();\n batch = await this._createBatch();\n }\n\n if (!didAdd && !batch.tryAdd(event)) {\n // TODO: Report MaxMesageSizeExceeded error. Mimic service's error.\n this._reportFailure(new Error(\"Placeholder for max message size exceeded\"), event);\n } else if (!didAdd) {\n // Handles the case where the event _was_ successfull added to the new batch.\n this._batchedEvents.push(event);\n }\n // Clear reference to existing event since it has been added to the batch.\n eventToAddToBatch = undefined;\n } catch (err: any) {\n if (!isObjectWithProperties(err, [\"name\"]) || err.name !== \"AbortError\") {\n this._reportFailure(err);\n batch = undefined;\n this._batchedEvents = [];\n }\n }\n }\n }\n\n /**\n * Helper method that returns an `EventDataBatch`.\n * This also has the side effects of\n * - keeping track of batch creation time: needed for maxWaitTime calculations.\n * - clearing reference to batched events.\n * - incrementing the readiness: creating a new batch indicates the buffer\n * should have room, so we can resolve some pending `ready()` calls.\n */\n private async _createBatch(): Promise<EventDataBatch> {\n this._lastBatchCreationTime = Date.now();\n this._batchedEvents = [];\n const batch = await this._producer.createBatch({\n partitionId: this._partitionId,\n });\n this._incrementReadiness();\n return batch;\n }\n\n /**\n * This method will resolve as many pending `ready()` calls as it can\n * based on how much space remains in the buffer.\n *\n * If the channel is currently flushing, this is a no-op. This prevents\n * `enqueueEvent` calls from adding the event to the buffer until flushing\n * completes.\n */\n private _incrementReadiness() {\n if (this._flushState.isFlushing) {\n return;\n }\n const currentBufferedCount = this.getCurrentBufferedCount();\n const num = Math.min(this._maxBufferSize - currentBufferedCount, this._readyQueue.length);\n for (let i = 0; i < num; i++) {\n this._readyQueue.shift()?.resolve();\n }\n }\n\n /**\n * Calls the user-provided `onSendEventsSuccessHandler` with the events\n * that were successfully sent.\n */\n private _reportSuccess() {\n this._bufferCount = this._bufferCount - this._batchedEvents.length;\n this._updateFlushState();\n try {\n this._onSendEventsSuccessHandler?.({\n events: this._batchedEvents,\n partitionId: this._partitionId,\n });\n } catch (e: unknown) {\n logger.error(\n `The following error occurred in the onSendEventsSuccessHandler: ${JSON.stringify(\n e,\n undefined,\n \" \",\n )}`,\n );\n }\n }\n\n /**\n * Calls the user-provided `onSendEventsErrorHandler` with an error and the events\n * that were not successfully sent.\n */\n private _reportFailure(err: any, event?: EventData | AmqpAnnotatedMessage) {\n this._bufferCount = this._bufferCount - (event ? 1 : this._batchedEvents.length);\n this._updateFlushState();\n try {\n this._onSendEventsErrorHandler({\n error: err,\n events: event ? [event] : this._batchedEvents,\n partitionId: this._partitionId,\n });\n } catch (e: unknown) {\n logger.error(\n `The following error occurred in the onSendEventsErrorHandler: ${JSON.stringify(\n e,\n undefined,\n \" \",\n )}`,\n );\n }\n }\n\n /**\n * Updates the channel's flush state once the size of the\n * event buffer has decreased to 0.\n */\n private _updateFlushState() {\n const state = this._flushState;\n if (!state.isFlushing || this.getCurrentBufferedCount() !== 0) {\n return;\n }\n\n state.resolve();\n\n this._flushState = { isFlushing: false };\n this._incrementReadiness();\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connectionContext.js","sourceRoot":"","sources":["../../src/connectionContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,oDAAoD;AACpD,0CAA0C;AAE1C,OAAO,EAAc,gBAAgB,EAAyC,MAAM,cAAc,CAAC;AACnG,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EAGT,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,6BAA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B,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,qBAAqB,EAAE,CAAC;QACnC,wBAAwB,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC3F,CAAC;IAED,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAElC,OAAO,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable no-inner-declarations */\n\nimport { Connection, ConnectionEvents, Dictionary, EventContext, OnAmqpEvent } from \"rhea-promise\";\nimport {\n ConnectionConfig,\n ConnectionContextBase,\n Constants,\n CreateConnectionContextBaseParameters,\n SasTokenProvider,\n createSasTokenProvider,\n} from \"@azure/core-amqp\";\nimport {\n EventHubConnectionStringProperties,\n parseEventHubConnectionString,\n} from \"./util/connectionStringUtils\";\nimport { ManagementClient, ManagementClientOptions } from \"./managementClient\";\nimport {\n NamedKeyCredential,\n SASCredential,\n TokenCredential,\n isNamedKeyCredential,\n isSASCredential,\n} from \"@azure/core-auth\";\nimport { logErrorStackTrace, logger } from \"./logger\";\nimport { EventHubClientOptions } from \"./models/public\";\nimport { EventHubConnectionConfig } from \"./eventhubConnectionConfig\";\nimport { PartitionReceiver } from \"./partitionReceiver\";\nimport { EventHubSender } from \"./eventHubSender\";\nimport { getRuntimeInfo } from \"./util/runtimeInfo\";\nimport { isCredential } from \"./util/typeGuards\";\nimport { packageJsonInfo } from \"./util/constants\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { createAbortablePromise } from \"@azure/core-util\";\n\n/**\n * @internal\n * Provides contextual information like the underlying amqp connection, cbs session, management session,\n * tokenProvider, senders, receivers, etc. about the EventHub client.\n */\nexport interface ConnectionContext extends ConnectionContextBase {\n /**\n * The EventHub connection config that is created after\n * parsing the connection string.\n */\n readonly config: EventHubConnectionConfig;\n /**\n * The credential to be used for Authentication.\n * Default value: SasTokenProvider.\n */\n tokenCredential: SasTokenProvider | TokenCredential;\n /**\n * Indicates whether the close() method was\n * called on theconnection object.\n */\n wasConnectionCloseCalled: boolean;\n /**\n * A dictionary of the EventHub Receivers associated with this client.\n */\n receivers: Dictionary<PartitionReceiver>;\n /**\n * A dictionary of the EventHub Senders associated with this client.\n */\n senders: Dictionary<EventHubSender>;\n /**\n * A reference to the management session ($management endpoint) on\n * the underlying amqp connection for the EventHub Client.\n */\n managementSession?: ManagementClient;\n /**\n * Function returning a promise that resolves once the connectionContext is ready to open an AMQP link.\n * ConnectionContext will be ready to open an AMQP link when:\n * - The AMQP connection is already open on both sides.\n * - The AMQP connection has been closed or disconnected. In this case, a new AMQP connection is expected\n * to be created first.\n * An AMQP link cannot be opened if the AMQP connection\n * is in the process of closing or disconnecting.\n */\n readyToOpenLink(options?: { abortSignal?: AbortSignalLike }): Promise<void>;\n /**\n * Closes all AMQP links, sessions and connection.\n */\n close(): Promise<void>;\n}\n\n/**\n * Describes the members on the ConnectionContext that are only\n * used by it internally.\n * @internal\n */\nexport interface ConnectionContextInternalMembers extends ConnectionContext {\n /**\n * Indicates whether the connection is in the process of closing.\n * When this returns `true`, a `disconnected` event will be received\n * after the connection is closed.\n *\n */\n isConnectionClosing(): boolean;\n /**\n * Resolves once the context's connection emits a `disconnected` event.\n */\n waitForDisconnectedEvent(options?: { abortSignal?: AbortSignalLike }): Promise<void>;\n /**\n * Resolves once the connection has finished being reset.\n * Connections are reset as part of reacting to a `disconnected` event.\n */\n waitForConnectionReset(): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport interface ConnectionContextOptions extends EventHubClientOptions {\n managementSessionAddress?: string;\n managementSessionAudience?: string;\n}\n\n/**\n * Helper type to get the names of all the functions on an object.\n */\ntype FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T]; // eslint-disable-line @typescript-eslint/ban-types\n/**\n * Helper type to get the types of all the functions on an object.\n */\ntype FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;\n/**\n * Helper type to get the types of all the functions on ConnectionContext\n * and the internal methods from ConnectionContextInternalMembers.\n * Note that this excludes the functions that ConnectionContext inherits.\n * Each function also has its `this` type set as `ConnectionContext`.\n */\ntype ConnectionContextMethods = Omit<\n FunctionProperties<ConnectionContextInternalMembers>,\n FunctionPropertyNames<ConnectionContextBase>\n> &\n ThisType<ConnectionContextInternalMembers>;\n\n/**\n * @internal\n */\nexport namespace ConnectionContext {\n /**\n * The user agent string for the EventHubs client.\n * See guideline at https://github.com/Azure/azure-sdk/blob/main/docs/design/Telemetry.mdk\n */\n const userAgent: string = `azsdk-js-azureeventhubs/${\n packageJsonInfo.version\n } (${getRuntimeInfo()})`;\n\n export function getUserAgent(options: ConnectionContextOptions): string {\n const finalUserAgent = options.userAgent ? `${userAgent},${options.userAgent}` : userAgent;\n if (finalUserAgent.length > Constants.maxUserAgentLength) {\n throw new Error(\n `The user-agent string cannot be more than ${Constants.maxUserAgentLength} characters in length.` +\n `The given user-agent string is: ${finalUserAgent} with length: ${finalUserAgent.length}`,\n );\n }\n return finalUserAgent;\n }\n\n export function create(\n config: EventHubConnectionConfig,\n tokenCredential: SasTokenProvider | TokenCredential,\n options?: ConnectionContextOptions,\n ): ConnectionContext {\n if (!options) options = {};\n\n config.webSocket = options.webSocketOptions && options.webSocketOptions.webSocket;\n config.webSocketEndpointPath = \"$servicebus/websocket\";\n config.webSocketConstructorOptions =\n options.webSocketOptions && options.webSocketOptions.webSocketConstructorOptions;\n\n const parameters: CreateConnectionContextBaseParameters = {\n config: config,\n // re-enabling this will be a post-GA discussion.\n // dataTransformer: options.dataTransformer,\n isEntityPathRequired: true,\n connectionProperties: {\n product: \"MSJSClient\",\n userAgent: getUserAgent(options),\n version: packageJsonInfo.version,\n },\n };\n // Let us create the base context and then add EventHub specific ConnectionContext properties.\n const connectionContext = ConnectionContextBase.create(parameters) as ConnectionContext;\n connectionContext.tokenCredential = tokenCredential;\n connectionContext.wasConnectionCloseCalled = false;\n connectionContext.senders = {};\n connectionContext.receivers = {};\n const mOptions: ManagementClientOptions = {\n address: options.managementSessionAddress,\n audience: options.managementSessionAudience,\n };\n connectionContext.managementSession = new ManagementClient(connectionContext, mOptions);\n\n let waitForConnectionRefreshResolve: () => void;\n let waitForConnectionRefreshPromise: Promise<void> | undefined;\n\n Object.assign<ConnectionContext, ConnectionContextMethods>(connectionContext, {\n isConnectionClosing() {\n // When the connection is not open, but the remote end is open,\n // then the rhea connection is in the process of terminating.\n return Boolean(!this.connection.isOpen() && this.connection.isRemoteOpen());\n },\n async readyToOpenLink(optionsArg?: { abortSignal?: AbortSignalLike }) {\n // Check that the connection isn't in the process of closing.\n // This can happen when the idle timeout has been reached but\n // the underlying socket is waiting to be destroyed.\n if (this.isConnectionClosing()) {\n // Wait for the disconnected event that indicates the underlying socket has closed.\n await this.waitForDisconnectedEvent(optionsArg);\n }\n\n // Wait for the connection to be reset.\n await this.waitForConnectionReset();\n },\n waitForDisconnectedEvent(optionsArg?: { abortSignal?: AbortSignalLike }) {\n return createAbortablePromise((resolve) => {\n logger.verbose(\n `[${this.connectionId}] Attempting to reinitialize connection` +\n ` but the connection is in the process of closing.` +\n ` Waiting for the disconnect event before continuing.`,\n );\n this.connection.once(ConnectionEvents.disconnected, resolve);\n }, optionsArg);\n },\n waitForConnectionReset() {\n // Check if the connection is currently in the process of disconnecting.\n if (waitForConnectionRefreshPromise) {\n return waitForConnectionRefreshPromise;\n }\n return Promise.resolve();\n },\n async close() {\n try {\n if (this.connection.isOpen()) {\n // Close all the senders.\n await Promise.all(\n Object.keys(connectionContext.senders).map((name) =>\n connectionContext.senders[name]?.close().catch(() => {\n /* error already logged, swallow it here */\n }),\n ),\n );\n // Close all the receivers.\n await Promise.all(\n Object.keys(connectionContext.receivers).map((name) =>\n connectionContext.receivers[name]?.close().catch(() => {\n /* error already logged, swallow it here */\n }),\n ),\n );\n // Close the cbs session;\n await this.cbsSession.close();\n // Close the management session\n await this.managementSession?.close();\n await this.connection.close();\n this.wasConnectionCloseCalled = true;\n logger.info(\"Closed the amqp connection '%s' on the client.\", this.connectionId);\n }\n } catch (err: any) {\n const errorDescription =\n err instanceof Error ? `${err.name}: ${err.message}` : JSON.stringify(err);\n logger.warning(\n `An error occurred while closing the connection \"${this.connectionId}\":\\n${errorDescription}`,\n );\n logErrorStackTrace(err);\n throw err;\n }\n },\n });\n\n // Define listeners to be added to the connection object for\n // \"connection_open\" and \"connection_error\" events.\n const onConnectionOpen: OnAmqpEvent = () => {\n connectionContext.wasConnectionCloseCalled = false;\n logger.verbose(\n \"[%s] setting 'wasConnectionCloseCalled' property of connection context to %s.\",\n connectionContext.connection.id,\n connectionContext.wasConnectionCloseCalled,\n );\n };\n\n const onDisconnected: OnAmqpEvent = async (context: EventContext) => {\n if (waitForConnectionRefreshPromise) {\n return;\n }\n waitForConnectionRefreshPromise = new Promise((resolve) => {\n waitForConnectionRefreshResolve = resolve;\n });\n try {\n logger.verbose(\n \"[%s] 'disconnected' event occurred on the amqp connection.\",\n connectionContext.connection.id,\n );\n\n if (context.connection && context.connection.error) {\n logger.verbose(\n \"[%s] Accompanying error on the context.connection: %O\",\n connectionContext.connection.id,\n context.connection && context.connection.error,\n );\n }\n if (context.error) {\n logger.verbose(\n \"[%s] Accompanying error on the context: %O\",\n connectionContext.connection.id,\n context.error,\n );\n }\n const state: Readonly<{\n wasConnectionCloseCalled: boolean;\n numSenders: number;\n numReceivers: number;\n }> = {\n wasConnectionCloseCalled: connectionContext.wasConnectionCloseCalled,\n numSenders: Object.keys(connectionContext.senders).length,\n numReceivers: Object.keys(connectionContext.receivers).length,\n };\n logger.verbose(\n \"[%s] Closing all open senders and receivers in the state: %O\",\n connectionContext.connection.id,\n state,\n );\n\n // Clear internal map maintained by rhea to avoid reconnecting of old links once the\n // connection is back up.\n connectionContext.connection.removeAllSessions();\n\n // Close the cbs session to ensure all the event handlers are released.\n await connectionContext.cbsSession?.close().catch(() => {\n /* error already logged, swallow it here */\n });\n // Close the management session to ensure all the event handlers are released.\n await connectionContext.managementSession?.close().catch(() => {\n /* error already logged, swallow it here */\n });\n\n // Close all senders and receivers to ensure clean up of timers & other resources.\n if (state.numSenders || state.numReceivers) {\n await Promise.all(\n Object.keys(connectionContext.senders).map((name) =>\n connectionContext.senders[name]?.close().catch(() => {\n /* error already logged, swallow it here */\n }),\n ),\n );\n\n await Promise.all(\n Object.keys(connectionContext.receivers).map((name) =>\n connectionContext.receivers[name]?.close().catch(() => {\n /* error already logged, swallow it here */\n }),\n ),\n );\n }\n } catch (err: any) {\n logger.verbose(\n `[${connectionContext.connectionId}] An error occurred while closing the connection in 'disconnected'. %O`,\n err,\n );\n }\n\n try {\n await refreshConnection(connectionContext);\n } catch (err: any) {\n logger.verbose(\n `[${connectionContext.connectionId}] An error occurred while refreshing the connection in 'disconnected'. %O`,\n err,\n );\n } finally {\n waitForConnectionRefreshResolve();\n waitForConnectionRefreshPromise = undefined;\n }\n };\n\n const protocolError: OnAmqpEvent = async (context: EventContext) => {\n logger.verbose(\n \"[%s] 'protocol_error' event occurred on the amqp connection.\",\n connectionContext.connection.id,\n );\n\n if (context.connection && context.connection.error) {\n logger.verbose(\n \"[%s] Accompanying error on the context.connection: %O\",\n connectionContext.connection.id,\n context.connection && context.connection.error,\n );\n }\n if (context.error) {\n logger.verbose(\n \"[%s] Accompanying error on the context: %O\",\n connectionContext.connection.id,\n context.error,\n );\n }\n };\n\n const error: OnAmqpEvent = async (context: EventContext) => {\n logger.verbose(\n \"[%s] 'error' event occurred on the amqp connection.\",\n connectionContext.connection.id,\n );\n\n if (context.connection && context.connection.error) {\n logger.verbose(\n \"[%s] Accompanying error on the context.connection: %O\",\n connectionContext.connection.id,\n context.connection && context.connection.error,\n );\n }\n if (context.error) {\n logger.verbose(\n \"[%s] Accompanying error on the context: %O\",\n connectionContext.connection.id,\n context.error,\n );\n }\n };\n\n function addConnectionListeners(connection: Connection): void {\n // Add listeners on the connection object.\n connection.on(ConnectionEvents.connectionOpen, onConnectionOpen);\n connection.on(ConnectionEvents.disconnected, onDisconnected);\n connection.on(ConnectionEvents.protocolError, protocolError);\n connection.on(ConnectionEvents.error, error);\n }\n\n function cleanConnectionContext(context: ConnectionContext): Promise<void> {\n // Remove listeners from the connection object.\n context.connection.removeListener(ConnectionEvents.connectionOpen, onConnectionOpen);\n context.connection.removeListener(ConnectionEvents.disconnected, onDisconnected);\n context.connection.removeListener(ConnectionEvents.protocolError, protocolError);\n context.connection.removeListener(ConnectionEvents.error, error);\n // Close the connection\n return context.connection.close();\n }\n\n async function refreshConnection(context: ConnectionContext): Promise<void> {\n const originalConnectionId = context.connectionId;\n try {\n await cleanConnectionContext(context);\n } catch (err: any) {\n logger.verbose(\n `[${context.connectionId}] There was an error closing the connection before reconnecting: %O`,\n err,\n );\n }\n\n // Create a new connection, id, locks, and cbs client.\n context.refreshConnection();\n addConnectionListeners(context.connection);\n logger.verbose(\n `The connection \"${originalConnectionId}\" has been updated to \"${context.connectionId}\".`,\n );\n }\n\n addConnectionListeners(connectionContext.connection);\n\n logger.verbose(\"[%s] Created connection context successfully.\", connectionContext.connectionId);\n return connectionContext;\n }\n}\n\n/**\n * Helper method to create a ConnectionContext from the input passed to either\n * EventHubProducerClient or EventHubConsumerClient constructors\n *\n * @internal\n */\nexport function createConnectionContext(\n hostOrConnectionString: string,\n eventHubNameOrOptions?: string | EventHubClientOptions,\n credentialOrOptions?:\n | TokenCredential\n | NamedKeyCredential\n | SASCredential\n | EventHubClientOptions,\n options?: EventHubClientOptions,\n): ConnectionContext {\n let connectionString;\n let config;\n let credential: TokenCredential | SasTokenProvider;\n hostOrConnectionString = String(hostOrConnectionString);\n\n if (!isCredential(credentialOrOptions)) {\n const parsedCS = parseEventHubConnectionString(hostOrConnectionString);\n if (\n !(\n parsedCS.eventHubName ||\n (typeof eventHubNameOrOptions === \"string\" && eventHubNameOrOptions)\n )\n ) {\n throw new TypeError(\n `Either provide \"eventHubName\" or the \"connectionString\": \"${hostOrConnectionString}\", ` +\n `must contain \"EntityPath=<your-event-hub-name>\".`,\n );\n }\n if (\n parsedCS.eventHubName &&\n typeof eventHubNameOrOptions === \"string\" &&\n eventHubNameOrOptions &&\n parsedCS.eventHubName !== eventHubNameOrOptions\n ) {\n throw new TypeError(\n `The entity path \"${parsedCS.eventHubName}\" in connectionString: \"${hostOrConnectionString}\" ` +\n `doesn't match with eventHubName: \"${eventHubNameOrOptions}\".`,\n );\n }\n connectionString = hostOrConnectionString;\n if (typeof eventHubNameOrOptions !== \"string\") {\n // connectionstring and/or options were passed to constructor\n config = EventHubConnectionConfig.create(connectionString);\n options = eventHubNameOrOptions;\n } else {\n // connectionstring, eventHubName and/or options were passed to constructor\n const eventHubName = eventHubNameOrOptions;\n config = EventHubConnectionConfig.create(connectionString, eventHubName);\n options = credentialOrOptions;\n }\n\n const parsed = parseEventHubConnectionString(connectionString) as Required<\n | Pick<EventHubConnectionStringProperties, \"sharedAccessKey\" | \"sharedAccessKeyName\">\n | Pick<EventHubConnectionStringProperties, \"sharedAccessSignature\">\n >;\n // Since connectionString was passed, create a TokenProvider.\n credential = createSasTokenProvider(parsed);\n } else {\n // host, eventHubName, a TokenCredential and/or options were passed to constructor\n const eventHubName = eventHubNameOrOptions;\n let host = hostOrConnectionString;\n if (isNamedKeyCredential(credentialOrOptions) || isSASCredential(credentialOrOptions)) {\n credential = createSasTokenProvider(credentialOrOptions);\n } else {\n credential = credentialOrOptions;\n }\n if (!eventHubName) {\n throw new TypeError(`\"eventHubName\" is missing`);\n }\n\n if (!host.endsWith(\"/\")) host += \"/\";\n connectionString = `Endpoint=sb://${host};SharedAccessKeyName=defaultKeyName;SharedAccessKey=defaultKeyValue;EntityPath=${eventHubName}`;\n config = EventHubConnectionConfig.create(connectionString);\n }\n\n if (options?.customEndpointAddress) {\n EventHubConnectionConfig.setCustomEndpointAddress(config, options.customEndpointAddress);\n }\n\n ConnectionConfig.validate(config);\n\n return ConnectionContext.create(config, credential, options);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataTransformer.js","sourceRoot":"","sources":["../../src/dataTransformer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQvC,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAa,CAAC;AACjD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAa,CAAC;AACrD,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAa,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC;;;;;;;OAOG;IACH,MAAM,CAAC,IAAa,EAAE,QAAmB;QACvC,IAAI,MAAW,CAAC;QAChB,6EAA6E;QAC7E,sFAAsF;QACtF,uBAAuB;QACvB,IAAI,IAAI,KAAK,SAAS;YAAE,IAAI,GAAG,IAAI,CAAC;QAEpC,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YACzB,2FAA2F;YAC3F,oEAAoE;YACpE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACpC,MAAM,CAAC,QAAQ,GAAG,oBAAoB,CAAC;QACzC,CAAC;aAAM,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;YACnC,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;aAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,YAAY,UAAU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C5C,CAAC,eAAe,CAAC,QAAQ,KAAK,mBAAmB;YAC/C,eAAe,CAAC,QAAQ,KAAK,oBAAoB;YACjD,eAAe,CAAC,QAAQ,KAAK,uBAAuB,CAAC,CACxD,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { logErrorStackTrace, logger } from \"./logger\";\nimport { Buffer } from \"buffer\";\nimport isBuffer from \"is-buffer\";\nimport { message } from \"rhea-promise\";\n\n/**\n * The allowed AMQP message body types.\n * @internal\n */\nexport type BodyTypes = \"data\" | \"value\" | \"sequence\";\n\n/** @internal */\nexport const dataSectionTypeCode = 0x75 as const;\n/** @internal */\nexport const sequenceSectionTypeCode = 0x76 as const;\n/** @internal */\nexport const valueSectionTypeCode = 0x77 as const;\n\n/**\n * The default data transformer that will be used by the Azure SDK.\n * @internal\n */\nexport const defaultDataTransformer = {\n /**\n * A function that takes the body property from an EventData object\n * and returns an encoded body (some form of AMQP type).\n *\n * @param body - The AMQP message body\n * @param bodyType - The AMQP section to story the body in.\n * @returns The encoded AMQP message body as an AMQP Data/Sequence/Value section.\n */\n encode(body: unknown, bodyType: BodyTypes): any {\n let result: any;\n // string, undefined, null, boolean, array, object, number should end up here\n // coercing undefined to null as that will ensure that null value will be given to the\n // customer on receive.\n if (body === undefined) body = null;\n\n if (bodyType === \"value\") {\n // TODO: Expose value_section from `rhea` similar to the data_section and sequence_section.\n // Right now there isn't a way to create a value section officially.\n result = message.data_section(body);\n result.typecode = valueSectionTypeCode;\n } else if (bodyType === \"sequence\") {\n result = message.sequence_section(body);\n } else if (isBuffer(body) || body instanceof Uint8Array) {\n result = message.data_section(body);\n } else if (body === null && bodyType === \"data\") {\n result = message.data_section(null);\n } else {\n try {\n const bodyStr = JSON.stringify(body);\n result = message.data_section(Buffer.from(bodyStr, \"utf8\"));\n } catch (err: any) {\n const msg =\n `An error occurred while executing JSON.stringify() on the given body ` +\n body +\n `${err ? err.stack : JSON.stringify(err)}`;\n logger.warning(\"[encode] \" + msg);\n logErrorStackTrace(err);\n throw new Error(msg);\n }\n }\n return result;\n },\n\n /**\n * A function that takes the body property from an AMQP message, which can come from either\n * the 'data', 'value' or 'sequence' sections of an AMQP message.\n *\n * If the body is not a JSON string the the raw contents will be returned, along with the bodyType\n * indicating which part of the AMQP message the body was decoded from.\n *\n * @param body - The AMQP message body as received from rhea.\n * @param skipParsingBodyAsJson - Boolean to skip running JSON.parse() on message body when body type is `content`.\n * @returns The decoded/raw body and the body type.\n */\n decode(\n body: unknown | RheaAmqpSection,\n skipParsingBodyAsJson: boolean,\n ): { body: unknown; bodyType: BodyTypes } {\n try {\n if (isRheaAmqpSection(body)) {\n switch (body.typecode) {\n case dataSectionTypeCode:\n return {\n body: skipParsingBodyAsJson ? body.content : tryToJsonDecode(body.content),\n bodyType: \"data\",\n };\n case sequenceSectionTypeCode:\n return { body: body.content, bodyType: \"sequence\" };\n case valueSectionTypeCode:\n return { body: body.content, bodyType: \"value\" };\n }\n } else {\n if (isBuffer(body)) {\n return { body: skipParsingBodyAsJson ? body : tryToJsonDecode(body), bodyType: \"data\" };\n }\n\n return { body, bodyType: \"value\" };\n }\n } catch (err: any) {\n logger.verbose(\n \"[decode] An error occurred while decoding the received message body. The error is: %O\",\n err,\n );\n throw err;\n }\n },\n};\n\n/**\n * Attempts to decode 'body' as a JSON string. If it fails it returns body\n * verbatim.\n *\n * @param body - An AMQP message body.\n * @returns A JSON decoded object, or body if body was not a JSON string.\n *\n * @internal\n */\nfunction tryToJsonDecode(body: unknown): unknown {\n let processedBody: any = body;\n try {\n // Trying to stringify and JSON.parse() anything else will fail flat and we shall return\n // the original type back\n const bodyStr: string = processedBody.toString(\"utf8\");\n processedBody = JSON.parse(bodyStr);\n } catch (err: any) {\n logger.verbose(\n \"[decode] An error occurred while trying JSON.parse() on the received body. The error is %O\",\n err,\n );\n }\n return processedBody;\n}\n\n/**\n * Mirror of the internal Section interface in rhea.\n *\n * @internal\n */\nexport interface RheaAmqpSection {\n typecode:\n | typeof dataSectionTypeCode\n | typeof sequenceSectionTypeCode\n | typeof valueSectionTypeCode;\n content: any;\n}\n\n/** @internal */\nexport function isRheaAmqpSection(\n possibleSection: any | RheaAmqpSection,\n): possibleSection is RheaAmqpSection {\n return (\n possibleSection != null &&\n typeof possibleSection.typecode === \"number\" &&\n (possibleSection.typecode === dataSectionTypeCode ||\n possibleSection.typecode === valueSectionTypeCode ||\n possibleSection.typecode === sequenceSectionTypeCode)\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentEventData.js","sourceRoot":"","sources":["../../../src/diagnostics/instrumentEventData.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAa,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAIjE,OAAO,EAA2B,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAElF;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAA2C,EAC3C,OAAyB,EACzB,UAAkB,EAClB,IAAY,EACZ,SAAmC;;IAEnC,MAAM,KAAK,GAAG,sBAAsB,CAAC,SAAS,CAAC;QAC7C,CAAC,CAAC,SAAS,CAAC,qBAAqB;QACjC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC;IAEzB,mDAAmD;IACnD,MAAM,sBAAsB,GAAG,OAAO,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,oBAAoB,CAAC,CAAC,CAAC;IAEtE,IAAI,sBAAsB,EAAE,CAAC;QAC3B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;IACtD,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACnE,SAAS,EACT,OAAO,EACP,aAAa,CAA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c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EventData, isAmqpAnnotatedMessage } from \"../eventData\";\nimport { TracingContext } from \"@azure/core-tracing\";\nimport { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { OperationOptions } from \"../util/operationOptions\";\nimport { MessagingOperationNames, toSpanOptions, tracingClient } from \"./tracing\";\n\n/**\n * @internal\n */\nexport const TRACEPARENT_PROPERTY = \"Diagnostic-Id\";\n\n/**\n * Populates the `EventData` with `SpanContext` info to support trace propagation.\n * Creates and returns a copy of the passed in `EventData` unless the `EventData`\n * has already been instrumented.\n * @param eventData - The `EventData` or `AmqpAnnotatedMessage` to instrument.\n * @param span - The `Span` containing the context to propagate tracing information.\n * @param operation - The type of the operation being performed.\n */\nexport function instrumentEventData(\n eventData: EventData | AmqpAnnotatedMessage,\n options: OperationOptions,\n entityPath: string,\n host: string,\n operation?: MessagingOperationNames,\n): { event: EventData; spanContext: TracingContext | undefined } {\n const props = isAmqpAnnotatedMessage(eventData)\n ? eventData.applicationProperties\n : eventData.properties;\n\n // check if the event has already been instrumented\n const previouslyInstrumented = Boolean(props?.[TRACEPARENT_PROPERTY]);\n\n if (previouslyInstrumented) {\n return { event: eventData, spanContext: undefined };\n }\n\n const { span: messageSpan, updatedOptions } = tracingClient.startSpan(\n \"message\",\n options,\n toSpanOptions({ entityPath, host }, operation, \"producer\"),\n );\n try {\n if (!messageSpan.isRecording()) {\n return {\n event: eventData,\n spanContext: undefined,\n };\n }\n\n const traceParent = tracingClient.createRequestHeaders(\n updatedOptions.tracingOptions?.tracingContext,\n )[\"traceparent\"];\n if (traceParent) {\n const copiedProps = { ...props };\n\n // create a copy so the original isn't modified\n if (isAmqpAnnotatedMessage(eventData)) {\n eventData = { ...eventData, applicationProperties: copiedProps };\n } else {\n eventData = { ...eventData, properties: copiedProps };\n }\n copiedProps[TRACEPARENT_PROPERTY] = traceParent;\n }\n\n return {\n event: eventData,\n spanContext: updatedOptions.tracingOptions?.tracingContext,\n };\n } finally {\n messageSpan.end();\n }\n}\n\n/**\n * Extracts the `SpanContext` from an `EventData` if the context exists.\n * @param eventData - An individual `EventData` object.\n * @internal\n */\nexport function extractSpanContextFromEventData(eventData: EventData): TracingContext | undefined {\n if (!eventData.properties || !eventData.properties[TRACEPARENT_PROPERTY]) {\n return;\n }\n\n const diagnosticId = eventData.properties[TRACEPARENT_PROPERTY];\n return tracingClient.parseTraceparentHeader(diagnosticId);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/diagnostics/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAuC,MAAM,qBAAqB,CAAC;AAE/F,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAOpD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,SAAS,EAAE,oBAAoB;IAC/B,WAAW,EAAE,eAAe,CAAC,IAAI;IACjC,cAAc,EAAE,eAAe,CAAC,OAAO;CACxC,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,cAAqE,EACrE,SAAmC,EACnC,QAA0B;IAE1B,MAAM,YAAY,GAChB,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS;QAChD,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,4BAA4B,CAAC;IAEnC,MAAM,cAAc,GAAG;QACrB,kBAAkB,EAAE,WAAW;QAC/B,CAAC,YAAY,CAAC,EAAE,cAAc,CAAC,UAAU;QACzC,eAAe,EAAE,cAAc,CAAC,IAAI;KACrC,CAAC;IAEF,IAAI,SAAS,EAAE,CAAC;QACd,cAAc,CAAC,qBAAqB,CAAC,GAAG,SAAS,CAAC;IACpD,CAAC;IAED,MAAM,WAAW,GAAuB;QACtC,cAAc,EAAE,cAAc;KAC/B,CAAC;IACF,IAAI,QAAQ,EAAE,CAAC;QACb,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAClC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createTracingClient, TracingSpanOptions, TracingSpanKind } from \"@azure/core-tracing\";\nimport { EventHubConnectionConfig } from \"../eventhubConnectionConfig\";\nimport { packageJsonInfo } from \"../util/constants\";\n\n/**\n * The names of the operations that can be instrumented.\n */\nexport type MessagingOperationNames = \"publish\" | \"receive\" | \"process\";\n\n/**\n * The {@link TracingClient} that is used to add tracing spans.\n */\nexport const tracingClient = createTracingClient({\n namespace: \"Microsoft.EventHub\",\n packageName: packageJsonInfo.name,\n packageVersion: packageJsonInfo.version,\n});\n\n/**\n * Creates {@link TracingSpanOptions} from the provided data.\n * @param eventHubConfig - The configuration object containing initial attributes to set on the span.\n * @param spanKind - The {@link TracingSpanKind} for the newly created span.\n * @param operation - The operation type.\n * @returns a {@link TracingSpanOptions} that can be passed to a {@link TracingClient}\n */\nexport function toSpanOptions(\n eventHubConfig: Pick<EventHubConnectionConfig, \"entityPath\" | \"host\">,\n operation?: MessagingOperationNames,\n spanKind?: TracingSpanKind,\n): TracingSpanOptions {\n const propertyName =\n operation === \"process\" || operation === \"receive\"\n ? \"messaging.source.name\"\n : \"messaging.destination.name\";\n\n const spanAttributes = {\n \"messaging.system\": \"eventhubs\",\n [propertyName]: eventHubConfig.entityPath,\n \"net.peer.name\": eventHubConfig.host,\n };\n\n if (operation) {\n spanAttributes[\"messaging.operation\"] = operation;\n }\n\n const spanOptions: TracingSpanOptions = {\n spanAttributes: spanAttributes,\n };\n if (spanKind) {\n spanOptions.spanKind = spanKind;\n }\n return spanOptions;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventData.js","sourceRoot":"","sources":["../../src/eventData.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,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OAAO,KAAK,CAAC;AACf,CAAC;AAYD;;;GAGG;AACH,MAAM,UAAU,oCAAoC,CAClD,WAAwB,EACxB,EACE,6BAA6B,EAC7B,UAAU,EACV,eAAe,EACf,qBAAqB,GAC0B;IAEjD,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACnC,OAAO;IACT,CAAC;IAED,MAAM,kBAAkB,GAAG,WAAW,CAAC,mBAAmB,IAAI,EAAE,CAAC;IACjE,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;QACrC,WAAW,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;IACvD,CAAC;IAED,IAAI,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1B,kBAAkB,CAAC,mCAAmC,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/F,CAAC;IACD,IAAI,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;QAC/B,kBAAkB,CAAC,mCAAmC,CAAC,UAAU,CAAC;YAChE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,SAAS,CAAC,qBAAqB,CAAC,EAAE,CAAC;QACrC,kBAAkB,CAAC,mCAAmC,CAAC,sBAAsB,CAAC;YAC5E,KAAK,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AmqpAnnotatedMessage, Constants } from \"@azure/core-amqp\";\nimport { BodyTypes, defaultDataTransformer } from \"./dataTransformer\";\nimport {\n DeliveryAnnotations,\n MessageAnnotations,\n Message as RheaMessage,\n types,\n} from \"rhea-promise\";\nimport { isDefined, isObjectWithProperties, objectHasProperty } from \"@azure/core-util\";\nimport {\n idempotentProducerAmqpPropertyNames,\n PENDING_PUBLISH_SEQ_NUM_SYMBOL,\n} from \"./util/constants\";\n\n/**\n * Describes the delivery annotations.\n * @internal\n */\nexport interface EventHubDeliveryAnnotations extends DeliveryAnnotations {\n /**\n * The offset of the last event.\n */\n last_enqueued_offset?: string;\n /**\n * The sequence number of the last event.\n */\n last_enqueued_sequence_number?: number;\n /**\n * The enqueued time of the last event.\n */\n last_enqueued_time_utc?: number;\n /**\n * The retrieval time of the last event.\n */\n runtime_info_retrieval_time_utc?: number;\n /**\n * Any unknown delivery annotations.\n */\n [x: string]: any;\n}\n\n/**\n * Map containing message attributes that will be held in the message header.\n * @internal\n */\nexport interface EventHubMessageAnnotations extends MessageAnnotations {\n /**\n * Annotation for the partition key set for the event.\n */\n \"x-opt-partition-key\"?: string | null;\n /**\n * Annotation for the sequence number of the event.\n */\n \"x-opt-sequence-number\"?: number;\n /**\n * Annotation for the enqueued time of the event.\n */\n \"x-opt-enqueued-time\"?: number;\n /**\n * Annotation for the offset of the event.\n */\n \"x-opt-offset\"?: string;\n /**\n * Any other annotation that can be added to the message.\n */\n [x: string]: any;\n}\n\n/**\n * Describes the structure of an event to be sent or received from the EventHub.\n * @internal\n */\nexport interface EventDataInternal {\n /**\n * The message body that needs to be sent or is received.\n */\n body: any;\n /**\n * The enqueued time of the event.\n */\n enqueuedTimeUtc?: Date;\n /**\n * If specified EventHub will hash this to a partitionId.\n * It guarantees that messages end up in a specific partition on the event hub.\n */\n partitionKey?: string | null;\n /**\n * The offset of the event.\n */\n offset?: string;\n /**\n * The sequence number of the event.\n */\n sequenceNumber?: number;\n /**\n * The application specific properties.\n */\n properties?: { [property: string]: any };\n /**\n * The last sequence number of the event within the partition stream of the Event Hub.\n */\n lastSequenceNumber?: number;\n /**\n * The offset of the last enqueued event.\n */\n lastEnqueuedOffset?: string;\n /**\n * The enqueued UTC time of the last event.\n */\n lastEnqueuedTime?: Date;\n /**\n * The time when the runtime info was retrieved\n */\n retrievalTime?: Date;\n /**\n * The properties set by the service.\n */\n systemProperties?: { [property: string]: any };\n /**\n * The content type of the message. Optionally describes\n * the payload of the message, with a descriptor following the format of RFC2045, Section 5, for\n * example \"application/json\".\n */\n contentType?: string;\n\n /**\n * The correlation identifier that allows an\n * application to specify a context for the message for the purposes of correlation, for example\n * reflecting the MessageId of a message that is being replied to.\n */\n correlationId?: string | number | Buffer;\n\n /**\n * The message identifier is an\n * application-defined value that uniquely identifies the message and its payload.\n *\n * Note: Numbers that are not whole integers are not allowed.\n */\n messageId?: string | number | Buffer;\n /**\n * Returns the underlying raw amqp message.\n */\n getRawAmqpMessage(): AmqpAnnotatedMessage;\n /**\n * The pending publish sequence number, set while the event\n * is being published with idempotent partitions enabled.\n */\n [PENDING_PUBLISH_SEQ_NUM_SYMBOL]?: number;\n /**\n * The sequence number the event was published with\n * when idempotent partitions are enabled.\n */\n _publishedSequenceNumber?: number;\n}\n\nconst messagePropertiesMap = {\n message_id: \"messageId\",\n user_id: \"userId\",\n to: \"to\",\n subject: \"subject\",\n reply_to: \"replyTo\",\n correlation_id: \"correlationId\",\n content_type: \"contentType\",\n content_encoding: \"contentEncoding\",\n absolute_expiry_time: \"absoluteExpiryTime\",\n creation_time: \"creationTime\",\n group_id: \"groupId\",\n group_sequence: \"groupSequence\",\n reply_to_group_id: \"replyToGroupId\",\n} as const;\n\n/**\n * Converts the AMQP message to an EventData.\n * @param msg - The AMQP message that needs to be converted to EventData.\n * @param skipParsingBodyAsJson - Boolean to skip running JSON.parse() on message body when body type is `content`.\n * @internal\n */\nexport function fromRheaMessage(\n msg: RheaMessage,\n skipParsingBodyAsJson: boolean,\n): EventDataInternal {\n const rawMessage = AmqpAnnotatedMessage.fromRheaMessage(msg);\n const { body, bodyType } = defaultDataTransformer.decode(msg.body, skipParsingBodyAsJson);\n rawMessage.bodyType = bodyType;\n\n const data: EventDataInternal = {\n body,\n getRawAmqpMessage() {\n return rawMessage;\n },\n };\n\n if (msg.message_annotations) {\n for (const annotationKey of Object.keys(msg.message_annotations)) {\n switch (annotationKey) {\n case Constants.partitionKey:\n data.partitionKey = msg.message_annotations[annotationKey];\n break;\n case Constants.sequenceNumber:\n data.sequenceNumber = msg.message_annotations[annotationKey];\n break;\n case Constants.enqueuedTime:\n data.enqueuedTimeUtc = new Date(msg.message_annotations[annotationKey]);\n break;\n case Constants.offset:\n data.offset = msg.message_annotations[annotationKey];\n break;\n default:\n if (!data.systemProperties) {\n data.systemProperties = {};\n }\n data.systemProperties[annotationKey] = convertDatesToNumbers(\n msg.message_annotations[annotationKey],\n );\n break;\n }\n }\n }\n if (msg.application_properties) {\n data.properties = convertDatesToNumbers(msg.application_properties);\n }\n if (msg.delivery_annotations) {\n data.lastEnqueuedOffset = msg.delivery_annotations.last_enqueued_offset;\n data.lastSequenceNumber = msg.delivery_annotations.last_enqueued_sequence_number;\n data.lastEnqueuedTime = new Date(msg.delivery_annotations.last_enqueued_time_utc as number);\n data.retrievalTime = new Date(\n msg.delivery_annotations.runtime_info_retrieval_time_utc as number,\n );\n }\n\n const messageProperties = Object.keys(messagePropertiesMap) as Array<\n keyof typeof messagePropertiesMap\n >;\n for (const messageProperty of messageProperties) {\n if (!data.systemProperties) {\n data.systemProperties = {};\n }\n if (msg[messageProperty] != null) {\n data.systemProperties[messagePropertiesMap[messageProperty]] = convertDatesToNumbers(\n msg[messageProperty],\n );\n }\n }\n\n if (msg.content_type != null) {\n data.contentType = msg.content_type;\n }\n if (msg.correlation_id != null) {\n data.correlationId = msg.correlation_id;\n }\n if (msg.message_id != null) {\n data.messageId = msg.message_id;\n }\n\n return data;\n}\n\n/**\n * Converts an EventData object to an AMQP message.\n * @param data - The EventData object that needs to be converted to an AMQP message.\n * @param partitionKey - An optional key to determine the partition that this event should land in.\n * @internal\n */\nexport function toRheaMessage(\n data: EventData | AmqpAnnotatedMessage,\n partitionKey?: string,\n): RheaMessage {\n let rheaMessage: RheaMessage;\n if (isAmqpAnnotatedMessage(data)) {\n rheaMessage = {\n ...AmqpAnnotatedMessage.toRheaMessage(data),\n body: defaultDataTransformer.encode(data.body, data.bodyType ?? \"data\"),\n };\n } else {\n let bodyType: BodyTypes = \"data\";\n if (typeof (data as EventDataInternal).getRawAmqpMessage === \"function\") {\n /*\n If the event is being round-tripped, then we respect the `bodyType` of the\n underlying AMQP message.\n */\n bodyType = (data as EventDataInternal).getRawAmqpMessage().bodyType ?? \"data\";\n }\n\n rheaMessage = {\n body: defaultDataTransformer.encode(data.body, bodyType),\n };\n // As per the AMQP 1.0 spec If the message-annotations or delivery-annotations section is omitted,\n // it is equivalent to a message-annotations section containing anempty map of annotations.\n rheaMessage.message_annotations = {};\n\n if (data.properties) {\n rheaMessage.application_properties = data.properties;\n }\n\n if (isDefined(partitionKey)) {\n rheaMessage.message_annotations[Constants.partitionKey] = partitionKey;\n // Event Hub service cannot route messages to a specific partition based on the partition key\n // if AMQP message header is an empty object. Hence we make sure that header is always present\n // with atleast one property. Setting durable to true, helps us achieve that.\n rheaMessage.durable = true;\n }\n\n if (data.contentType != null) {\n rheaMessage.content_type = data.contentType;\n }\n if (data.correlationId != null) {\n rheaMessage.correlation_id = data.correlationId;\n }\n if (data.messageId != null) {\n if (\n typeof data.messageId === \"string\" &&\n data.messageId.length > Constants.maxMessageIdLength\n ) {\n throw new Error(\n `Length of 'messageId' property on the event cannot be greater than ${Constants.maxMessageIdLength} characters.`,\n );\n }\n rheaMessage.message_id = data.messageId;\n }\n }\n\n return rheaMessage;\n}\n\n/**\n * The interface that describes the data to be sent to Event Hub.\n * Use this as a reference when creating the object to be sent when using the `EventHubProducerClient`.\n * For example, `{ body: \"your-data\" }` or\n * ```\n * {\n * body: \"your-data\",\n * properties: {\n * propertyName: \"property value\"\n * }\n * }\n * ```\n */\nexport interface EventData {\n /**\n * The message body that needs to be sent.\n * If the application reading the events is not using this SDK,\n * convert your body payload to a byte array or Buffer for better\n * cross-language compatibility.\n */\n body: any;\n\n /**\n * The content type of the message. Optionally describes\n * the payload of the message, with a descriptor following the format of RFC2045, Section 5, for\n * example \"application/json\".\n */\n contentType?: string;\n\n /**\n * The correlation identifier that allows an\n * application to specify a context for the message for the purposes of correlation, for example\n * reflecting the MessageId of a message that is being replied to.\n */\n correlationId?: string | number | Buffer;\n\n /**\n * The message identifier is an\n * application-defined value that uniquely identifies the message and its payload.\n *\n * Note: Numbers that are not whole integers are not allowed.\n */\n messageId?: string | number | Buffer;\n\n /**\n * Set of key value pairs that can be used to set properties specific to user application.\n */\n properties?: {\n [key: string]: any;\n };\n}\n\n/**\n * The interface that describes the structure of the event received from Event Hub.\n * Use this as a reference when creating the `processEvents` function to process the events\n * recieved from an Event Hub when using the `EventHubConsumerClient`.\n */\nexport interface ReceivedEventData {\n /**\n * The message body that needs to be sent or is received.\n */\n body: any;\n /**\n * The application specific properties.\n */\n properties?: {\n [key: string]: any;\n };\n /**\n * The enqueued time of the event.\n */\n enqueuedTimeUtc: Date;\n /**\n * When specified Event Hub will hash this to a partitionId.\n * It guarantees that messages end up in a specific partition on the event hub.\n */\n partitionKey: string | null;\n /**\n * The offset of the event.\n */\n offset: string;\n /**\n * The sequence number of the event.\n */\n sequenceNumber: number;\n /**\n * The properties set by the service.\n */\n systemProperties?: {\n [key: string]: any;\n };\n\n /**\n * The content type of the message. Optionally describes\n * the payload of the message, with a descriptor following the format of RFC2045, Section 5, for\n * example \"application/json\".\n */\n contentType?: string;\n\n /**\n * The correlation identifier that allows an\n * application to specify a context for the message for the purposes of correlation, for example\n * reflecting the MessageId of a message that is being replied to.\n */\n correlationId?: string | number | Buffer;\n\n /**\n * The message identifier is an\n * application-defined value that uniquely identifies the message and its payload.\n */\n messageId?: string | number | Buffer;\n\n /**\n * Returns the underlying raw amqp message.\n */\n getRawAmqpMessage(): AmqpAnnotatedMessage;\n}\n\n/**\n * @internal\n */\nexport function isAmqpAnnotatedMessage(possible: unknown): possible is AmqpAnnotatedMessage {\n return (\n isObjectWithProperties(possible, [\"body\", \"bodyType\"]) &&\n !objectHasProperty(possible, \"getRawAmqpMessage\")\n );\n}\n\n/**\n * Converts any Date objects into a number representing date.getTime().\n * Recursively checks for any Date objects in arrays and objects.\n * @internal\n */\nfunction convertDatesToNumbers<T = unknown>(thing: T): T {\n // fast exit\n if (!isDefined(thing)) return thing;\n\n // When 'thing' is a Date, return the number representation\n if (\n typeof thing === \"object\" &&\n objectHasProperty(thing, \"getTime\") &&\n typeof thing.getTime === \"function\"\n ) {\n return thing.getTime();\n }\n\n /*\n Examples:\n [0, 'foo', new Date(), { nested: new Date()}]\n */\n if (Array.isArray(thing)) {\n return thing.map(convertDatesToNumbers) as unknown as T;\n }\n\n /*\n Examples:\n { foo: new Date(), children: { nested: new Date() }}\n */\n if (typeof thing === \"object\" && isDefined<object>(thing)) {\n const thingShallowCopy = { ...thing };\n for (const key of Object.keys(thingShallowCopy)) {\n (thingShallowCopy as any)[key] = convertDatesToNumbers((thingShallowCopy as any)[key]);\n }\n return thingShallowCopy;\n }\n\n return thing;\n}\n\n/**\n * @internal\n */\nexport interface PopulateIdempotentMessageAnnotationsParameters {\n isIdempotentPublishingEnabled: boolean;\n ownerLevel?: number;\n producerGroupId?: number;\n publishSequenceNumber?: number;\n}\n\n/**\n * Populates a rhea message with idempotent producer properties.\n * @internal\n */\nexport function populateIdempotentMessageAnnotations(\n rheaMessage: RheaMessage,\n {\n isIdempotentPublishingEnabled,\n ownerLevel,\n producerGroupId,\n publishSequenceNumber,\n }: PopulateIdempotentMessageAnnotationsParameters,\n): void {\n if (!isIdempotentPublishingEnabled) {\n return;\n }\n\n const messageAnnotations = rheaMessage.message_annotations || {};\n if (!rheaMessage.message_annotations) {\n rheaMessage.message_annotations = messageAnnotations;\n }\n\n if (isDefined(ownerLevel)) {\n messageAnnotations[idempotentProducerAmqpPropertyNames.epoch] = types.wrap_short(ownerLevel);\n }\n if (isDefined(producerGroupId)) {\n messageAnnotations[idempotentProducerAmqpPropertyNames.producerId] =\n types.wrap_long(producerGroupId);\n }\n if (isDefined(publishSequenceNumber)) {\n messageAnnotations[idempotentProducerAmqpPropertyNames.producerSequenceNumber] =\n types.wrap_int(publishSequenceNumber);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventDataAdapter.js","sourceRoot":"","sources":["../../src/eventDataAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAqElC;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAAqC,EAAE;IAEvC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAkB,EAAE,EAAE;YACvD,uCACK,MAAM,KACT,IAAI;gBACJ,WAAW,IACX;QACJ,CAAC;QACD,OAAO,EAAE,CAAC,OAAkB,EAAkB,EAAE;YAC9C,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;YACtC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;YAC3D,CAAC;YACD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAClE,CAAC;YACD,OAAO;gBACL;;;mBAGG;gBACH,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;gBAC5E,WAAW;aACZ,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EventData } from \"./eventData\";\n\n/**\n * A message with payload and content type fields\n *\n * This interface is hidden because it is already exported by `@azure/schema-registry-avro`\n *\n * @hidden\n */\nexport interface MessageContent {\n /**\n * The message's binary data\n */\n data: Uint8Array;\n /**\n * The message's content type\n */\n contentType: string;\n}\n\n/**\n * A message adapter interface that specifies methods for producing and consuming\n * messages with payloads and content type fields.\n *\n * This interface is hidden because it is already exported by `@azure/schema-registry-avro`\n *\n * @hidden\n */\nexport interface MessageAdapter<MessageT> {\n /**\n * defines how to create a message from a payload and a content type\n */\n produce: (MessageContent: MessageContent) => MessageT;\n /**\n * defines how to access the payload and the content type of a message\n */\n consume: (message: MessageT) => MessageContent;\n}\n\n// This type should always be equivalent to Omit<Omit<EventData, \"body\">, \"contentType\">\n/**\n * Parameters to the `createEventDataAdapter` function that creates an event data adapter.\n */\nexport interface EventDataAdapterParameters {\n /**\n * The correlation identifier that allows an\n * application to specify a context for the message for the purposes of correlation, for example\n * reflecting the MessageId of a message that is being replied to.\n */\n correlationId?: string | number | Buffer;\n\n /**\n * The message identifier is an\n * application-defined value that uniquely identifies the message and its payload.\n *\n * Note: Numbers that are not whole integers are not allowed.\n */\n messageId?: string | number | Buffer;\n\n /**\n * Set of key value pairs that can be used to set properties specific to user application.\n */\n properties?: {\n [key: string]: any;\n };\n}\n\n/**\n * A function that constructs an event data adapter. That adapter can be used\n * with `@azure/schema-registry-avro` to encode and decode body in event data.\n *\n * @param params - parameters to create the event data\n * @returns An event data adapter that can produce and consume event data\n */\nexport function createEventDataAdapter(\n params: EventDataAdapterParameters = {},\n): MessageAdapter<EventData> {\n return {\n produce: ({ data: body, contentType }: MessageContent) => {\n return {\n ...params,\n body,\n contentType,\n };\n },\n consume: (message: EventData): MessageContent => {\n const { body, contentType } = message;\n if (body === undefined) {\n throw new Error(\"Expected the body field to be defined\");\n }\n if (contentType === undefined) {\n throw new Error(\"Expected the contentType field to be defined\");\n }\n return {\n /**\n * If the raw response was parsed as JSON, we need to convert it to a Uint8Array,\n * otherwise, leave the payload as is.\n */\n data: typeof body === \"object\" ? Uint8Array.from(Object.values(body)) : body,\n contentType,\n };\n },\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventDataBatch.js","sourceRoot":"","sources":["../../src/eventDataBatch.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAa,oCAAoC,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;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CAAC;YAED,2EAA2E;YAC3E,uCAAuC;YACvC,WAAW,IAAI,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC;QACxE,CAAC;QAED,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC;QAC1C,MAAM,eAAe,GACnB,WAAW,IAAI,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,CAAC;QACpF,WAAW,IAAI,WAAW,GAAG,eAAe,CAAC;QAE7C,kEAAkE;QAClE,mCAAmC;QACnC,IAAI,WAAW,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,kEAAkE;QAClE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3C,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { EventData, populateIdempotentMessageAnnotations, toRheaMessage } from \"./eventData\";\nimport { ConnectionContext } from \"./connectionContext\";\nimport { MessageAnnotations, message, Message as RheaMessage } from \"rhea-promise\";\nimport { isDefined, isObjectWithProperties } from \"@azure/core-util\";\nimport { OperationTracingOptions, TracingContext } from \"@azure/core-tracing\";\nimport { instrumentEventData } from \"./diagnostics/instrumentEventData\";\nimport { throwTypeErrorIfParameterMissing } from \"./util/error\";\nimport { PartitionPublishingProperties } from \"./models/private\";\n\n/**\n * The amount of bytes to reserve as overhead for a small message.\n */\nconst smallMessageOverhead = 5;\n/**\n * The amount of bytes to reserve as overhead for a large message.\n */\nconst largeMessageOverhead = 8;\n/**\n * The maximum number of bytes that a message may be to be considered small.\n */\nconst smallMessageMaxBytes = 255;\n\n/**\n * Checks if the provided eventDataBatch is an instance of `EventDataBatch`.\n * @param eventDataBatch - The instance of `EventDataBatch` to verify.\n * @internal\n */\nexport function isEventDataBatch(eventDataBatch: unknown): eventDataBatch is EventDataBatch {\n return (\n isObjectWithProperties(eventDataBatch, [\"count\", \"sizeInBytes\", \"tryAdd\"]) &&\n typeof eventDataBatch.tryAdd === \"function\" &&\n typeof eventDataBatch.count === \"number\" &&\n typeof eventDataBatch.sizeInBytes === \"number\"\n );\n}\n\n/**\n * Options to configure the behavior of the `tryAdd` method on the `EventDataBatch` class.\n */\nexport interface TryAddOptions {\n /**\n * The options to use when creating Spans for tracing.\n */\n tracingOptions?: OperationTracingOptions;\n}\n\n/**\n * An interface representing a batch of events which can be used to send events to Event Hub.\n *\n * To create the batch, use the `createBatch()` method on the `EventHubProducerClient`.\n * To send the batch, use the `sendBatch()` method on the same client.\n * To fill the batch, use the `tryAdd()` method on the batch itself.\n *\n */\nexport interface EventDataBatch {\n /**\n * A value that is hashed and used by the Azure Event Hubs service to determine the partition to\n * which the events are sent. Use the `createBatch()` method on the `EventHubProducerClient` to\n * set the partitionKey.\n * @readonly\n * @internal\n */\n readonly partitionKey?: string;\n\n /**\n * Id of the partition to which the batch of events are sent. Use the `createBatch()` method on\n * the `EventHubProducerClient` to set the partitionId.\n * @readonly\n * @internal\n */\n readonly partitionId?: string;\n\n /**\n * Size of the batch in bytes after the events added to it have been encoded into a single AMQP\n * message.\n * @readonly\n */\n readonly sizeInBytes: number;\n\n /**\n * Number of events added to the batch.\n * @readonly\n */\n readonly count: number;\n\n /**\n * The maximum size of the batch, in bytes. The `tryAdd` function on the batch will return `false`\n * if the event being added causes the size of the batch to exceed this limit. Use the `createBatch()` method on\n * the `EventHubProducerClient` to set the maxSizeInBytes.\n * @readonly\n */\n readonly maxSizeInBytes: number;\n\n /**\n * Adds an event to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next event.\n *\n * @param eventData - An individual event data object or AmqpAnnotatedMessage.\n * @returns A boolean value indicating if the event data has been added to the batch or not.\n */\n tryAdd(eventData: EventData | AmqpAnnotatedMessage, options?: TryAddOptions): boolean;\n}\n\n/**\n * An internal class representing a batch of events which can be used to send events to Event Hub.\n *\n * @internal\n */\nexport class EventDataBatchImpl implements EventDataBatch {\n /**\n * Describes the amqp connection context for the Client.\n */\n private _context: ConnectionContext;\n /**\n * The Id of the partition to which the batch is expected to be sent to.\n * Specifying this will throw an error if the batch was created using a `partitionKey`.\n */\n private _partitionId?: string;\n /**\n * A value that is hashed to produce a partition assignment.\n * It guarantees that messages with the same partitionKey end up in the same partition.\n * Specifying this will throw an error if the batch was created using a `partitionId`.\n */\n private _partitionKey?: string;\n /**\n * The maximum size allowed for the batch.\n */\n private _maxSizeInBytes: number;\n /**\n * Current size of the batch in bytes.\n */\n private _sizeInBytes: number;\n /**\n * Encoded amqp messages.\n */\n private _encodedMessages: Buffer[] = [];\n /**\n * Number of events in the batch.\n */\n private _count: number;\n /**\n * List of 'message' span contexts.\n */\n private _spanContexts: TracingContext[] = [];\n /**\n * The message annotations to apply on the batch envelope.\n * This will reflect the message annotations on the first event\n * that was added to the batch.\n * A common annotation is the partition key.\n */\n private _batchAnnotations?: MessageAnnotations;\n /**\n * Indicates that the batch should be treated as idempotent.\n */\n private _isIdempotent: boolean;\n /**\n * The sequence number assigned to the first event in the batch while\n * the batch is being sent to the service.\n */\n private _pendingStartingSequenceNumber?: number;\n /**\n * The publishing sequence number assigned to the first event in the batch at the time\n * the batch was successfully published.\n * If the producer was not configured to apply sequence numbering or if the batch\n * has not yet been successfully published, the value will be `undefined`.\n */\n private _startingPublishSequenceNumber?: number;\n\n /**\n * EventDataBatch should not be constructed using `new EventDataBatch()`\n * Use the `createBatch()` method on your `EventHubProducer` instead.\n * @internal\n */\n constructor(\n context: ConnectionContext,\n maxSizeInBytes: number,\n isIdempotent: boolean,\n partitionKey?: string,\n partitionId?: string,\n ) {\n this._context = context;\n this._maxSizeInBytes = maxSizeInBytes;\n this._isIdempotent = isIdempotent;\n this._partitionKey = isDefined(partitionKey) ? String(partitionKey) : partitionKey;\n this._partitionId = isDefined(partitionId) ? String(partitionId) : partitionId;\n this._sizeInBytes = 0;\n this._count = 0;\n }\n\n /**\n * The maximum size of the batch, in bytes.\n * @readonly\n */\n get maxSizeInBytes(): number {\n return this._maxSizeInBytes;\n }\n\n /**\n * The partitionKey set during `EventDataBatch` creation. This value is hashed to\n * produce a partition assignment when the producer is created without a `partitionId`\n * @readonly\n */\n get partitionKey(): string | undefined {\n return this._partitionKey;\n }\n\n /**\n * The partitionId set during `EventDataBatch` creation.\n * If this value is set then partitionKey can not be set.\n * @readonly\n */\n get partitionId(): string | undefined {\n return this._partitionId;\n }\n\n /**\n * Size of the `EventDataBatch` instance after the events added to it have been\n * encoded into a single AMQP message.\n * @readonly\n */\n get sizeInBytes(): number {\n return this._sizeInBytes;\n }\n\n /**\n * Number of events in the `EventDataBatch` instance.\n * @readonly\n */\n get count(): number {\n return this._count;\n }\n\n /**\n * The publishing sequence number assigned to the first event in the batch at the time\n * the batch was successfully published.\n * If the producer was not configured to apply sequence numbering or if the batch\n * has not yet been successfully published, the value will be `undefined`.\n */\n get startingPublishedSequenceNumber(): number | undefined {\n return this._startingPublishSequenceNumber;\n }\n\n /**\n * Gets the \"message\" span contexts that were created when adding events to the batch.\n * @internal\n */\n get _messageSpanContexts(): TracingContext[] {\n return this._spanContexts;\n }\n\n /**\n * Generates an AMQP message that contains the provided encoded events and annotations.\n * @param encodedEvents - The already encoded events to include in the AMQP batch.\n * @param annotations - The message annotations to set on the batch.\n * @param publishingProps - Idempotent publishing properties used to decorate the events in the batch while sending.\n */\n private _generateBatch(\n encodedEvents: Buffer[],\n annotations: MessageAnnotations | undefined,\n publishingProps?: PartitionPublishingProperties,\n ): Buffer {\n if (this._isIdempotent && publishingProps) {\n // We need to decode the encoded events, add the idempotent annotations, and re-encode them.\n // We can't lazily encode the events because we rely on `message.encode` to capture the\n // byte length of anything not in `event.body`.\n // Events can't be decorated ahead of time because the publishing properties aren't known\n // until the events are being sent to the service.\n const decodedEvents = encodedEvents.map(message.decode) as unknown as RheaMessage[];\n const decoratedEvents = this._decorateRheaMessagesWithPublishingProps(\n decodedEvents,\n publishingProps,\n );\n encodedEvents = decoratedEvents.map(message.encode);\n }\n\n const batchEnvelope: RheaMessage = {\n body: message.data_sections(encodedEvents),\n };\n if (annotations) {\n batchEnvelope.message_annotations = annotations;\n }\n return message.encode(batchEnvelope);\n }\n\n /**\n * Uses the publishingProps to add idempotent properties as message annotations to rhea messages.\n */\n private _decorateRheaMessagesWithPublishingProps(\n events: RheaMessage[],\n publishingProps: PartitionPublishingProperties,\n ): RheaMessage[] {\n if (!this._isIdempotent) {\n return events;\n }\n\n const { lastPublishedSequenceNumber = 0, ownerLevel, producerGroupId } = publishingProps;\n const startingSequenceNumber = lastPublishedSequenceNumber + 1;\n for (let i = 0; i < events.length; i++) {\n const event = events[i];\n populateIdempotentMessageAnnotations(event, {\n isIdempotentPublishingEnabled: this._isIdempotent,\n ownerLevel,\n producerGroupId,\n publishSequenceNumber: startingSequenceNumber + i,\n });\n }\n\n this._pendingStartingSequenceNumber = startingSequenceNumber;\n return events;\n }\n\n /**\n * Annotates a rhea message with placeholder idempotent properties if the batch is idempotent.\n * This is necessary so that we can accurately calculate the size of the batch while adding events.\n * Placeholder values are used because real values won't be known until we attempt to send the batch.\n */\n private _decorateRheaMessageWithPlaceholderIdempotencyProps(event: RheaMessage): RheaMessage {\n if (!this._isIdempotent) {\n return event;\n }\n\n if (!event.message_annotations) {\n event.message_annotations = {};\n }\n\n // Set placeholder values for these annotations.\n populateIdempotentMessageAnnotations(event, {\n isIdempotentPublishingEnabled: this._isIdempotent,\n ownerLevel: 0,\n publishSequenceNumber: 0,\n producerGroupId: 0,\n });\n\n return event;\n }\n\n /**\n * Generates the single AMQP message which is the result of encoding all the events\n * added into the `EventDataBatch` instance.\n *\n * This is not meant for the user to use directly.\n *\n * When the `EventDataBatch` instance is passed to the `send()` method on the `EventHubProducer`,\n * this single batched AMQP message is what gets sent over the wire to the service.\n * @readonly\n */\n _generateMessage(publishingProps?: PartitionPublishingProperties): Buffer {\n return this._generateBatch(this._encodedMessages, this._batchAnnotations, publishingProps);\n }\n\n /**\n * Sets startingPublishSequenceNumber to the pending publish sequence number.\n */\n _commitPublish(): void {\n this._startingPublishSequenceNumber = this._pendingStartingSequenceNumber;\n }\n\n /**\n * Tries to add an event data to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next event.\n *\n * @param eventData - An individual event data object.\n * @returns A boolean value indicating if the event data has been added to the batch or not.\n */\n public tryAdd(eventData: EventData | AmqpAnnotatedMessage, options: TryAddOptions = {}): boolean {\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"tryAdd\", \"eventData\", eventData);\n\n const { entityPath, host } = this._context.config;\n const { event: instrumentedEvent, spanContext } = instrumentEventData(\n eventData,\n options,\n entityPath,\n host,\n );\n\n // Convert EventData to RheaMessage.\n const amqpMessage = toRheaMessage(instrumentedEvent, this._partitionKey);\n const originalAnnotations = amqpMessage.message_annotations && {\n ...amqpMessage.message_annotations,\n };\n this._decorateRheaMessageWithPlaceholderIdempotencyProps(amqpMessage);\n const encodedMessage = message.encode(amqpMessage);\n\n let currentSize = this._sizeInBytes;\n // The first time an event is added, we need to calculate\n // the overhead of creating an AMQP batch, including the\n // message_annotations that are taken from the 1st message.\n if (this.count === 0) {\n if (originalAnnotations) {\n this._batchAnnotations = originalAnnotations;\n }\n\n // Figure out the overhead of creating a batch by generating an empty batch\n // with the expected batch annotations.\n currentSize += this._generateBatch([], this._batchAnnotations).length;\n }\n\n const messageSize = encodedMessage.length;\n const messageOverhead =\n messageSize <= smallMessageMaxBytes ? smallMessageOverhead : largeMessageOverhead;\n currentSize += messageSize + messageOverhead;\n\n // Check if the size of the batch exceeds the maximum allowed size\n // once we add the new event to it.\n if (currentSize > this._maxSizeInBytes) {\n return false;\n }\n\n // The event will fit in the batch, so it is now safe to store it.\n this._encodedMessages.push(encodedMessage);\n if (spanContext) {\n this._spanContexts.push(spanContext);\n }\n\n this._sizeInBytes = currentSize;\n this._count++;\n return true;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventHubBufferedProducerClient.js","sourceRoot":"","sources":["../../src/eventHubBufferedProducerClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAWlE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAwB,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA4F7C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,8BAA8B;IAgDzC;;;OAGG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,IAAI,uBAAuB;QACzB,OAAO,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC;IAChD,CAAC;IAiED,YACE,0CAAkD,EAClD,sBAAsE,EACtE,oBAIyC,EACzC,QAAgD;;QAvIlD;;;WAGG;QACK,qBAAgB,GAAG,IAAI,eAAe,EAAE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MAAM,KAAK,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAC7D,MAAM,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;YAChD,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC;YACzC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,4BAA4B;QACxC,MAAM,CAAC,OAAO,CAAC,uEAAuE,CAAC,CAAC;QACxF,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YAChE,MAAM,KAAK,CAAO,IAAI,CAAC,6BAA6B,CAAC,CAAC;YACtD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACpB,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EventData } from \"./eventData\";\nimport { EventHubProducerClient } from \"./eventHubProducerClient\";\nimport { OperationOptions } from \"./util/operationOptions\";\nimport {\n EventHubClientOptions,\n GetEventHubPropertiesOptions,\n GetPartitionIdsOptions,\n GetPartitionPropertiesOptions,\n SendBatchOptions,\n} from \"./models/public\";\nimport { EventHubProperties, PartitionProperties } from \"./managementClient\";\nimport { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isDefined } from \"@azure/core-util\";\nimport { isCredential } from \"./util/typeGuards\";\nimport { AbortController } from \"@azure/abort-controller\";\nimport { AmqpAnnotatedMessage, delay } from \"@azure/core-amqp\";\nimport { BatchingPartitionChannel } from \"./batchingPartitionChannel\";\nimport { PartitionAssigner } from \"./impl/partitionAssigner\";\nimport { logger } from \"./logger\";\nimport { getRandomName } from \"./util/utils\";\n\n/**\n * Contains the events that were successfully sent to the Event Hub,\n * and the partition they were assigned to.\n */\nexport interface OnSendEventsSuccessContext {\n /**\n * The partition each event was assigned.\n */\n partitionId: string;\n /**\n * The array of {@link EventData} and/or `AmqpAnnotatedMessage` that were successfully sent to the Event Hub.\n */\n events: Array<EventData | AmqpAnnotatedMessage>;\n}\n\n/**\n * Contains the events that were not successfully sent to the Event Hub,\n * the partition they were assigned to, and the error that was encountered while sending.\n */\nexport interface OnSendEventsErrorContext {\n /**\n * The partition each event was assigned.\n */\n partitionId: string;\n /**\n * The array of {@link EventData} and/or `AmqpAnnotatedMessage` that were not successfully sent to the Event Hub.\n */\n events: Array<EventData | AmqpAnnotatedMessage>;\n /**\n * The error that occurred when sending the associated events to the Event Hub.\n */\n error: Error;\n}\n\n/**\n * Describes the options that can be provided while creating the `EventHubBufferedProducerClient`.\n */\nexport interface EventHubBufferedProducerClientOptions extends EventHubClientOptions {\n /**\n * The total number of events that can be buffered for publishing at a given time for a given partition.\n *\n * Default: 1500\n */\n maxEventBufferLengthPerPartition?: number;\n /**\n * The amount of time to wait for a new event to be enqueued in the buffer before publishing a partially full batch.\n *\n * Default: 1 second.\n */\n maxWaitTimeInMs?: number;\n /**\n * The handler to call once a batch has successfully published.\n */\n onSendEventsSuccessHandler?: (ctx: OnSendEventsSuccessContext) => void;\n /**\n * The handler to call when a batch fails to publish.\n */\n onSendEventsErrorHandler: (ctx: OnSendEventsErrorContext) => void;\n /**\n * Indicates whether or not the EventHubProducerClient should enable idempotent publishing to Event Hub partitions.\n * If enabled, the producer will only be able to publish directly to partitions;\n * it will not be able to publish to the Event Hubs gateway for automatic partition routing\n * nor will it be able to use a partition key.\n * Default: false\n */\n enableIdempotentRetries?: boolean;\n}\n\n/**\n * Options to configure the `flush` method on the `EventHubBufferedProducerClient`.\n */\nexport interface BufferedFlushOptions extends OperationOptions {}\n\n/**\n * Options to configure the `close` method on the `EventHubBufferedProducerClient`.\n */\nexport interface BufferedCloseOptions extends OperationOptions {\n /**\n * When `true`, all buffered events that are pending should be sent before closing.\n * When `false`, abandon all buffered events and close immediately.\n * Defaults to `true`.\n */\n flush?: boolean;\n}\n\n/**\n * Options to configure the `enqueueEvents` method on the `EventHubBufferedProducerClient`.\n */\nexport interface EnqueueEventOptions extends SendBatchOptions {}\n\n/**\n * The `EventHubBufferedProducerClient`is used to publish events to a specific Event Hub.\n *\n * The `EventHubBufferedProducerClient` does not publish events immediately.\n * Instead, events are buffered so they can be efficiently batched and published\n * when the batch is full or the `maxWaitTimeInMs` has elapsed with no new events\n * enqueued.\n *\n * Depending on the options specified when events are enqueued, they may be\n * automatically assigned to a partition, grouped according to the specified partition key,\n * or assigned a specifically requested partition.\n *\n * This model is intended to shift the burden of batch management from callers, at the cost of\n * non-deterministic timing, for when events will be published. There are additional trade-offs\n * to consider, as well:\n * - If the application crashes, events in the buffer will not have been published. To prevent\n * data loss, callers are encouraged to track publishing progress using the\n * `onSendEventsSuccessHandler` and `onSendEventsErrorHandler` handlers.\n * - Events specifying a partition key may be assigned a different partition than those using\n * the same key with other producers.\n * - In the unlikely event that a partition becomes temporarily unavailable, the\n * `EventHubBufferedProducerClient` may take longer to recover than other producers.\n *\n * In scenarios where it is important to have events published immediately with a deterministic\n * outcome, ensure that partition keys are assigned to a partition consistent with other\n * publishers, or where maximizing availability is a requirement, using the\n * `EventHubProducerClient` is recommended.\n */\nexport class EventHubBufferedProducerClient {\n /**\n * Controls the `abortSignal` passed to each `BatchingPartitionChannel`.\n * Used to signal when a channel should stop waiting for events.\n */\n private _abortController = new AbortController();\n\n /**\n * Indicates whether the client has been explicitly closed.\n */\n private _isClosed: boolean = false;\n\n /**\n * Handles assigning partitions.\n */\n private _partitionAssigner = new PartitionAssigner();\n\n /**\n * The known partitionIds that will be used when assigning events to partitions.\n */\n private _partitionIds: string[] = [];\n\n /**\n * The EventHubProducerClient to use when creating and sending batches to the Event Hub.\n */\n private _producer: EventHubProducerClient;\n\n /**\n * Mapping of partitionIds to `BatchingPartitionChannels`.\n * Each `BatchingPartitionChannel` handles buffering events and backpressure independently.\n */\n private _partitionChannels = new Map<string, BatchingPartitionChannel>();\n\n /**\n * The options passed by the user when creating the EventHubBufferedProducerClient instance.\n */\n private _clientOptions: EventHubBufferedProducerClientOptions;\n\n /**\n * The interval at which the background management operation should run.\n */\n private _backgroundManagementInterval = 10000; // 10 seconds\n\n /**\n * Indicates whether the background management loop is running.\n */\n private _isBackgroundManagementRunning = false;\n\n /**\n * @readonly\n * The name of the Event Hub instance for which this client is created.\n */\n get eventHubName(): string {\n return this._producer.eventHubName;\n }\n\n /**\n * @readonly\n * The fully qualified namespace of the Event Hub instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n get fullyQualifiedNamespace(): string {\n return this._producer.fullyQualifiedNamespace;\n }\n\n /**\n * The name used to identify this EventHubBufferedProducerClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public readonly identifier: string;\n\n /**\n * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(connectionString: string, options: EventHubBufferedProducerClientOptions);\n /**\n * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n connectionString: string,\n eventHubName: string,\n options: EventHubBufferedProducerClientOptions,\n );\n /**\n * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See @azure/identity for creating credentials that support AAD auth.\n * Use the `AzureNamedKeyCredential` from @azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from @azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options: EventHubBufferedProducerClientOptions,\n );\n constructor(\n fullyQualifiedNamespaceOrConnectionString1: string,\n eventHubNameOrOptions2: string | EventHubBufferedProducerClientOptions,\n credentialOrOptions3?:\n | TokenCredential\n | NamedKeyCredential\n | SASCredential\n | EventHubBufferedProducerClientOptions,\n options4?: EventHubBufferedProducerClientOptions,\n ) {\n if (typeof eventHubNameOrOptions2 !== \"string\") {\n this.identifier = eventHubNameOrOptions2.identifier ?? getRandomName();\n this._producer = new EventHubProducerClient(fullyQualifiedNamespaceOrConnectionString1, {\n ...eventHubNameOrOptions2,\n identifier: this.identifier,\n });\n this._clientOptions = { ...eventHubNameOrOptions2 };\n } else if (!isCredential(credentialOrOptions3)) {\n this.identifier = credentialOrOptions3?.identifier ?? getRandomName();\n this._producer = new EventHubProducerClient(\n fullyQualifiedNamespaceOrConnectionString1,\n eventHubNameOrOptions2,\n { ...credentialOrOptions3, identifier: this.identifier },\n );\n this._clientOptions = { ...credentialOrOptions3! };\n } else {\n this.identifier = options4?.identifier ?? getRandomName();\n this._producer = new EventHubProducerClient(\n fullyQualifiedNamespaceOrConnectionString1,\n eventHubNameOrOptions2,\n credentialOrOptions3,\n { ...options4, identifier: this.identifier },\n );\n this._clientOptions = { ...options4! };\n }\n // setting internal idempotent publishing option on the standard producer.\n (this._producer as any)._enableIdempotentRetries = this._clientOptions.enableIdempotentRetries;\n }\n\n /**\n * Closes the AMQP connection to the Event Hub instance,\n * returning a promise that will be resolved when disconnection is completed.\n *\n * This will wait for enqueued events to be flushed to the service before closing\n * the connection.\n * To close without flushing, set the `flush` option to `false`.\n *\n * @param options - The set of options to apply to the operation call.\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n async close(options: BufferedCloseOptions = {}): Promise<void> {\n logger.verbose(\"closing buffered producer client...\");\n if (!isDefined(options.flush) || options.flush === true) {\n await this.flush(options);\n }\n // Calling abort signals to the BatchingPartitionChannels that they\n // should stop reading/sending events, and to the background management\n // loop that it should stop periodic partition id updates.\n this._abortController.abort();\n await this._producer.close();\n this._isClosed = true;\n }\n\n /**\n * Enqueues an event into the buffer to be published to the Event Hub.\n * If there is no capacity in the buffer when this method is invoked,\n * it will wait for space to become available and ensure that the event\n * has been enqueued.\n *\n * When this call returns, the event has been accepted into the buffer,\n * but it may not have been published yet.\n * Publishing will take place at a nondeterministic point in the future as the buffer is processed.\n *\n * @param events - An {@link EventData} or `AmqpAnnotatedMessage`.\n * @param options - A set of options that can be specified to influence the way in which\n * the event is sent to the associated Event Hub.\n * - `abortSignal` : A signal used to cancel the enqueueEvent operation.\n * - `partitionId` : The partition this set of events will be sent to. If set, `partitionKey` can not be set.\n * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.\n * @returns The total number of events that are currently buffered and waiting to be published, across all partitions.\n */\n async enqueueEvent(\n event: EventData | AmqpAnnotatedMessage,\n options: EnqueueEventOptions = {},\n ): Promise<number> {\n if (this._isClosed) {\n throw new Error(\n `This EventHubBufferedProducerClient has already been closed. Create a new client to enqueue events.`,\n );\n }\n\n if (!this._partitionIds.length) {\n await this._updatePartitionIds();\n }\n if (!this._isBackgroundManagementRunning) {\n this._startPartitionIdsUpdateLoop().catch((e) => {\n logger.error(\n `The following error occured during batch creation or sending: ${JSON.stringify(\n e,\n undefined,\n \" \",\n )}`,\n );\n });\n this._isBackgroundManagementRunning = true;\n }\n\n const partitionId = this._partitionAssigner.assignPartition({\n partitionId: options.partitionId,\n partitionKey: options.partitionKey,\n });\n\n const partitionChannel = this._getPartitionChannel(partitionId);\n await partitionChannel.enqueueEvent(event);\n return this._getTotalBufferedEventsCount();\n }\n\n /**\n * Enqueues events into the buffer to be published to the Event Hub.\n * If there is no capacity in the buffer when this method is invoked,\n * it will wait for space to become available and ensure that the events\n * have been enqueued.\n *\n * When this call returns, the events have been accepted into the buffer,\n * but it may not have been published yet.\n * Publishing will take place at a nondeterministic point in the future as the buffer is processed.\n *\n * @param events - An array of {@link EventData} or `AmqpAnnotatedMessage`.\n * @param options - A set of options that can be specified to influence the way in which\n * events are sent to the associated Event Hub.\n * - `abortSignal` : A signal used to cancel the enqueueEvents operation.\n * - `partitionId` : The partition this set of events will be sent to. If set, `partitionKey` can not be set.\n * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.\n * @returns The total number of events that are currently buffered and waiting to be published, across all partitions.\n */\n async enqueueEvents(\n events: EventData[] | AmqpAnnotatedMessage[],\n options: EnqueueEventOptions = {},\n ): Promise<number> {\n for (const event of events) {\n await this.enqueueEvent(event, options);\n }\n\n return this._getTotalBufferedEventsCount();\n }\n\n /**\n * Attempts to publish all events in the buffer immediately.\n * This may result in multiple batches being published,\n * the outcome of each of which will be individually reported by\n * the `onSendEventsSuccessHandler` and `onSendEventsErrorHandler` handlers.\n *\n * @param options - The set of options to apply to the operation call.\n */\n async flush(options: BufferedFlushOptions = {}): Promise<void> {\n await Promise.all(\n Array.from(this._partitionChannels.values()).map((channel) => channel.flush(options)),\n );\n }\n\n /**\n * Provides the Event Hub runtime information.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the Event Hub instance.\n * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise<EventHubProperties> {\n return this._producer.getEventHubProperties(options);\n }\n\n /**\n * Provides the id for each partition associated with the Event Hub.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with an Array of strings representing the id for\n * each partition associated with the Event Hub.\n * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionIds(options: GetPartitionIdsOptions = {}): Promise<Array<string>> {\n return this._producer.getPartitionIds(options);\n }\n\n /**\n * Provides information about the state of the specified partition.\n * @param partitionId - The id of the partition for which information is required.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the state of the partition .\n * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionProperties(\n partitionId: string,\n options: GetPartitionPropertiesOptions = {},\n ): Promise<PartitionProperties> {\n return this._producer.getPartitionProperties(partitionId, options);\n }\n\n /**\n * Gets the `BatchingPartitionChannel` associated with the partitionId.\n *\n * If one does not exist, it is created.\n */\n private _getPartitionChannel(partitionId: string): BatchingPartitionChannel {\n const partitionChannel =\n this._partitionChannels.get(partitionId) ??\n new BatchingPartitionChannel({\n loopAbortSignal: this._abortController.signal,\n maxBufferSize: this._clientOptions.maxEventBufferLengthPerPartition || 1500,\n maxWaitTimeInMs: this._clientOptions.maxWaitTimeInMs || 1000,\n onSendEventsErrorHandler: this._clientOptions.onSendEventsErrorHandler,\n onSendEventsSuccessHandler: this._clientOptions.onSendEventsSuccessHandler,\n partitionId,\n producer: this._producer,\n });\n this._partitionChannels.set(partitionId, partitionChannel);\n return partitionChannel;\n }\n\n /**\n * Returns the total number of buffered events across all partitions.\n */\n private _getTotalBufferedEventsCount(): number {\n let total = 0;\n for (const [_, channel] of this._partitionChannels) {\n total += channel.getCurrentBufferedCount();\n }\n\n return total;\n }\n\n private async _updatePartitionIds(): Promise<void> {\n logger.verbose(\"Checking for partition Id updates...\");\n const queriedPartitionIds = await this.getPartitionIds();\n\n if (this._partitionIds.length !== queriedPartitionIds.length) {\n logger.verbose(\"Applying partition Id updates\");\n this._partitionIds = queriedPartitionIds;\n this._partitionAssigner.setPartitionIds(this._partitionIds);\n }\n }\n\n private async _startPartitionIdsUpdateLoop(): Promise<void> {\n logger.verbose(\"Starting a background loop to check and apply partition id updates...\");\n while (!this._abortController.signal.aborted && !this._isClosed) {\n await delay<void>(this._backgroundManagementInterval);\n if (!this._isClosed) {\n await this._updatePartitionIds();\n }\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventHubConsumerClient.js","sourceRoot":"","sources":["../../src/eventHubConsumerClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAmB,cAAc,EAA6B,MAAM,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ACnD,OAAO,eAAe,CAAC,gBAAgB,KAAK,UAAU,CACvD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,2BAA2B,CAClC,QAAyC;IAEzC,OAAO,OAAQ,QAAsC,CAAC,aAAa,KAAK,UAAU,CAAC;AACrF,CAAC;AAED,SAAS,aAAa,CACpB,OAAqC,EACrC,wBAAiC;IAEjC,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,UAAU,CAAC;IAC5B,CAAC;IAED,IAAI,wBAAwB,EAAE,CAAC;QAC7B,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CheckpointStore, EventProcessor, FullEventProcessorOptions } from \"./eventProcessor\";\nimport { ConnectionContext, createConnectionContext } from \"./connectionContext\";\nimport {\n EventHubConsumerClientOptions,\n GetEventHubPropertiesOptions,\n GetPartitionIdsOptions,\n GetPartitionPropertiesOptions,\n LoadBalancingOptions,\n} from \"./models/public\";\nimport { EventHubProperties, PartitionProperties } from \"./managementClient\";\nimport { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport {\n SubscribeOptions,\n Subscription,\n SubscriptionEventHandlers,\n} from \"./eventHubConsumerClientModels\";\nimport { BalancedLoadBalancingStrategy } from \"./loadBalancerStrategies/balancedStrategy\";\nimport { Constants } from \"@azure/core-amqp\";\nimport { GreedyLoadBalancingStrategy } from \"./loadBalancerStrategies/greedyStrategy\";\nimport { InMemoryCheckpointStore } from \"./inMemoryCheckpointStore\";\nimport { LoadBalancingStrategy } from \"./loadBalancerStrategies/loadBalancingStrategy\";\nimport { PartitionGate } from \"./impl/partitionGate\";\nimport { UnbalancedLoadBalancingStrategy } from \"./loadBalancerStrategies/unbalancedStrategy\";\nimport { isCredential } from \"./util/typeGuards\";\nimport { logger } from \"./logger\";\nimport { validateEventPositions } from \"./eventPosition\";\nimport { getRandomName } from \"./util/utils\";\n\nconst defaultConsumerClientOptions: Required<\n Pick<FullEventProcessorOptions, \"maxWaitTimeInSeconds\" | \"maxBatchSize\">\n> = {\n // to support our current \"process single event only\" workflow we'll also purposefully\n // only request a single event at a time.\n maxBatchSize: 1,\n maxWaitTimeInSeconds: 60,\n};\n\n/**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n *\n * There are multiple ways to create an `EventHubConsumerClient`\n * - Use the connection string from the SAS policy created for your Event Hub instance.\n * - Use the connection string from the SAS policy created for your Event Hub namespace,\n * and the name of the Event Hub instance\n * - Use the full namespace like `<yournamespace>.servicebus.windows.net`, and a credentials object.\n *\n * Optionally, you can also pass:\n * - An options bag to configure the retry policy or proxy settings.\n * - A checkpoint store that is used by the client to read checkpoints to determine the position from where it should\n * resume receiving events when your application gets restarted. The checkpoint store is also used by the client\n * to load balance multiple instances of your application.\n */\nexport class EventHubConsumerClient {\n /**\n * Describes the amqp connection context for the client.\n */\n private _context: ConnectionContext;\n /**\n * The options passed by the user when creating the EventHubClient instance.\n */\n private _clientOptions: EventHubConsumerClientOptions;\n private _partitionGate = new PartitionGate();\n\n /**\n * The Subscriptions that were spawned by calling `subscribe()`.\n * Subscriptions that have been stopped by the user will not\n * be present in this set.\n */\n private _subscriptions = new Set<Subscription>();\n\n /**\n * The name of the default consumer group in the Event Hubs service.\n */\n static defaultConsumerGroupName: string = Constants.defaultConsumerGroup;\n\n private _checkpointStore: CheckpointStore;\n private _userChoseCheckpointStore: boolean;\n\n /**\n * Options for configuring load balancing.\n */\n private readonly _loadBalancingOptions: Required<LoadBalancingOptions>;\n\n /**\n * @readonly\n * The name of the Event Hub instance for which this client is created.\n */\n get eventHubName(): string {\n return this._context.config.entityPath;\n }\n\n /**\n * @readonly\n * The fully qualified namespace of the Event Hub instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n get fullyQualifiedNamespace(): string {\n return this._context.config.host;\n }\n\n /**\n * The name used to identify this EventHubConsumerClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public readonly identifier: string;\n\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n connectionString: string,\n options?: EventHubConsumerClientOptions,\n ); // #1\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param checkpointStore - A checkpoint store that is used by the client to read checkpoints to determine\n * the position from where it should resume receiving events when your application gets restarted.\n * It is also used by the client to load balance multiple instances of your application.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n connectionString: string,\n checkpointStore: CheckpointStore,\n options?: EventHubConsumerClientOptions,\n ); // #1.1\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n connectionString: string,\n eventHubName: string,\n options?: EventHubConsumerClientOptions,\n ); // #2\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param checkpointStore - A checkpoint store that is used by the client to read checkpoints to determine\n * the position from where it should resume receiving events when your application gets restarted.\n * It is also used by the client to load balance multiple instances of your application.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n connectionString: string,\n eventHubName: string,\n checkpointStore: CheckpointStore,\n options?: EventHubConsumerClientOptions,\n ); // #2.1\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See @azure/identity for creating credentials that support AAD auth.\n * Use the `AzureNamedKeyCredential` from @azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from @azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options?: EventHubConsumerClientOptions,\n ); // #3\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See @azure/identity for creating credentials that support AAD auth.\n * Use the `AzureNamedKeyCredential` from @azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from @azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param checkpointStore - A checkpoint store that is used by the client to read checkpoints to determine\n * the position from where it should resume receiving events when your application gets restarted.\n * It is also used by the client to load balance multiple instances of your application.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n checkpointStore: CheckpointStore,\n options?: EventHubConsumerClientOptions,\n ); // #3.1\n constructor(\n private _consumerGroup: string,\n connectionStringOrFullyQualifiedNamespace2: string,\n checkpointStoreOrEventHubNameOrOptions3?:\n | CheckpointStore\n | EventHubConsumerClientOptions\n | string,\n checkpointStoreOrCredentialOrOptions4?:\n | CheckpointStore\n | EventHubConsumerClientOptions\n | TokenCredential\n | NamedKeyCredential\n | SASCredential,\n checkpointStoreOrOptions5?: CheckpointStore | EventHubConsumerClientOptions,\n options6?: EventHubConsumerClientOptions,\n ) {\n if (isCredential(checkpointStoreOrCredentialOrOptions4)) {\n // #3 or 3.1\n logger.info(\"Creating EventHubConsumerClient with TokenCredential.\");\n\n if (isCheckpointStore(checkpointStoreOrOptions5)) {\n // 3.1\n this._checkpointStore = checkpointStoreOrOptions5;\n this._userChoseCheckpointStore = true;\n this._clientOptions = options6 || {};\n } else {\n this._checkpointStore = new InMemoryCheckpointStore();\n this._userChoseCheckpointStore = false;\n this._clientOptions = checkpointStoreOrOptions5 || {};\n }\n\n this._context = createConnectionContext(\n connectionStringOrFullyQualifiedNamespace2,\n checkpointStoreOrEventHubNameOrOptions3 as string,\n checkpointStoreOrCredentialOrOptions4,\n this._clientOptions,\n );\n } else if (typeof checkpointStoreOrEventHubNameOrOptions3 === \"string\") {\n // #2 or 2.1\n logger.info(\"Creating EventHubConsumerClient with connection string and event hub name.\");\n\n if (isCheckpointStore(checkpointStoreOrCredentialOrOptions4)) {\n // 2.1\n this._checkpointStore = checkpointStoreOrCredentialOrOptions4;\n this._userChoseCheckpointStore = true;\n this._clientOptions = (checkpointStoreOrOptions5 as EventHubConsumerClientOptions) || {};\n } else {\n // 2\n this._checkpointStore = new InMemoryCheckpointStore();\n this._userChoseCheckpointStore = false;\n this._clientOptions = checkpointStoreOrCredentialOrOptions4 || {};\n }\n\n this._context = createConnectionContext(\n connectionStringOrFullyQualifiedNamespace2,\n checkpointStoreOrEventHubNameOrOptions3,\n this._clientOptions,\n );\n } else {\n // #1 or 1.1\n logger.info(\"Creating EventHubConsumerClient with connection string.\");\n\n if (isCheckpointStore(checkpointStoreOrEventHubNameOrOptions3)) {\n // 1.1\n this._checkpointStore = checkpointStoreOrEventHubNameOrOptions3;\n this._userChoseCheckpointStore = true;\n this._clientOptions =\n (checkpointStoreOrCredentialOrOptions4 as EventHubConsumerClientOptions) || {};\n } else {\n // 1\n this._checkpointStore = new InMemoryCheckpointStore();\n this._userChoseCheckpointStore = false;\n this._clientOptions =\n (checkpointStoreOrEventHubNameOrOptions3 as EventHubConsumerClientOptions) || {};\n }\n\n this._context = createConnectionContext(\n connectionStringOrFullyQualifiedNamespace2,\n this._clientOptions,\n );\n }\n this.identifier = this._clientOptions.identifier ?? getRandomName();\n this._loadBalancingOptions = {\n // default options\n strategy: \"balanced\",\n updateIntervalInMs: 10000,\n partitionOwnershipExpirationIntervalInMs: 60000,\n // options supplied by user\n ...this._clientOptions?.loadBalancingOptions,\n };\n }\n\n /**\n * Closes the AMQP connection to the Event Hub instance,\n * returning a promise that will be resolved when disconnection is completed.\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n async close(): Promise<void> {\n // Stop all the actively running subscriptions.\n const activeSubscriptions = Array.from(this._subscriptions);\n await Promise.all(\n activeSubscriptions.map((subscription) => {\n return subscription.close();\n }),\n );\n // Close the connection via the connection context.\n return this._context.close();\n }\n\n /**\n * Provides the id for each partition associated with the Event Hub.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with an Array of strings representing the id for\n * each partition associated with the Event Hub.\n * @throws Error if the underlying connection has been closed, create a new EventHubConsumerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionIds(options: GetPartitionIdsOptions = {}): Promise<Array<string>> {\n return this._context\n .managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n })\n .then((eventHubProperties) => {\n return eventHubProperties.partitionIds;\n });\n }\n\n /**\n * Provides information about the state of the specified partition.\n * @param partitionId - The id of the partition for which information is required.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the state of the partition .\n * @throws Error if the underlying connection has been closed, create a new EventHubConsumerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionProperties(\n partitionId: string,\n options: GetPartitionPropertiesOptions = {},\n ): Promise<PartitionProperties> {\n return this._context.managementSession!.getPartitionProperties(partitionId, {\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n\n /**\n * Provides the Event Hub runtime information.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the Event Hub instance.\n * @throws Error if the underlying connection has been closed, create a new EventHubConsumerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise<EventHubProperties> {\n return this._context.managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n\n /**\n * Subscribe to events from all partitions.\n *\n * If checkpoint store is provided to the `EventHubConsumerClient` and there are multiple\n * instances of your application, then each instance will subscribe to a subset of the\n * partitions such that the load is balanced amongst them.\n *\n * Call close() on the returned object to stop receiving events.\n *\n * Example usage:\n * ```ts\n * const client = new EventHubConsumerClient(consumerGroup, connectionString, eventHubName);\n * const subscription = client.subscribe(\n * {\n * processEvents: (events, context) => { console.log(\"Received event count: \", events.length) },\n * processError: (err, context) => { console.log(\"Error: \", err) }\n * },\n * { startPosition: earliestEventPosition }\n * );\n * ```\n *\n * @param handlers - Handlers for the lifecycle of the subscription - subscription initialization\n * per partition, receiving events, handling errors and the closing\n * of a subscription per partition.\n * @param options - Configures the way events are received.\n * Most common are `maxBatchSize` and `maxWaitTimeInSeconds` that control the flow of\n * events to the handler provided to receive events as well as the start position. For example,\n * `{ maxBatchSize: 20, maxWaitTimeInSeconds: 120, startPosition: { sequenceNumber: 123 } }`\n */\n subscribe(handlers: SubscriptionEventHandlers, options?: SubscribeOptions): Subscription; // #1\n /**\n * Subscribe to events from a single partition.\n * Call close() on the returned object to stop receiving events.\n *\n * Example usage:\n * ```ts\n * const client = new EventHubConsumerClient(consumerGroup, connectionString, eventHubName);\n * const subscription = client.subscribe(\n * partitionId,\n * {\n * processEvents: (events, context) => { console.log(\"Received event count: \", events.length) },\n * processError: (err, context) => { console.log(\"Error: \", err) }\n * },\n * { startPosition: earliestEventPosition }\n * );\n * ```\n *\n * @param partitionId - The id of the partition to subscribe to.\n * @param handlers - Handlers for the lifecycle of the subscription - subscription initialization\n * of the partition, receiving events, handling errors and the closing\n * of a subscription to the partition.\n * @param options - Configures the way events are received.\n * Most common are `maxBatchSize` and `maxWaitTimeInSeconds` that control the flow of\n * events to the handler provided to receive events as well as the start position. For example,\n * `{ maxBatchSize: 20, maxWaitTimeInSeconds: 120, startPosition: { sequenceNumber: 123 } }`\n */\n\n subscribe(\n partitionId: string,\n handlers: SubscriptionEventHandlers,\n options?: SubscribeOptions,\n ): Subscription; // #2\n subscribe(\n handlersOrPartitionId1?: SubscriptionEventHandlers | string,\n optionsOrHandlers2?: SubscribeOptions | SubscriptionEventHandlers,\n possibleOptions3?: SubscribeOptions,\n ): Subscription {\n let eventProcessor: EventProcessor;\n let targetedPartitionId: string;\n\n if (isSubscriptionEventHandlers(handlersOrPartitionId1)) {\n // #1: subscribe overload - read from all partitions\n const options = optionsOrHandlers2 as SubscribeOptions | undefined;\n if (options && options.startPosition) {\n validateEventPositions(options.startPosition);\n }\n ({ targetedPartitionId, eventProcessor } = this.createEventProcessorForAllPartitions(\n handlersOrPartitionId1,\n options,\n ));\n } else if (isSubscriptionEventHandlers(optionsOrHandlers2)) {\n // #2: subscribe overload (read from specific partition IDs), don't coordinate\n const options = possibleOptions3 as SubscribeOptions | undefined;\n if (options && options.startPosition) {\n validateEventPositions(options.startPosition);\n }\n ({ targetedPartitionId, eventProcessor } = this.createEventProcessorForSinglePartition(\n // cast to string as downstream code expects partitionId to be string, but JS users could have given us anything.\n // we don't validate the user input and instead rely on service throwing errors if any\n String(handlersOrPartitionId1),\n optionsOrHandlers2,\n possibleOptions3,\n ));\n } else {\n throw new TypeError(\"Unhandled subscribe() overload\");\n }\n\n eventProcessor.start();\n\n const subscription = {\n get isRunning() {\n return eventProcessor.isRunning();\n },\n close: () => {\n this._partitionGate.remove(targetedPartitionId);\n this._subscriptions.delete(subscription);\n return eventProcessor.stop();\n },\n };\n this._subscriptions.add(subscription);\n return subscription;\n }\n\n /**\n * Gets the LoadBalancing strategy that should be used based on what the user provided.\n */\n private _getLoadBalancingStrategy(): LoadBalancingStrategy {\n if (!this._userChoseCheckpointStore) {\n // The default behavior when a checkpointstore isn't provided\n // is to always grab all the partitions.\n return new UnbalancedLoadBalancingStrategy();\n }\n\n const partitionOwnershipExpirationIntervalInMs =\n this._loadBalancingOptions.partitionOwnershipExpirationIntervalInMs;\n if (this._loadBalancingOptions?.strategy === \"greedy\") {\n return new GreedyLoadBalancingStrategy(partitionOwnershipExpirationIntervalInMs);\n }\n\n // The default behavior when a checkpointstore is provided is\n // to grab one partition at a time.\n return new BalancedLoadBalancingStrategy(partitionOwnershipExpirationIntervalInMs);\n }\n\n private createEventProcessorForAllPartitions(\n subscriptionEventHandlers: SubscriptionEventHandlers,\n options?: SubscribeOptions,\n ): { targetedPartitionId: string; eventProcessor: EventProcessor } {\n this._partitionGate.add(\"all\");\n\n if (this._userChoseCheckpointStore) {\n logger.verbose(\n \"EventHubConsumerClient subscribing to all partitions, using a checkpoint store.\",\n );\n } else {\n logger.verbose(\"EventHubConsumerClient subscribing to all partitions, no checkpoint store.\");\n }\n\n const loadBalancingStrategy = this._getLoadBalancingStrategy();\n const eventProcessor = this._createEventProcessor(\n this._context,\n subscriptionEventHandlers,\n this._checkpointStore,\n {\n ...defaultConsumerClientOptions,\n ...(options as SubscribeOptions),\n ownerLevel: getOwnerLevel(options, this._userChoseCheckpointStore),\n // make it so all the event processors process work with the same overarching owner ID\n // this allows the EventHubConsumer to unify all the work for any processors that it spawns\n ownerId: this.identifier,\n retryOptions: this._clientOptions.retryOptions,\n loadBalancingStrategy,\n loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs,\n },\n );\n\n return { targetedPartitionId: \"all\", eventProcessor };\n }\n\n private createEventProcessorForSinglePartition(\n partitionId: string,\n eventHandlers: SubscriptionEventHandlers,\n options?: SubscribeOptions,\n ): { targetedPartitionId: string; eventProcessor: EventProcessor } {\n this._partitionGate.add(partitionId);\n\n const subscribeOptions = options as SubscribeOptions | undefined;\n\n if (this._userChoseCheckpointStore) {\n logger.verbose(\n `EventHubConsumerClient subscribing to specific partition (${partitionId}), using a checkpoint store.`,\n );\n } else {\n logger.verbose(\n `EventHubConsumerClient subscribing to specific partition (${partitionId}), no checkpoint store.`,\n );\n }\n\n const eventProcessor = this._createEventProcessor(\n this._context,\n eventHandlers,\n this._checkpointStore,\n {\n ...defaultConsumerClientOptions,\n ...options,\n processingTarget: partitionId,\n ownerLevel: getOwnerLevel(subscribeOptions, this._userChoseCheckpointStore),\n retryOptions: this._clientOptions.retryOptions,\n loadBalancingStrategy: new UnbalancedLoadBalancingStrategy(),\n loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs ?? 10000,\n },\n );\n\n return { targetedPartitionId: partitionId, eventProcessor };\n }\n\n private _createEventProcessor(\n connectionContext: ConnectionContext,\n subscriptionEventHandlers: SubscriptionEventHandlers,\n checkpointStore: CheckpointStore,\n options: FullEventProcessorOptions,\n ): EventProcessor {\n return new EventProcessor(\n this._consumerGroup,\n connectionContext,\n subscriptionEventHandlers,\n checkpointStore,\n options,\n );\n }\n}\n\n/**\n * @internal\n */\nexport function isCheckpointStore(possible: CheckpointStore | any): possible is CheckpointStore {\n if (!possible) {\n return false;\n }\n\n const checkpointStore = possible as CheckpointStore;\n\n return (\n typeof checkpointStore.claimOwnership === \"function\" &&\n typeof checkpointStore.listCheckpoints === \"function\" &&\n typeof checkpointStore.listOwnership === \"function\" &&\n typeof checkpointStore.updateCheckpoint === \"function\"\n );\n}\n\n/**\n * @internal\n */\nfunction isSubscriptionEventHandlers(\n possible: any | SubscriptionEventHandlers,\n): possible is SubscriptionEventHandlers {\n return typeof (possible as SubscriptionEventHandlers).processEvents === \"function\";\n}\n\nfunction getOwnerLevel(\n options: SubscribeOptions | undefined,\n userChoseCheckpointStore: boolean,\n): number | undefined {\n if (options && options.ownerLevel) {\n return options.ownerLevel;\n }\n\n if (userChoseCheckpointStore) {\n return 0;\n } else {\n return undefined;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventHubConsumerClientModels.js","sourceRoot":"","sources":["../../src/eventHubConsumerClientModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CloseReason } from \"./models/public\";\nimport { EventPosition } from \"./eventPosition\";\nimport { LastEnqueuedEventProperties } from \"./partitionReceiver\";\nimport { MessagingError } from \"@azure/core-amqp\";\nimport { OperationTracingOptions } from \"@azure/core-tracing\";\nimport { ReceivedEventData } from \"./eventData\";\n\n/**\n * @internal\n */\nexport interface BasicPartitionProperties {\n /**\n * The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n */\n fullyQualifiedNamespace: string;\n /**\n * The event hub name.\n */\n eventHubName: string;\n /**\n * The consumer group name.\n */\n consumerGroup: string;\n /**\n * The identifier of the Event Hub partition.\n */\n partitionId: string;\n}\n\n/**\n * Interface that describes the context passed to each of the functions that are a part\n * of the `SubscriptionEventHandlers`. When implementing any of these functions, use\n * the context object to get information about the partition as well as the\n * ability to checkpoint.\n */\nexport interface PartitionContext {\n /**\n * The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n */\n readonly fullyQualifiedNamespace: string;\n /**\n * The event hub name.\n */\n readonly eventHubName: string;\n /**\n * The consumer group name.\n */\n readonly consumerGroup: string;\n /**\n * The identifier of the Event Hub partition.\n */\n readonly partitionId: string;\n /**\n * Information on the last enqueued event in the partition that is being processed.\n * This property is only updated if the `trackLastEnqueuedEventProperties` option is set to true\n * when creating an instance of EventProcessor.\n * @readonly\n */\n readonly lastEnqueuedEventProperties?: LastEnqueuedEventProperties;\n /**\n * Updates the checkpoint using the event data.\n *\n * A checkpoint is meant to represent the last successfully processed event by the user from a particular\n * partition of a consumer group in an Event Hub instance.\n *\n * @param eventData - The event that you want to update the checkpoint with.\n */\n updateCheckpoint(eventData: ReceivedEventData): Promise<void>;\n}\n\n/**\n * Signature of the user provided function invoked by `EventHubConsumerClient` when a set of events is received.\n */\nexport type ProcessEventsHandler = (\n events: ReceivedEventData[],\n context: PartitionContext,\n) => Promise<void>;\n\n/**\n * Signature of the user provided function invoked by `EventHubConsumerClient` for errors that occur when\n * receiving events or when executing any of the user provided functions passed to the `subscribe()` method.\n */\nexport type ProcessErrorHandler = (\n error: Error | MessagingError,\n context: PartitionContext,\n) => Promise<void>;\n\n/**\n * Signature of the user provided function invoked by `EventHubConsumerClient` just before starting to receive\n * events from a partition.\n */\nexport type ProcessInitializeHandler = (context: PartitionContext) => Promise<void>;\n\n/**\n * Signature of the user provided function invoked by `EventHubConsumerClient` just after stopping to receive\n * events from a partition.\n */\nexport type ProcessCloseHandler = (reason: CloseReason, context: PartitionContext) => Promise<void>;\n\n/**\n * Interface that describes the functions to be implemented by the user which are invoked by\n * the `EventHubConsumerClient` when the `subscribe()` method is called to receive events\n * from Event Hub.\n */\nexport interface SubscriptionEventHandlers {\n /**\n * The function invoked by `EventHubConsumerClient` when a set of events is received. The\n * `PartitionContext` passed to this function can be used to determine which partition is being read from.\n *\n * The `updateCheckpoint()` method on the context can be used to update checkpoints in the `CheckpointStore`\n * (if one was provided to the client). Use this in frequent intervals to mark events that have been processed\n * so that the client can restart from such checkpoints in the event of a restart or error recovery.\n *\n * Note: It is possible for received events to be an empty array.\n * This can happen if there are no new events to receive\n * in the `maxWaitTimeInSeconds`, which is defaulted to 60 seconds.\n * The `maxWaitTimeInSeconds` can be changed by setting\n * it in the `options` passed to `subscribe()`.\n */\n processEvents: ProcessEventsHandler;\n /**\n * The function invoked by `EventHubConsumerClient` for errors that occur when receiving events\n * or when executing any of the user provided functions passed to the `subscribe()` method.\n *\n * The `PartitionContext` passed to this function will indicate the partition that was being processed\n * when the error was thrown. In cases where an error is thrown outside of processing events from a\n * partition(e.g. failure to perform load balancing), the `partitionId` on the context will be an empty string.\n *\n * After the client completes executing this function, the `partitionClose` function is invoked.\n */\n processError: ProcessErrorHandler;\n /**\n * The function invoked by `EventHubConsumerClient` each time the subscription is about to begin\n * reading from a partition. The `PartitionContext` passed to this function can be used to determine\n * which partition is about to be read from.\n *\n * The client will start receiving events for the partition only after completing the execution of\n * this function (if provided). Therefore, use this function to carry out any setup work including\n * async tasks.\n */\n processInitialize?: ProcessInitializeHandler;\n /**\n * The function invoked by `EventHubConsumerClient` each time the subscription stops reading events from\n * a partition. The information on this partition will be available on the `PartitionContext` passed to the\n * function `processClose`.\n *\n * If the `CloseReason` passed to this function is `OwnershipLost`, then another subscription has taken over\n * reading from the same partition using the same consumer group. This is expected if you have multiple\n * instances of your application running and have passed the `CheckpointStore` to the client to load balance.\n *\n * If the `CloseReason` is `Shutdown`, this indicates that either `subscription.close()` was called, or an\n * error occured. Unless the subscription was explicitly closed via `subscription.close()`, the subscription\n * will attempt to resume reading events from the last checkpoint for the partition.\n */\n processClose?: ProcessCloseHandler;\n}\n\n/**\n * Options to configure the `subscribe` method on the `EventHubConsumerClient`.\n * For example, `{ maxBatchSize: 20, maxWaitTimeInSeconds: 120, startPosition: { sequenceNumber: 123 } }`\n */\nexport interface SubscribeOptions {\n /**\n * The number of events to request per batch\n */\n maxBatchSize?: number;\n /**\n * The maximum amount of time to wait to build up the requested message count before\n * passing the data to user code for processing. If not provided, it defaults to 60 seconds.\n */\n maxWaitTimeInSeconds?: number;\n /**\n * The event position in a partition to start receiving events from if no checkpoint is found.\n * Pass a map of partition id to position if you would like to use different starting\n * position for each partition.\n */\n startPosition?: EventPosition | { [partitionId: string]: EventPosition };\n /**\n * Indicates whether or not the consumer should request information on the last enqueued event on its\n * associated partition, and track that information as events are received.\n\n * When information about the partition's last enqueued event is being tracked, each event received\n * from the Event Hubs service will carry metadata about the partition that it otherwise would not. This results in a small amount of\n * additional network bandwidth consumption that is generally a favorable trade-off when considered\n * against periodically making requests for partition properties using the Event Hub client.\n */\n trackLastEnqueuedEventProperties?: boolean;\n /**\n * The owner level to use as this subscription subscribes to partitions.\n */\n ownerLevel?: number;\n /**\n * Options for configuring tracing.\n */\n tracingOptions?: OperationTracingOptions;\n /**\n * Option to disable the client from running JSON.parse() on the message body when receiving the message.\n * Not applicable if the message was sent with AMQP body type value or sequence. Use this option when you\n * prefer to work directly with the bytes present in the message body than have the client attempt to parse it.\n */\n skipParsingBodyAsJson?: boolean;\n /**\n * The count of events requested eagerly and queued without regard to whether a read was requested.\n */\n prefetchCount?: number;\n}\n\n/**\n * Interface that describes the object returned by the `subscribe()` method on the `EventHubConsumerClient`.\n */\nexport interface Subscription {\n /**\n * Stops the subscription from receiving more messages.\n *\n * If a checkpoint store has been configured this will also mark this subscription's\n * partitions as abandoned, freeing them up to be read by other consumers.\n *\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n close(): Promise<void>;\n /**\n * Indicates whether the receiver is running.\n * `true` - is running; `false` otherwise.\n * @readonly\n */\n isRunning: boolean;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventHubProducerClient.js","sourceRoot":"","sources":["../../src/eventHubProducerClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAqB,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAUjF,OAAO,EAAkB,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIxF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,4BAA4B,EAC5B,gCAAgC,EAChC,iCAAiC,GAClC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,sBAAsB;IA4BjC;;;OAGG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAA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AM,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ConnectionContext, createConnectionContext } from \"./connectionContext\";\nimport {\n CreateBatchOptions,\n EventHubClientOptions,\n GetEventHubPropertiesOptions,\n GetPartitionIdsOptions,\n GetPartitionPropertiesOptions,\n SendBatchOptions,\n} from \"./models/public\";\nimport { PartitionPublishingOptions, PartitionPublishingProperties } from \"./models/private\";\nimport { EventDataBatch, EventDataBatchImpl, isEventDataBatch } from \"./eventDataBatch\";\nimport { EventHubProperties, PartitionProperties } from \"./managementClient\";\nimport { TracingContext, TracingSpanLink } from \"@azure/core-tracing\";\nimport { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isDefined } from \"@azure/core-util\";\nimport { isCredential } from \"./util/typeGuards\";\nimport { logErrorStackTrace, logger } from \"./logger\";\nimport {\n idempotentAlreadyPublished,\n idempotentSomeAlreadyPublished,\n throwErrorIfConnectionClosed,\n throwTypeErrorIfParameterMissing,\n validateProducerPartitionSettings,\n} from \"./util/error\";\nimport { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { EventData, EventDataInternal } from \"./eventData\";\nimport { EventHubSender } from \"./eventHubSender\";\nimport { OperationOptions } from \"./util/operationOptions\";\nimport { toSpanOptions, tracingClient } from \"./diagnostics/tracing\";\nimport { instrumentEventData } from \"./diagnostics/instrumentEventData\";\nimport { getRandomName } from \"./util/utils\";\n\n/**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n *\n * There are multiple ways to create an `EventHubProducerClient`\n * - Use the connection string from the SAS policy created for your Event Hub instance.\n * - Use the connection string from the SAS policy created for your Event Hub namespace,\n * and the name of the Event Hub instance\n * - Use the full namespace like `<yournamespace>.servicebus.windows.net`, and a credentials object.\n *\n * Optionally, you can also pass an options bag to configure the retry policy or proxy settings.\n *\n */\nexport class EventHubProducerClient {\n /**\n * Describes the amqp connection context for the client.\n */\n private _context: ConnectionContext;\n\n /**\n * The options passed by the user when creating the EventHubClient instance.\n */\n private _clientOptions: EventHubClientOptions;\n /**\n * Map of partitionId to senders\n */\n private _sendersMap: Map<string, EventHubSender>;\n /**\n * Indicates whether or not the EventHubProducerClient should enable idempotent publishing to Event Hub partitions.\n * If enabled, the producer will only be able to publish directly to partitions;\n * it will not be able to publish to the Event Hubs gateway for automatic partition routing\n * nor will it be able to use a partition key.\n * Default: false\n */\n private _enableIdempotentRetries?: boolean;\n /**\n * The set of options that can be specified to influence publishing behavior specific to the configured Event Hub partition.\n * These options are not necessary in the majority of scenarios and are intended for use with specialized scenarios,\n * such as when recovering the state used for idempotent publishing.\n */\n private _partitionOptions?: Record<string, PartitionPublishingOptions>;\n /**\n * @readonly\n * The name of the Event Hub instance for which this client is created.\n */\n get eventHubName(): string {\n return this._context.config.entityPath;\n }\n\n /**\n * @readonly\n * The fully qualified namespace of the Event Hub instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n get fullyQualifiedNamespace(): string {\n return this._context.config.host;\n }\n\n /**\n * The name used to identify this EventHubProducerClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public readonly identifier: string;\n\n /**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(connectionString: string, options?: EventHubClientOptions); // eslint-disable-line @azure/azure-sdk/ts-naming-options\n /**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(connectionString: string, eventHubName: string, options?: EventHubClientOptions); // eslint-disable-line @azure/azure-sdk/ts-naming-options\n /**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See @azure/identity for creating credentials that support AAD auth.\n * Use the `AzureNamedKeyCredential` from @azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from @azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options?: EventHubClientOptions, // eslint-disable-line @azure/azure-sdk/ts-naming-options\n );\n constructor(\n fullyQualifiedNamespaceOrConnectionString1: string,\n eventHubNameOrOptions2?: string | EventHubClientOptions,\n credentialOrOptions3?:\n | TokenCredential\n | NamedKeyCredential\n | SASCredential\n | EventHubClientOptions,\n options4?: EventHubClientOptions, // eslint-disable-line @azure/azure-sdk/ts-naming-options\n ) {\n this._context = createConnectionContext(\n fullyQualifiedNamespaceOrConnectionString1,\n eventHubNameOrOptions2,\n credentialOrOptions3,\n options4,\n );\n if (typeof eventHubNameOrOptions2 !== \"string\") {\n this._clientOptions = eventHubNameOrOptions2 || {};\n } else if (!isCredential(credentialOrOptions3)) {\n this._clientOptions = credentialOrOptions3 || {};\n } else {\n this._clientOptions = options4 || {};\n }\n this.identifier = this._clientOptions.identifier ?? getRandomName();\n this._sendersMap = new Map();\n }\n\n /**\n * Creates an instance of `EventDataBatch` to which one can add events until the maximum supported size is reached.\n * The batch can be passed to the {@link sendBatch} method of the `EventHubProducerClient` to be sent to Azure Event Hubs.\n *\n * Events with different values for partitionKey or partitionId will need to be put into different batches.\n * To simplify such batch management across partitions or to have the client automatically batch events\n * and send them in specific intervals, use `EventHubBufferedProducerClient` instead.\n *\n * The below example assumes you have an array of events at hand to be batched safely.\n * If you have events coming in one by one, `EventHubBufferedProducerClient` is recommended instead\n * for effecient management of batches.\n *\n * Example usage:\n * ```ts\n * const client = new EventHubProducerClient(connectionString);\n * let batch = await client.createBatch();\n * for (let i = 0; i < messages.length; i++) {\n * if (!batch.tryAdd(messages[i])) {\n * await client.sendBatch(batch);\n * batch = await client.createBatch();\n * if (!batch.tryAdd(messages[i])) {\n * throw new Error(\"Message too big to fit\")\n * }\n * if (i === messages.length - 1) {\n * await client.sendBatch(batch);\n * }\n * }\n * }\n * ```\n *\n * @param options - Configures the behavior of the batch.\n * - `partitionKey` : A value that is hashed and used by the Azure Event Hubs service to determine the partition to which\n * the events need to be sent.\n * - `partitionId` : Id of the partition to which the batch of events need to be sent.\n * - `maxSizeInBytes`: The upper limit for the size of batch. The `tryAdd` function will return `false` after this limit is reached.\n * - `abortSignal` : A signal the request to cancel the operation.\n * @returns Promise<EventDataBatch>\n * @throws Error if both `partitionId` and `partitionKey` are set in the options.\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal in the options.\n */\n async createBatch(options: CreateBatchOptions = {}): Promise<EventDataBatch> {\n throwErrorIfConnectionClosed(this._context);\n\n const partitionId = isDefined(options.partitionId) ? String(options.partitionId) : undefined;\n\n validateProducerPartitionSettings({\n enableIdempotentRetries: this._enableIdempotentRetries,\n partitionId,\n partitionKey: options.partitionKey,\n });\n\n let sender = this._sendersMap.get(partitionId || \"\");\n if (!sender) {\n const partitionPublishingOptions = isDefined(partitionId)\n ? this._partitionOptions?.[partitionId]\n : undefined;\n sender = EventHubSender.create(this._context, this.identifier, {\n enableIdempotentProducer: Boolean(this._enableIdempotentRetries),\n partitionId,\n partitionPublishingOptions,\n });\n this._sendersMap.set(partitionId || \"\", sender);\n }\n\n let maxMessageSize = await sender.getMaxMessageSize({\n retryOptions: this._clientOptions.retryOptions,\n abortSignal: options.abortSignal,\n });\n\n if (options.maxSizeInBytes) {\n if (options.maxSizeInBytes > maxMessageSize) {\n const error = new Error(\n `Max message size (${options.maxSizeInBytes} bytes) is greater than maximum message size (${maxMessageSize} bytes) on the AMQP sender link.`,\n );\n logger.warning(`[${this._context.connectionId}] ${error.message}`);\n logErrorStackTrace(error);\n throw error;\n }\n maxMessageSize = options.maxSizeInBytes;\n }\n return new EventDataBatchImpl(\n this._context,\n maxMessageSize,\n Boolean(this._enableIdempotentRetries),\n options.partitionKey,\n partitionId,\n );\n }\n\n /**\n * Get the information about the state of publishing for a partition as observed by the `EventHubProducerClient`.\n * This data can always be read, but will only be populated with information relevant to the active features\n * for the producer client.\n *\n * @param partitionId - Id of the partition from which to retrieve publishing properties.\n * @param options - The set of options to apply to the operation call.\n * - `abortSignal` : A signal the request to cancel the send operation.\n * @returns Promise<void>\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore this is called in EventHubBufferedProducerClient via cast-to-any workaround\n private async getPartitionPublishingProperties(\n partitionId: string,\n options: OperationOptions = {},\n ): Promise<PartitionPublishingProperties> {\n if (!isDefined(partitionId)) {\n throw new TypeError(\n `getPartitionPublishingProperties called without required argument \"partitionId\"`,\n );\n }\n\n if (typeof partitionId === \"number\") {\n partitionId = String(partitionId);\n }\n\n let sender = this._sendersMap.get(partitionId);\n if (!sender) {\n sender = EventHubSender.create(this._context, this.identifier, {\n enableIdempotentProducer: Boolean(this._enableIdempotentRetries),\n partitionId,\n partitionPublishingOptions: this._partitionOptions?.[partitionId],\n });\n this._sendersMap.set(partitionId, sender);\n }\n\n return sender.getPartitionPublishingProperties(options);\n }\n\n /**\n * Sends an array of events as a batch to the associated Event Hub.\n *\n * Azure Event Hubs has a limit on the size of the batch that can be sent which if exceeded\n * will result in an error with code `MessageTooLargeError`.\n * To safely send within batch size limits, use `EventHubProducerClient.createBatch()` or\n * `EventHubBufferedProducerClient` instead.\n *\n * Example usage:\n * ```ts\n * const client = new EventHubProducerClient(connectionString);\n * await client.sendBatch(messages);\n * ```\n *\n * @param batch - An array of {@link EventData} or `AmqpAnnotatedMessage`.\n * @param options - A set of options that can be specified to influence the way in which\n * events are sent to the associated Event Hub.\n * - `abortSignal` : A signal the request to cancel the send operation.\n * - `partitionId` : The partition this batch will be sent to. If set, `partitionKey` can not be set.\n * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.\n *\n * @returns Promise<void>\n * @throws MessageTooLargeError if all the events in the input array cannot be fit into a batch.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n * @throws MessagingError if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n async sendBatch(\n batch: EventData[] | AmqpAnnotatedMessage[],\n options?: SendBatchOptions,\n ): Promise<void>;\n /**\n * Sends a batch of events created using `EventHubProducerClient.createBatch()` to the associated Event Hub.\n *\n * Events with different values for partitionKey or partitionId will need to be put into different batches.\n * To simplify such batch management across partitions or to have the client automatically batch events\n * and send them in specific intervals, use `EventHubBufferedProducerClient` instead.\n *\n * The below example assumes you have an array of events at hand to be batched safely.\n * If you have events coming in one by one, `EventHubBufferedProducerClient` is recommended instead\n * for effecient management of batches.\n *\n * Example usage:\n * ```ts\n * const client = new EventHubProducerClient(connectionString);\n * let batch = await client.createBatch();\n * for (let i = 0; i < messages.length; i++) {\n * if (!batch.tryAdd(messages[i])) {\n * await client.sendBatch(batch);\n * batch = await client.createBatch();\n * if (!batch.tryAdd(messages[i])) {\n * throw new Error(\"Message too big to fit\")\n * }\n * if (i === messages.length - 1) {\n * await client.sendBatch(batch);\n * }\n * }\n * }\n * ```\n * @param batch - A batch of events that you can create using the {@link createBatch} method.\n * @param options - A set of options that can be specified to influence the way in which\n * events are sent to the associated Event Hub.\n * - `abortSignal` : A signal the request to cancel the send operation.\n *\n * @returns Promise<void>\n * @throws AbortError if the operation is cancelled via the abortSignal.\n * @throws MessagingError if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n async sendBatch(batch: EventDataBatch, options?: OperationOptions): Promise<void>; // eslint-disable-line @azure/azure-sdk/ts-naming-options\n async sendBatch(\n batch: EventDataBatch | EventData[],\n options: SendBatchOptions | OperationOptions = {},\n ): Promise<void> {\n throwErrorIfConnectionClosed(this._context);\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"sendBatch\", \"batch\", batch);\n\n let partitionId: string | undefined;\n let partitionKey: string | undefined;\n\n // Holds an EventData properties object containing tracing properties.\n // This lets us avoid cloning batch when it is EventData[], which is\n // important as the idempotent EventHubSender needs to decorate the\n // original EventData passed through.\n const eventDataTracingProperties: Array<EventData[\"properties\"]> = [];\n\n // link message span contexts\n let spanContextsToLink: TracingContext[] = [];\n\n if (isEventDataBatch(batch)) {\n if (\n this._enableIdempotentRetries &&\n isDefined((batch as EventDataBatchImpl).startingPublishedSequenceNumber)\n ) {\n throw new Error(idempotentAlreadyPublished);\n }\n const partitionAssignment = extractPartitionAssignmentFromBatch(batch, options);\n partitionId = partitionAssignment.partitionId;\n partitionKey = partitionAssignment.partitionKey;\n spanContextsToLink = (batch as EventDataBatchImpl)._messageSpanContexts;\n } else {\n if (!Array.isArray(batch)) {\n batch = [batch];\n }\n if (batch.some((event) => isDefined((event as EventDataInternal)._publishedSequenceNumber))) {\n throw new Error(idempotentSomeAlreadyPublished);\n }\n const partitionAssignment = extractPartitionAssignmentFromOptions(options);\n partitionId = partitionAssignment.partitionId;\n partitionKey = partitionAssignment.partitionKey;\n\n for (let i = 0; i < batch.length; i++) {\n batch[i] = instrumentEventData(\n batch[i],\n options,\n this._context.config.entityPath,\n this._context.config.host,\n \"publish\",\n ).event;\n eventDataTracingProperties[i] = batch[i].properties;\n }\n }\n\n validateProducerPartitionSettings({\n enableIdempotentRetries: this._enableIdempotentRetries,\n partitionId,\n partitionKey,\n });\n\n return tracingClient.withSpan(\n `${EventHubProducerClient.name}.${this.sendBatch.name}`,\n options,\n (updatedOptions) => {\n let sender = this._sendersMap.get(partitionId || \"\");\n if (!sender) {\n const partitionPublishingOptions = isDefined(partitionId)\n ? this._partitionOptions?.[partitionId]\n : undefined;\n sender = EventHubSender.create(this._context, this.identifier, {\n enableIdempotentProducer: Boolean(this._enableIdempotentRetries),\n partitionId,\n partitionPublishingOptions,\n });\n this._sendersMap.set(partitionId || \"\", sender);\n }\n\n return sender.send(batch, {\n ...updatedOptions,\n partitionId,\n partitionKey,\n retryOptions: this._clientOptions.retryOptions,\n });\n },\n {\n spanLinks: spanContextsToLink.map<TracingSpanLink>((tracingContext) => {\n return { tracingContext };\n }),\n ...toSpanOptions(this._context.config, \"publish\", \"client\"),\n },\n );\n }\n\n /**\n * Closes the AMQP connection to the Event Hub instance,\n * returning a promise that will be resolved when disconnection is completed.\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n async close(): Promise<void> {\n await this._context.close();\n\n for (const pair of this._sendersMap) {\n await pair[1].close();\n }\n this._sendersMap.clear();\n }\n\n /**\n * Provides the Event Hub runtime information.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the Event Hub instance.\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise<EventHubProperties> {\n return this._context.managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n\n /**\n * Provides the id for each partition associated with the Event Hub.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with an Array of strings representing the id for\n * each partition associated with the Event Hub.\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionIds(options: GetPartitionIdsOptions = {}): Promise<Array<string>> {\n return this._context\n .managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n })\n .then((eventHubProperties) => {\n return eventHubProperties.partitionIds;\n });\n }\n\n /**\n * Provides information about the state of the specified partition.\n * @param partitionId - The id of the partition for which information is required.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the state of the partition .\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionProperties(\n partitionId: string,\n options: GetPartitionPropertiesOptions = {},\n ): Promise<PartitionProperties> {\n return this._context.managementSession!.getPartitionProperties(partitionId, {\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n}\n\n/**\n * @internal\n */\nfunction extractPartitionAssignmentFromOptions(options: SendBatchOptions = {}): {\n partitionKey?: string;\n partitionId?: string;\n} {\n const result: ReturnType<typeof extractPartitionAssignmentFromOptions> = {};\n const { partitionId, partitionKey } = options;\n\n if (isDefined(partitionId)) {\n result.partitionId = String(partitionId);\n }\n if (isDefined(partitionKey)) {\n result.partitionKey = String(partitionKey);\n }\n\n return result;\n}\n\n/**\n * @internal\n */\nfunction extractPartitionAssignmentFromBatch(\n batch: EventDataBatch,\n options: SendBatchOptions,\n): { partitionKey?: string; partitionId?: string } {\n const result: ReturnType<typeof extractPartitionAssignmentFromBatch> = {};\n const partitionId = batch.partitionId;\n const partitionKey = batch.partitionKey;\n\n const { partitionId: unexpectedPartitionId, partitionKey: unexpectedPartitionKey } =\n extractPartitionAssignmentFromOptions(options);\n if (unexpectedPartitionKey && partitionKey !== unexpectedPartitionKey) {\n throw new Error(\n `The partitionKey (${unexpectedPartitionKey}) set on sendBatch does not match the partitionKey (${partitionKey}) set when creating the batch.`,\n );\n }\n if (unexpectedPartitionId && unexpectedPartitionId !== partitionId) {\n throw new Error(\n `The partitionId (${unexpectedPartitionId}) set on sendBatch does not match the partitionId (${partitionId}) set when creating the batch.`,\n );\n }\n\n if (isDefined(partitionId)) {\n result.partitionId = String(partitionId);\n }\n if (isDefined(partitionKey)) {\n result.partitionKey = String(partitionKey);\n }\n\n return result;\n}\n"]}
|