@azure/event-hubs 5.13.0-alpha.20241017.1 → 5.13.0-alpha.20241115.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/batchingPartitionChannel.d.ts +3 -3
- package/dist/browser/batchingPartitionChannel.d.ts.map +1 -1
- package/dist/browser/batchingPartitionChannel.js.map +1 -1
- package/dist/browser/connectionContext.d.ts +8 -7
- package/dist/browser/connectionContext.d.ts.map +1 -1
- package/dist/browser/connectionContext.js +2 -4
- package/dist/browser/connectionContext.js.map +1 -1
- package/dist/browser/diagnostics/instrumentEventData.d.ts +5 -5
- package/dist/browser/diagnostics/instrumentEventData.d.ts.map +1 -1
- package/dist/browser/diagnostics/instrumentEventData.js.map +1 -1
- package/dist/browser/diagnostics/tracing.d.ts +2 -2
- package/dist/browser/diagnostics/tracing.d.ts.map +1 -1
- package/dist/browser/diagnostics/tracing.js.map +1 -1
- package/dist/browser/eventData.d.ts +2 -2
- package/dist/browser/eventData.d.ts.map +1 -1
- package/dist/browser/eventData.js +2 -2
- package/dist/browser/eventData.js.map +1 -1
- package/dist/browser/eventDataAdapter.d.ts +1 -1
- package/dist/browser/eventDataAdapter.d.ts.map +1 -1
- package/dist/browser/eventDataAdapter.js.map +1 -1
- package/dist/browser/eventDataBatch.d.ts +5 -5
- package/dist/browser/eventDataBatch.d.ts.map +1 -1
- package/dist/browser/eventDataBatch.js.map +1 -1
- package/dist/browser/eventHubBufferedProducerClient.d.ts +6 -6
- package/dist/browser/eventHubBufferedProducerClient.d.ts.map +1 -1
- package/dist/browser/eventHubBufferedProducerClient.js.map +1 -1
- package/dist/browser/eventHubConsumerClient.d.ts +5 -5
- package/dist/browser/eventHubConsumerClient.d.ts.map +1 -1
- package/dist/browser/eventHubConsumerClient.js.map +1 -1
- package/dist/browser/eventHubConsumerClientModels.d.ts +6 -6
- package/dist/browser/eventHubConsumerClientModels.d.ts.map +1 -1
- package/dist/browser/eventHubConsumerClientModels.js.map +1 -1
- package/dist/browser/eventHubProducerClient.d.ts +7 -7
- package/dist/browser/eventHubProducerClient.d.ts.map +1 -1
- package/dist/browser/eventHubProducerClient.js.map +1 -1
- package/dist/browser/eventHubSender.d.ts +8 -8
- package/dist/browser/eventHubSender.d.ts.map +1 -1
- package/dist/browser/eventHubSender.js +3 -3
- package/dist/browser/eventHubSender.js.map +1 -1
- package/dist/browser/eventProcessor.d.ts +6 -6
- package/dist/browser/eventProcessor.d.ts.map +1 -1
- package/dist/browser/eventProcessor.js.map +1 -1
- package/dist/browser/impl/awaitableQueue.d.ts +1 -1
- package/dist/browser/impl/awaitableQueue.d.ts.map +1 -1
- package/dist/browser/impl/awaitableQueue.js.map +1 -1
- package/dist/browser/inMemoryCheckpointStore.d.ts +2 -2
- package/dist/browser/inMemoryCheckpointStore.d.ts.map +1 -1
- package/dist/browser/inMemoryCheckpointStore.js.map +1 -1
- package/dist/browser/loadBalancerStrategies/balancedStrategy.d.ts +2 -2
- package/dist/browser/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -1
- package/dist/browser/loadBalancerStrategies/balancedStrategy.js.map +1 -1
- package/dist/browser/loadBalancerStrategies/greedyStrategy.d.ts +2 -2
- package/dist/browser/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -1
- package/dist/browser/loadBalancerStrategies/greedyStrategy.js.map +1 -1
- package/dist/browser/loadBalancerStrategies/loadBalancingStrategy.d.ts +1 -1
- package/dist/browser/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -1
- package/dist/browser/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -1
- package/dist/browser/loadBalancerStrategies/unbalancedStrategy.d.ts +2 -2
- package/dist/browser/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -1
- package/dist/browser/loadBalancerStrategies/unbalancedStrategy.js.map +1 -1
- package/dist/browser/logger.d.ts +1 -1
- package/dist/browser/logger.d.ts.map +1 -1
- package/dist/browser/logger.js.map +1 -1
- package/dist/browser/managementClient.d.ts +4 -4
- package/dist/browser/managementClient.d.ts.map +1 -1
- package/dist/browser/managementClient.js +1 -1
- package/dist/browser/managementClient.js.map +1 -1
- package/dist/browser/models/private.d.ts +5 -5
- package/dist/browser/models/private.d.ts.map +1 -1
- package/dist/browser/models/private.js +1 -1
- package/dist/browser/models/private.js.map +1 -1
- package/dist/browser/models/public.d.ts +2 -2
- package/dist/browser/models/public.d.ts.map +1 -1
- package/dist/browser/models/public.js.map +1 -1
- package/dist/browser/partitionProcessor.d.ts +5 -5
- package/dist/browser/partitionProcessor.d.ts.map +1 -1
- package/dist/browser/partitionProcessor.js.map +1 -1
- package/dist/browser/partitionPump.d.ts +7 -7
- package/dist/browser/partitionPump.d.ts.map +1 -1
- package/dist/browser/partitionPump.js.map +1 -1
- package/dist/browser/partitionReceiver.d.ts +6 -6
- package/dist/browser/partitionReceiver.d.ts.map +1 -1
- package/dist/browser/partitionReceiver.js +1 -1
- package/dist/browser/partitionReceiver.js.map +1 -1
- package/dist/browser/pumpManager.d.ts +5 -5
- package/dist/browser/pumpManager.d.ts.map +1 -1
- package/dist/browser/pumpManager.js.map +1 -1
- package/dist/browser/util/delayWithoutThrow.d.ts +1 -1
- package/dist/browser/util/delayWithoutThrow.d.ts.map +1 -1
- package/dist/browser/util/delayWithoutThrow.js.map +1 -1
- package/dist/browser/util/error.d.ts +3 -3
- package/dist/browser/util/error.d.ts.map +1 -1
- package/dist/browser/util/error.js.map +1 -1
- package/dist/browser/util/operationOptions.d.ts +2 -2
- package/dist/browser/util/operationOptions.d.ts.map +1 -1
- package/dist/browser/util/operationOptions.js.map +1 -1
- package/dist/browser/util/retries.d.ts +1 -1
- package/dist/browser/util/retries.d.ts.map +1 -1
- package/dist/browser/util/retries.js.map +1 -1
- package/dist/browser/util/typeGuards.d.ts +1 -1
- package/dist/browser/util/typeGuards.d.ts.map +1 -1
- package/dist/browser/util/typeGuards.js +1 -1
- package/dist/browser/util/typeGuards.js.map +1 -1
- package/dist/browser/withAuth.d.ts +5 -5
- package/dist/browser/withAuth.d.ts.map +1 -1
- package/dist/browser/withAuth.js +1 -1
- package/dist/browser/withAuth.js.map +1 -1
- package/dist/commonjs/batchingPartitionChannel.d.ts +3 -3
- package/dist/commonjs/batchingPartitionChannel.d.ts.map +1 -1
- package/dist/commonjs/batchingPartitionChannel.js.map +1 -1
- package/dist/commonjs/connectionContext.d.ts +8 -7
- package/dist/commonjs/connectionContext.d.ts.map +1 -1
- package/dist/commonjs/connectionContext.js +0 -2
- package/dist/commonjs/connectionContext.js.map +1 -1
- package/dist/commonjs/diagnostics/instrumentEventData.d.ts +5 -5
- package/dist/commonjs/diagnostics/instrumentEventData.d.ts.map +1 -1
- package/dist/commonjs/diagnostics/instrumentEventData.js.map +1 -1
- package/dist/commonjs/diagnostics/tracing.d.ts +2 -2
- package/dist/commonjs/diagnostics/tracing.d.ts.map +1 -1
- package/dist/commonjs/diagnostics/tracing.js.map +1 -1
- package/dist/commonjs/eventData.d.ts +2 -2
- package/dist/commonjs/eventData.d.ts.map +1 -1
- package/dist/commonjs/eventData.js.map +1 -1
- package/dist/commonjs/eventDataAdapter.d.ts +1 -1
- package/dist/commonjs/eventDataAdapter.d.ts.map +1 -1
- package/dist/commonjs/eventDataAdapter.js.map +1 -1
- package/dist/commonjs/eventDataBatch.d.ts +5 -5
- package/dist/commonjs/eventDataBatch.d.ts.map +1 -1
- package/dist/commonjs/eventDataBatch.js.map +1 -1
- package/dist/commonjs/eventHubBufferedProducerClient.d.ts +6 -6
- package/dist/commonjs/eventHubBufferedProducerClient.d.ts.map +1 -1
- package/dist/commonjs/eventHubBufferedProducerClient.js.map +1 -1
- package/dist/commonjs/eventHubConsumerClient.d.ts +5 -5
- package/dist/commonjs/eventHubConsumerClient.d.ts.map +1 -1
- package/dist/commonjs/eventHubConsumerClient.js.map +1 -1
- package/dist/commonjs/eventHubConsumerClientModels.d.ts +6 -6
- package/dist/commonjs/eventHubConsumerClientModels.d.ts.map +1 -1
- package/dist/commonjs/eventHubConsumerClientModels.js.map +1 -1
- package/dist/commonjs/eventHubProducerClient.d.ts +7 -7
- package/dist/commonjs/eventHubProducerClient.d.ts.map +1 -1
- package/dist/commonjs/eventHubProducerClient.js.map +1 -1
- package/dist/commonjs/eventHubSender.d.ts +8 -8
- package/dist/commonjs/eventHubSender.d.ts.map +1 -1
- package/dist/commonjs/eventHubSender.js.map +1 -1
- package/dist/commonjs/eventProcessor.d.ts +6 -6
- package/dist/commonjs/eventProcessor.d.ts.map +1 -1
- package/dist/commonjs/eventProcessor.js.map +1 -1
- package/dist/commonjs/impl/awaitableQueue.d.ts +1 -1
- package/dist/commonjs/impl/awaitableQueue.d.ts.map +1 -1
- package/dist/commonjs/impl/awaitableQueue.js.map +1 -1
- package/dist/commonjs/inMemoryCheckpointStore.d.ts +2 -2
- package/dist/commonjs/inMemoryCheckpointStore.d.ts.map +1 -1
- package/dist/commonjs/inMemoryCheckpointStore.js.map +1 -1
- package/dist/commonjs/loadBalancerStrategies/balancedStrategy.d.ts +2 -2
- package/dist/commonjs/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -1
- package/dist/commonjs/loadBalancerStrategies/balancedStrategy.js.map +1 -1
- package/dist/commonjs/loadBalancerStrategies/greedyStrategy.d.ts +2 -2
- package/dist/commonjs/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -1
- package/dist/commonjs/loadBalancerStrategies/greedyStrategy.js.map +1 -1
- package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.d.ts +1 -1
- package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -1
- package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -1
- package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.d.ts +2 -2
- package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -1
- package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.js.map +1 -1
- package/dist/commonjs/logger.d.ts +1 -1
- package/dist/commonjs/logger.d.ts.map +1 -1
- package/dist/commonjs/logger.js.map +1 -1
- package/dist/commonjs/managementClient.d.ts +4 -4
- package/dist/commonjs/managementClient.d.ts.map +1 -1
- package/dist/commonjs/managementClient.js.map +1 -1
- package/dist/commonjs/models/private.d.ts +5 -5
- package/dist/commonjs/models/private.d.ts.map +1 -1
- package/dist/commonjs/models/private.js +0 -1
- package/dist/commonjs/models/private.js.map +1 -1
- package/dist/commonjs/models/public.d.ts +2 -2
- package/dist/commonjs/models/public.d.ts.map +1 -1
- package/dist/commonjs/models/public.js.map +1 -1
- package/dist/commonjs/partitionProcessor.d.ts +5 -5
- package/dist/commonjs/partitionProcessor.d.ts.map +1 -1
- package/dist/commonjs/partitionProcessor.js.map +1 -1
- package/dist/commonjs/partitionPump.d.ts +7 -7
- package/dist/commonjs/partitionPump.d.ts.map +1 -1
- package/dist/commonjs/partitionPump.js.map +1 -1
- package/dist/commonjs/partitionReceiver.d.ts +6 -6
- package/dist/commonjs/partitionReceiver.d.ts.map +1 -1
- package/dist/commonjs/partitionReceiver.js.map +1 -1
- package/dist/commonjs/pumpManager.d.ts +5 -5
- package/dist/commonjs/pumpManager.d.ts.map +1 -1
- package/dist/commonjs/pumpManager.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/util/delayWithoutThrow.d.ts +1 -1
- package/dist/commonjs/util/delayWithoutThrow.d.ts.map +1 -1
- package/dist/commonjs/util/delayWithoutThrow.js.map +1 -1
- package/dist/commonjs/util/error.d.ts +3 -3
- package/dist/commonjs/util/error.d.ts.map +1 -1
- package/dist/commonjs/util/error.js.map +1 -1
- package/dist/commonjs/util/operationOptions.d.ts +2 -2
- package/dist/commonjs/util/operationOptions.d.ts.map +1 -1
- package/dist/commonjs/util/operationOptions.js.map +1 -1
- package/dist/commonjs/util/retries.d.ts +1 -1
- package/dist/commonjs/util/retries.d.ts.map +1 -1
- package/dist/commonjs/util/retries.js.map +1 -1
- package/dist/commonjs/util/typeGuards.d.ts +1 -1
- package/dist/commonjs/util/typeGuards.d.ts.map +1 -1
- package/dist/commonjs/util/typeGuards.js.map +1 -1
- package/dist/commonjs/withAuth.d.ts +5 -5
- package/dist/commonjs/withAuth.d.ts.map +1 -1
- package/dist/commonjs/withAuth.js.map +1 -1
- package/dist/esm/batchingPartitionChannel.d.ts +3 -3
- package/dist/esm/batchingPartitionChannel.d.ts.map +1 -1
- package/dist/esm/batchingPartitionChannel.js.map +1 -1
- package/dist/esm/connectionContext.d.ts +8 -7
- package/dist/esm/connectionContext.d.ts.map +1 -1
- package/dist/esm/connectionContext.js +2 -4
- package/dist/esm/connectionContext.js.map +1 -1
- package/dist/esm/diagnostics/instrumentEventData.d.ts +5 -5
- package/dist/esm/diagnostics/instrumentEventData.d.ts.map +1 -1
- package/dist/esm/diagnostics/instrumentEventData.js.map +1 -1
- package/dist/esm/diagnostics/tracing.d.ts +2 -2
- package/dist/esm/diagnostics/tracing.d.ts.map +1 -1
- package/dist/esm/diagnostics/tracing.js.map +1 -1
- package/dist/esm/eventData.d.ts +2 -2
- package/dist/esm/eventData.d.ts.map +1 -1
- package/dist/esm/eventData.js +2 -2
- package/dist/esm/eventData.js.map +1 -1
- package/dist/esm/eventDataAdapter.d.ts +1 -1
- package/dist/esm/eventDataAdapter.d.ts.map +1 -1
- package/dist/esm/eventDataAdapter.js.map +1 -1
- package/dist/esm/eventDataBatch.d.ts +5 -5
- package/dist/esm/eventDataBatch.d.ts.map +1 -1
- package/dist/esm/eventDataBatch.js.map +1 -1
- package/dist/esm/eventHubBufferedProducerClient.d.ts +6 -6
- package/dist/esm/eventHubBufferedProducerClient.d.ts.map +1 -1
- package/dist/esm/eventHubBufferedProducerClient.js.map +1 -1
- package/dist/esm/eventHubConsumerClient.d.ts +5 -5
- package/dist/esm/eventHubConsumerClient.d.ts.map +1 -1
- package/dist/esm/eventHubConsumerClient.js.map +1 -1
- package/dist/esm/eventHubConsumerClientModels.d.ts +6 -6
- package/dist/esm/eventHubConsumerClientModels.d.ts.map +1 -1
- package/dist/esm/eventHubConsumerClientModels.js.map +1 -1
- package/dist/esm/eventHubProducerClient.d.ts +7 -7
- package/dist/esm/eventHubProducerClient.d.ts.map +1 -1
- package/dist/esm/eventHubProducerClient.js.map +1 -1
- package/dist/esm/eventHubSender.d.ts +8 -8
- package/dist/esm/eventHubSender.d.ts.map +1 -1
- package/dist/esm/eventHubSender.js +3 -3
- package/dist/esm/eventHubSender.js.map +1 -1
- package/dist/esm/eventProcessor.d.ts +6 -6
- package/dist/esm/eventProcessor.d.ts.map +1 -1
- package/dist/esm/eventProcessor.js.map +1 -1
- package/dist/esm/impl/awaitableQueue.d.ts +1 -1
- package/dist/esm/impl/awaitableQueue.d.ts.map +1 -1
- package/dist/esm/impl/awaitableQueue.js.map +1 -1
- package/dist/esm/inMemoryCheckpointStore.d.ts +2 -2
- package/dist/esm/inMemoryCheckpointStore.d.ts.map +1 -1
- package/dist/esm/inMemoryCheckpointStore.js.map +1 -1
- package/dist/esm/loadBalancerStrategies/balancedStrategy.d.ts +2 -2
- package/dist/esm/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -1
- package/dist/esm/loadBalancerStrategies/balancedStrategy.js.map +1 -1
- package/dist/esm/loadBalancerStrategies/greedyStrategy.d.ts +2 -2
- package/dist/esm/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -1
- package/dist/esm/loadBalancerStrategies/greedyStrategy.js.map +1 -1
- package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.d.ts +1 -1
- package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -1
- package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -1
- package/dist/esm/loadBalancerStrategies/unbalancedStrategy.d.ts +2 -2
- package/dist/esm/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -1
- package/dist/esm/loadBalancerStrategies/unbalancedStrategy.js.map +1 -1
- package/dist/esm/logger.d.ts +1 -1
- package/dist/esm/logger.d.ts.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/managementClient.d.ts +4 -4
- package/dist/esm/managementClient.d.ts.map +1 -1
- package/dist/esm/managementClient.js +1 -1
- package/dist/esm/managementClient.js.map +1 -1
- package/dist/esm/models/private.d.ts +5 -5
- package/dist/esm/models/private.d.ts.map +1 -1
- package/dist/esm/models/private.js +1 -1
- package/dist/esm/models/private.js.map +1 -1
- package/dist/esm/models/public.d.ts +2 -2
- package/dist/esm/models/public.d.ts.map +1 -1
- package/dist/esm/models/public.js.map +1 -1
- package/dist/esm/partitionProcessor.d.ts +5 -5
- package/dist/esm/partitionProcessor.d.ts.map +1 -1
- package/dist/esm/partitionProcessor.js.map +1 -1
- package/dist/esm/partitionPump.d.ts +7 -7
- package/dist/esm/partitionPump.d.ts.map +1 -1
- package/dist/esm/partitionPump.js.map +1 -1
- package/dist/esm/partitionReceiver.d.ts +6 -6
- package/dist/esm/partitionReceiver.d.ts.map +1 -1
- package/dist/esm/partitionReceiver.js +1 -1
- package/dist/esm/partitionReceiver.js.map +1 -1
- package/dist/esm/pumpManager.d.ts +5 -5
- package/dist/esm/pumpManager.d.ts.map +1 -1
- package/dist/esm/pumpManager.js.map +1 -1
- package/dist/esm/util/delayWithoutThrow.d.ts +1 -1
- package/dist/esm/util/delayWithoutThrow.d.ts.map +1 -1
- package/dist/esm/util/delayWithoutThrow.js.map +1 -1
- package/dist/esm/util/error.d.ts +3 -3
- package/dist/esm/util/error.d.ts.map +1 -1
- package/dist/esm/util/error.js.map +1 -1
- package/dist/esm/util/operationOptions.d.ts +2 -2
- package/dist/esm/util/operationOptions.d.ts.map +1 -1
- package/dist/esm/util/operationOptions.js.map +1 -1
- package/dist/esm/util/retries.d.ts +1 -1
- package/dist/esm/util/retries.d.ts.map +1 -1
- package/dist/esm/util/retries.js.map +1 -1
- package/dist/esm/util/typeGuards.d.ts +1 -1
- package/dist/esm/util/typeGuards.d.ts.map +1 -1
- package/dist/esm/util/typeGuards.js +1 -1
- package/dist/esm/util/typeGuards.js.map +1 -1
- package/dist/esm/withAuth.d.ts +5 -5
- package/dist/esm/withAuth.d.ts.map +1 -1
- package/dist/esm/withAuth.js +1 -1
- package/dist/esm/withAuth.js.map +1 -1
- package/dist/event-hubs.d.ts +5 -5
- package/package.json +5 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventProcessor.js","sourceRoot":"","sources":["../../src/eventProcessor.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAc,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAiB,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAe,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAqJxD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAsBzB;;;;;;;;;;;OAWG;IACH,YACU,cAAsB,EACtB,QAA2B,EAC3B,0BAAqD,EACrD,gBAAiC,EACzC,OAAkC;QAJ1B,mBAAc,GAAd,cAAc,CAAQ;QACtB,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,+BAA0B,GAA1B,0BAA0B,CAA2B;QACrD,qBAAgB,GAAhB,gBAAgB,CAAiB;QAlCnC,eAAU,GAAY,KAAK,CAAC;QAqClC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;YAC3B,MAAM,CAAC,OAAO,CAAC,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G,IAAI,GAAG,EAA8B,CAAC;IACpE,MAAM,iCAAiC,GAAG,IAAI,GAAG,EAA8B,CAAC;IAChF,MAAM,iBAAiB,GAAa,EAAE,CAAC;IAEvC,yDAAyD;IACzD,0DAA0D;IAC1D,wDAAwD;IACxD,+DAA+D;IAC/D,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;QAC3C,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,iCAAiC,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,SAAS,CAAC,OAAO,KAAK,EAAE,IAAI,wBAAwB,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;YAChF,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,4FAA4F;IAC5F,gCAAgC;IAChC,8EAA8E;IAC9E,4CAA4C;IAC5C,qEAAqE;IACrE,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,oBAAoB,CAClE,EAAE,EACF,iCAAiC,EACjC,YAAY,CACb,CAAC;IACF,iBAAiB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAE7C,OAAO;QACL,iBAAiB,EAAE,IAAI,GAAG,CAAC,iBAAiB,CAAC;QAC7C,qBAAqB;KACtB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport { Checkpoint, PartitionProcessor } from \"./partitionProcessor.js\";\nimport { EventPosition, isEventPosition, latestEventPosition } from \"./eventPosition.js\";\nimport { PumpManager, PumpManagerImpl } from \"./pumpManager.js\";\nimport { logErrorStackTrace, logger } from \"./logger.js\";\nimport { CloseReason } from \"./models/public.js\";\nimport { CommonEventProcessorOptions } from \"./models/private.js\";\nimport { ConnectionContext } from \"./connectionContext.js\";\nimport { LoadBalancingStrategy } from \"./loadBalancerStrategies/loadBalancingStrategy.js\";\nimport { OperationOptions } from \"./util/operationOptions.js\";\nimport { SubscriptionEventHandlers } from \"./eventHubConsumerClientModels.js\";\nimport { delayWithoutThrow } from \"./util/delayWithoutThrow.js\";\nimport { getRandomName } from \"./util/utils.js\";\nimport { StandardAbortMessage } from \"@azure/core-amqp\";\n\n/**\n * An interface representing the details on which instance of a `EventProcessor` owns processing\n * of a given partition from a consumer group of an Event Hub instance.\n *\n * **Note**: This is used internally by the `EventProcessor` and user never has to create it directly.\n */\nexport interface PartitionOwnership {\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 * The unique identifier of the event processor.\n */\n ownerId: string;\n /**\n * The last modified time.\n */\n lastModifiedTimeInMs?: number;\n /**\n * The unique identifier for the operation.\n */\n etag?: string;\n}\n\n/**\n * A checkpoint store stores and retrieves partition ownership information and checkpoint details\n * for each partition in a given consumer group of an event hub instance.\n *\n * Users are not meant to implement an `CheckpointStore`.\n * Users are expected to choose existing implementations of this interface, instantiate it, and pass\n * it to the `EventHubConsumerClient` class constructor when instantiating a client.\n * Users are not expected to use any of the methods on a checkpoint store, these are used internally by\n * the client.\n *\n * Implementations of `CheckpointStore` can be found on npm by searching for packages with the prefix @azure/eventhub-checkpointstore-.\n */\nexport interface CheckpointStore {\n /**\n * Called to get the list of all existing partition ownership from the underlying data store. Could return empty\n * results if there are is no existing ownership information.\n *\n * @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net.\n * @param eventHubName - The event hub name.\n * @param consumerGroup - The consumer group name.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n * @returns A list of partition ownership details of all the partitions that have/had an owner.\n */\n listOwnership(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n options?: OperationOptions,\n ): Promise<PartitionOwnership[]>;\n /**\n * Called to claim ownership of a list of partitions. This will return the list of partitions that were owned\n * successfully.\n *\n * @param partitionOwnership - The list of partition ownership this instance is claiming to own.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n * @returns A list of partitions this instance successfully claimed ownership.\n */\n claimOwnership(\n partitionOwnership: PartitionOwnership[],\n options?: OperationOptions,\n ): Promise<PartitionOwnership[]>;\n\n /**\n * Updates the checkpoint in the data store for a partition.\n *\n * @param checkpoint - The checkpoint.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n */\n updateCheckpoint(checkpoint: Checkpoint, options?: OperationOptions): Promise<void>;\n\n /**\n * Lists all the checkpoints in a data store for a given namespace, eventhub and consumer group.\n *\n * @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net.\n * @param eventHubName - The event hub name.\n * @param consumerGroup - The consumer group name.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n * @returns A list of checkpoints for a given namespace, eventhub, and consumer group.\n */\n listCheckpoints(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n options?: OperationOptions,\n ): Promise<Checkpoint[]>;\n}\n\n/**\n * A set of options to pass to the constructor of `EventProcessor`.\n * You can specify\n * - `maxBatchSize`: The max size of the batch of events passed each time to user code for processing.\n * - `maxWaitTimeInSeconds`: 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 * Example usage with default values:\n * ```ts\n * {\n * maxBatchSize: 1,\n * maxWaitTimeInSeconds: 60,\n * }\n * ```\n * @internal\n */\nexport interface FullEventProcessorOptions extends CommonEventProcessorOptions {\n /**\n * An optional pump manager to use, rather than instantiating one internally\n * @internal\n */\n pumpManager?: PumpManager;\n /**\n * The amount of time between load balancing attempts.\n */\n loopIntervalInMs: number;\n /**\n * A specific partition to target.\n */\n processingTarget?: string;\n}\n\n/**\n * Event Processor based applications consist of one or more instances of EventProcessor which have been\n * configured to consume events from the same Event Hub and consumer group. They balance the\n * workload across different instances by distributing the partitions to be processed among themselves.\n * They also allow the user to track progress when events are processed using checkpoints.\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 * @internal\n */\nexport class EventProcessor {\n private _processorOptions: FullEventProcessorOptions;\n private _pumpManager: PumpManager;\n private _id: string;\n private _isRunning: boolean = false;\n private _loopTask?: PromiseLike<void>;\n private _abortController?: AbortController;\n /**\n * A specific partition to target.\n */\n private _processingTarget?: string;\n /**\n * Determines which partitions to claim as part of load balancing.\n */\n private _loadBalancingStrategy: LoadBalancingStrategy;\n /**\n * The amount of time between load balancing attempts.\n */\n private _loopIntervalInMs: number;\n private _eventHubName: string;\n private _fullyQualifiedNamespace: string;\n\n /**\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param eventHubClient - An instance of `EventHubClient` that was created for the Event Hub instance.\n * @param PartitionProcessorClass - A user-provided class that extends the `PartitionProcessor` class.\n * This class will be responsible for processing and checkpointing events.\n * @param checkpointStore - An instance of `CheckpointStore`. See @azure/eventhubs-checkpointstore-blob for an implementation.\n * For production, choose an implementation that will store checkpoints and partition ownership details to a durable store.\n * @param options - A set of options to configure the Event Processor\n * - `maxBatchSize` : The max size of the batch of events passed each time to user code for processing.\n * - `maxWaitTimeInSeconds` : 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 constructor(\n private _consumerGroup: string,\n private _context: ConnectionContext,\n private _subscriptionEventHandlers: SubscriptionEventHandlers,\n private _checkpointStore: CheckpointStore,\n options: FullEventProcessorOptions,\n ) {\n if (options.ownerId) {\n this._id = options.ownerId;\n logger.verbose(`Starting event processor with ID ${this._id}`);\n } else {\n this._id = getRandomName();\n logger.verbose(`Starting event processor with autogenerated ID ${this._id}`);\n }\n\n this._eventHubName = this._context.config.entityPath;\n this._fullyQualifiedNamespace = this._context.config.host;\n this._processorOptions = options;\n this._pumpManager =\n options.pumpManager || new PumpManagerImpl(this._id, this._processorOptions);\n this._processingTarget = options.processingTarget;\n this._loopIntervalInMs = options.loopIntervalInMs;\n this._loadBalancingStrategy = options.loadBalancingStrategy;\n }\n\n /**\n * The unique identifier for the EventProcessor.\n */\n get id(): string {\n return this._id;\n }\n\n private _createPartitionOwnershipRequest(\n partitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIdToClaim: string,\n ): PartitionOwnership {\n const previousPartitionOwnership = partitionOwnershipMap.get(partitionIdToClaim);\n const partitionOwnership: PartitionOwnership = {\n ownerId: this._id,\n partitionId: partitionIdToClaim,\n fullyQualifiedNamespace: this._fullyQualifiedNamespace,\n consumerGroup: this._consumerGroup,\n eventHubName: this._eventHubName,\n etag: previousPartitionOwnership ? previousPartitionOwnership.etag : undefined,\n };\n\n return partitionOwnership;\n }\n\n /*\n * Claim ownership of the given partition if it's available\n */\n private async _claimOwnership(\n ownershipRequest: PartitionOwnership,\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n if (abortSignal.aborted) {\n logger.verbose(\n `[${this._id}] Subscription was closed before claiming ownership of ${ownershipRequest.partitionId}.`,\n );\n return;\n }\n logger.info(\n `[${this._id}] Attempting to claim ownership of partition ${ownershipRequest.partitionId}.`,\n );\n try {\n const claimedOwnerships = await this._checkpointStore.claimOwnership([ownershipRequest]);\n\n // can happen if the partition was claimed out from underneath us - we shouldn't\n // attempt to spin up a processor.\n if (!claimedOwnerships.length) {\n return;\n }\n\n logger.info(\n `[${this._id}] Successfully claimed ownership of partition ${ownershipRequest.partitionId}.`,\n );\n\n await this._startPump(ownershipRequest.partitionId, abortSignal);\n } catch (err: any) {\n logger.warning(\n `[${this._id}] Failed to claim ownership of partition ${ownershipRequest.partitionId}`,\n );\n logErrorStackTrace(err);\n await this._handleSubscriptionError(err);\n }\n }\n\n private async _startPump(partitionId: string, abortSignal: AbortSignalLike): Promise<void> {\n if (abortSignal.aborted) {\n logger.verbose(\n `[${this._id}] The subscription was closed before starting to read from ${partitionId}.`,\n );\n return;\n }\n\n if (this._pumpManager.isReceivingFromPartition(partitionId)) {\n logger.verbose(\n `[${this._id}] There is already an active partitionPump for partition \"${partitionId}\", skipping pump creation.`,\n );\n return;\n }\n\n logger.verbose(\n `[${this._id}] [${partitionId}] Calling user-provided PartitionProcessorFactory.`,\n );\n\n const partitionProcessor = new PartitionProcessor(\n this._subscriptionEventHandlers,\n this._checkpointStore,\n {\n fullyQualifiedNamespace: this._fullyQualifiedNamespace,\n eventHubName: this._eventHubName,\n consumerGroup: this._consumerGroup,\n partitionId: partitionId,\n eventProcessorId: this._id,\n },\n );\n\n const eventPosition = await this._getStartingPosition(partitionId);\n await this._pumpManager.createPump(\n eventPosition,\n this._context,\n partitionProcessor,\n abortSignal,\n );\n\n logger.verbose(`[${this._id}] PartitionPump created successfully.`);\n }\n\n private async _getStartingPosition(partitionIdToClaim: string): Promise<EventPosition> {\n const availableCheckpoints = await this._checkpointStore.listCheckpoints(\n this._fullyQualifiedNamespace,\n this._eventHubName,\n this._consumerGroup,\n );\n\n const validCheckpoints = availableCheckpoints.filter(\n (chk) => chk.partitionId === partitionIdToClaim,\n );\n\n if (validCheckpoints.length > 0) {\n return { offset: validCheckpoints[0].offset };\n }\n\n logger.verbose(\n `No checkpoint found for partition ${partitionIdToClaim}. Looking for fallback.`,\n );\n return getStartPosition(partitionIdToClaim, this._processorOptions.startPosition);\n }\n\n private async _runLoopForSinglePartition(\n partitionId: string,\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n while (!abortSignal.aborted) {\n try {\n await this._startPump(partitionId, abortSignal);\n } catch (err: any) {\n logger.warning(\n `[${this._id}] An error occurred within the EventProcessor loop: ${err?.name}: ${err?.message}`,\n );\n logErrorStackTrace(err);\n await this._handleSubscriptionError(err);\n } finally {\n // sleep for some time after which we can attempt to create a pump again.\n logger.verbose(\n `[${this._id}] Pausing the EventProcessor loop for ${this._loopIntervalInMs} ms.`,\n );\n // swallow errors from delay since it's fine for delay to exit early\n await delayWithoutThrow(this._loopIntervalInMs, abortSignal);\n }\n }\n this._isRunning = false;\n }\n\n /**\n * Every loop to this method will result in this EventProcessor owning at most one new partition.\n *\n * The load is considered balanced when no active EventProcessor owns 2 partitions more than any other active\n * EventProcessor. Given that each invocation to this method results in ownership claim of at most one partition,\n * this algorithm converges gradually towards a steady state.\n *\n * When a new partition is claimed, this method is also responsible for starting a partition pump that creates an\n * EventHubConsumer for processing events from that partition.\n */\n private async _runLoopWithLoadBalancing(\n loadBalancingStrategy: LoadBalancingStrategy,\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n let cancelLoopResolver;\n // This provides a mechanism for exiting the loop early\n // if the subscription has had `close` called.\n const cancelLoopPromise = new Promise<void>((resolve) => {\n cancelLoopResolver = resolve;\n if (abortSignal.aborted) {\n resolve();\n return;\n }\n\n abortSignal.addEventListener(\"abort\", resolve);\n });\n\n // Periodically check if any partitions need to be claimed and claim them.\n while (!abortSignal.aborted) {\n const iterationStartTimeInMs = Date.now();\n try {\n const { partitionIds } = await this._context.managementSession!.getEventHubProperties({\n abortSignal,\n });\n await this._performLoadBalancing(loadBalancingStrategy, partitionIds, abortSignal);\n } catch (err: any) {\n logger.warning(\n `[${this._id}] An error occurred within the EventProcessor loop: ${err?.name}: ${err?.message}`,\n );\n logErrorStackTrace(err);\n // Protect against the scenario where the user awaits on subscription.close() from inside processError.\n await Promise.race([this._handleSubscriptionError(err), cancelLoopPromise]);\n } finally {\n // Sleep for some time, then continue the loop.\n const iterationDeltaInMs = Date.now() - iterationStartTimeInMs;\n const delayDurationInMs = Math.max(this._loopIntervalInMs - iterationDeltaInMs, 0);\n logger.verbose(\n `[${this._id}] Pausing the EventProcessor loop for ${delayDurationInMs} ms.`,\n );\n // Swallow the error since it's fine to exit early from the delay.\n await delayWithoutThrow(delayDurationInMs, abortSignal);\n }\n }\n\n if (cancelLoopResolver) {\n abortSignal.removeEventListener(\"abort\", cancelLoopResolver);\n }\n this._isRunning = false;\n }\n\n private async _performLoadBalancing(\n loadBalancingStrategy: LoadBalancingStrategy,\n partitionIds: string[],\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n if (abortSignal.aborted) throw new AbortError(StandardAbortMessage);\n\n // Retrieve current partition ownership details from the datastore.\n const partitionOwnership = await this._checkpointStore.listOwnership(\n this._fullyQualifiedNamespace,\n this._eventHubName,\n this._consumerGroup,\n );\n\n if (abortSignal.aborted) throw new AbortError(StandardAbortMessage);\n\n const { partitionOwnershipMap, partitionsToClaim } = computePartitionsToClaim({\n id: this._id,\n isReceivingFromPartition: (partitionId: string) =>\n this._pumpManager.isReceivingFromPartition(partitionId),\n loadBalancingStrategy,\n partitionIds,\n partitionOwnership,\n });\n\n for (const partitionToClaim of partitionsToClaim) {\n const partitionOwnershipRequest = this._createPartitionOwnershipRequest(\n partitionOwnershipMap,\n partitionToClaim,\n );\n\n await this._claimOwnership(partitionOwnershipRequest, abortSignal);\n }\n }\n\n /**\n * This is called when there are errors that are not specific to a partition (ex: load balancing)\n */\n private async _handleSubscriptionError(err: Error): Promise<void> {\n // filter out any internal \"expected\" errors\n if (err.name === \"AbortError\") {\n return;\n }\n\n if (this._subscriptionEventHandlers.processError) {\n try {\n await this._subscriptionEventHandlers.processError(err, {\n fullyQualifiedNamespace: this._fullyQualifiedNamespace,\n eventHubName: this._eventHubName,\n consumerGroup: this._consumerGroup,\n partitionId: \"\",\n updateCheckpoint: async () => {\n /* no-op */\n },\n });\n } catch (errorFromUser: any) {\n logger.verbose(\n `[${this._id}] An error was thrown from the user's processError handler: ${errorFromUser}`,\n );\n }\n }\n }\n\n /**\n * Starts the `EventProcessor`. Based on the number of instances of `EventProcessor` that are running for the\n * same consumer group, the partitions are distributed among these instances to process events.\n *\n * For each partition, the user provided `PartitionProcessor` is instantiated.\n *\n * Subsequent calls to start will be ignored if this event processor is already running.\n * Calling `start()` after `stop()` is called will restart this event processor.\n *\n */\n start(): void {\n if (this._isRunning) {\n logger.verbose(`[${this._id}] Attempted to start an already running EventProcessor.`);\n return;\n }\n\n this._isRunning = true;\n this._abortController = new AbortController();\n logger.verbose(`[${this._id}] Starting an EventProcessor.`);\n\n if (this._processingTarget) {\n logger.verbose(`[${this._id}] Single partition target: ${this._processingTarget}`);\n this._loopTask = this._runLoopForSinglePartition(\n this._processingTarget,\n this._abortController.signal,\n );\n } else {\n logger.verbose(`[${this._id}] Multiple partitions, using load balancer`);\n this._loopTask = this._runLoopWithLoadBalancing(\n this._loadBalancingStrategy,\n this._abortController.signal,\n );\n }\n }\n\n isRunning(): boolean {\n return this._isRunning;\n }\n\n /**\n * Stops processing events for all partitions owned by this event processor.\n * All `PartitionProcessor` will be shutdown and any open resources will be closed.\n *\n * Subsequent calls to stop will be ignored if the event processor is not running.\n *\n */\n async stop(): Promise<void> {\n logger.verbose(`[${this._id}] Stopping an EventProcessor.`);\n // cancel the event processor loop\n this._abortController?.abort();\n\n try {\n // remove all existing pumps\n await this._pumpManager.removeAllPumps(CloseReason.Shutdown);\n\n // waits for the event processor loop to complete\n // will complete immediately if _loopTask is undefined\n if (this._loopTask) {\n await this._loopTask;\n }\n } catch (err: any) {\n logger.verbose(`[${this._id}] An error occurred while stopping the EventProcessor: ${err}`);\n } finally {\n logger.verbose(`[${this._id}] EventProcessor stopped.`);\n }\n\n if (this._processingTarget) {\n logger.verbose(`[${this._id}] No partitions owned, skipping abandoning.`);\n } else {\n await this.abandonPartitionOwnerships();\n }\n }\n\n private async abandonPartitionOwnerships(): Promise<PartitionOwnership[]> {\n logger.verbose(`[${this._id}] Abandoning owned partitions`);\n const allOwnerships = await this._checkpointStore.listOwnership(\n this._fullyQualifiedNamespace,\n this._eventHubName,\n this._consumerGroup,\n );\n const ourOwnerships = allOwnerships.filter((ownership) => ownership.ownerId === this._id);\n // unclaim any partitions that we currently own\n for (const ownership of ourOwnerships) {\n ownership.ownerId = \"\";\n }\n return this._checkpointStore.claimOwnership(ourOwnerships);\n }\n}\n\nfunction isAbandoned(ownership: PartitionOwnership): boolean {\n return ownership.ownerId === \"\";\n}\n\nfunction getStartPosition(\n partitionIdToClaim: string,\n startPositions?: EventPosition | { [partitionId: string]: EventPosition },\n): EventPosition {\n if (startPositions == null) {\n return latestEventPosition;\n }\n\n if (isEventPosition(startPositions)) {\n return startPositions;\n }\n\n const startPosition = (startPositions as { [partitionId: string]: EventPosition })[\n partitionIdToClaim\n ];\n\n if (startPosition == null) {\n return latestEventPosition;\n }\n\n return startPosition;\n}\n\nfunction computePartitionsToClaim(inputs: {\n partitionOwnership: PartitionOwnership[];\n id: string;\n isReceivingFromPartition: (id: string) => boolean;\n loadBalancingStrategy: LoadBalancingStrategy;\n partitionIds: string[];\n}): {\n partitionsToClaim: Set<string>;\n partitionOwnershipMap: Map<string, PartitionOwnership>;\n} {\n const { partitionOwnership, id, isReceivingFromPartition, loadBalancingStrategy, partitionIds } =\n inputs;\n\n const partitionOwnershipMap = new Map<string, PartitionOwnership>();\n const nonAbandonedPartitionOwnershipMap = new Map<string, PartitionOwnership>();\n const partitionsToRenew: string[] = [];\n\n // Separate abandoned ownerships from claimed ownerships.\n // We only want to pass active partition ownerships to the\n // load balancer, but we need to hold onto the abandoned\n // partition ownerships because we need the etag to claim them.\n for (const ownership of partitionOwnership) {\n partitionOwnershipMap.set(ownership.partitionId, ownership);\n if (!isAbandoned(ownership)) {\n nonAbandonedPartitionOwnershipMap.set(ownership.partitionId, ownership);\n }\n if (ownership.ownerId === id && isReceivingFromPartition(ownership.partitionId)) {\n partitionsToRenew.push(ownership.partitionId);\n }\n }\n\n // Pass the list of all the partition ids and the collection of claimed partition ownerships\n // to the load balance strategy.\n // The load balancing strategy only needs to know the full list of partitions,\n // and which of those are currently claimed.\n // Since abandoned partitions are no longer claimed, we exclude them.\n const partitionsToClaim = loadBalancingStrategy.getPartitionsToClaim(\n id,\n nonAbandonedPartitionOwnershipMap,\n partitionIds,\n );\n partitionsToClaim.push(...partitionsToRenew);\n\n return {\n partitionsToClaim: new Set(partitionsToClaim),\n partitionOwnershipMap,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"eventProcessor.js","sourceRoot":"","sources":["../../src/eventProcessor.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAqJxD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAsBzB;;;;;;;;;;;OAWG;IACH,YACU,cAAsB,EACtB,QAA2B,EAC3B,0BAAqD,EACrD,gBAAiC,EACzC,OAAkC;QAJ1B,mBAAc,GAAd,cAAc,CAAQ;QACtB,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,+BAA0B,GAA1B,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\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AbortError } from \"@azure/abort-controller\";\nimport type { Checkpoint } from \"./partitionProcessor.js\";\nimport { PartitionProcessor } from \"./partitionProcessor.js\";\nimport type { EventPosition } from \"./eventPosition.js\";\nimport { isEventPosition, latestEventPosition } from \"./eventPosition.js\";\nimport type { PumpManager } from \"./pumpManager.js\";\nimport { PumpManagerImpl } from \"./pumpManager.js\";\nimport { logErrorStackTrace, logger } from \"./logger.js\";\nimport { CloseReason } from \"./models/public.js\";\nimport type { CommonEventProcessorOptions } from \"./models/private.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { LoadBalancingStrategy } from \"./loadBalancerStrategies/loadBalancingStrategy.js\";\nimport type { OperationOptions } from \"./util/operationOptions.js\";\nimport type { SubscriptionEventHandlers } from \"./eventHubConsumerClientModels.js\";\nimport { delayWithoutThrow } from \"./util/delayWithoutThrow.js\";\nimport { getRandomName } from \"./util/utils.js\";\nimport { StandardAbortMessage } from \"@azure/core-amqp\";\n\n/**\n * An interface representing the details on which instance of a `EventProcessor` owns processing\n * of a given partition from a consumer group of an Event Hub instance.\n *\n * **Note**: This is used internally by the `EventProcessor` and user never has to create it directly.\n */\nexport interface PartitionOwnership {\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 * The unique identifier of the event processor.\n */\n ownerId: string;\n /**\n * The last modified time.\n */\n lastModifiedTimeInMs?: number;\n /**\n * The unique identifier for the operation.\n */\n etag?: string;\n}\n\n/**\n * A checkpoint store stores and retrieves partition ownership information and checkpoint details\n * for each partition in a given consumer group of an event hub instance.\n *\n * Users are not meant to implement an `CheckpointStore`.\n * Users are expected to choose existing implementations of this interface, instantiate it, and pass\n * it to the `EventHubConsumerClient` class constructor when instantiating a client.\n * Users are not expected to use any of the methods on a checkpoint store, these are used internally by\n * the client.\n *\n * Implementations of `CheckpointStore` can be found on npm by searching for packages with the prefix @azure/eventhub-checkpointstore-.\n */\nexport interface CheckpointStore {\n /**\n * Called to get the list of all existing partition ownership from the underlying data store. Could return empty\n * results if there are is no existing ownership information.\n *\n * @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net.\n * @param eventHubName - The event hub name.\n * @param consumerGroup - The consumer group name.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n * @returns A list of partition ownership details of all the partitions that have/had an owner.\n */\n listOwnership(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n options?: OperationOptions,\n ): Promise<PartitionOwnership[]>;\n /**\n * Called to claim ownership of a list of partitions. This will return the list of partitions that were owned\n * successfully.\n *\n * @param partitionOwnership - The list of partition ownership this instance is claiming to own.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n * @returns A list of partitions this instance successfully claimed ownership.\n */\n claimOwnership(\n partitionOwnership: PartitionOwnership[],\n options?: OperationOptions,\n ): Promise<PartitionOwnership[]>;\n\n /**\n * Updates the checkpoint in the data store for a partition.\n *\n * @param checkpoint - The checkpoint.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n */\n updateCheckpoint(checkpoint: Checkpoint, options?: OperationOptions): Promise<void>;\n\n /**\n * Lists all the checkpoints in a data store for a given namespace, eventhub and consumer group.\n *\n * @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net.\n * @param eventHubName - The event hub name.\n * @param consumerGroup - The consumer group name.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n * @returns A list of checkpoints for a given namespace, eventhub, and consumer group.\n */\n listCheckpoints(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n options?: OperationOptions,\n ): Promise<Checkpoint[]>;\n}\n\n/**\n * A set of options to pass to the constructor of `EventProcessor`.\n * You can specify\n * - `maxBatchSize`: The max size of the batch of events passed each time to user code for processing.\n * - `maxWaitTimeInSeconds`: 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 * Example usage with default values:\n * ```ts\n * {\n * maxBatchSize: 1,\n * maxWaitTimeInSeconds: 60,\n * }\n * ```\n * @internal\n */\nexport interface FullEventProcessorOptions extends CommonEventProcessorOptions {\n /**\n * An optional pump manager to use, rather than instantiating one internally\n * @internal\n */\n pumpManager?: PumpManager;\n /**\n * The amount of time between load balancing attempts.\n */\n loopIntervalInMs: number;\n /**\n * A specific partition to target.\n */\n processingTarget?: string;\n}\n\n/**\n * Event Processor based applications consist of one or more instances of EventProcessor which have been\n * configured to consume events from the same Event Hub and consumer group. They balance the\n * workload across different instances by distributing the partitions to be processed among themselves.\n * They also allow the user to track progress when events are processed using checkpoints.\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 * @internal\n */\nexport class EventProcessor {\n private _processorOptions: FullEventProcessorOptions;\n private _pumpManager: PumpManager;\n private _id: string;\n private _isRunning: boolean = false;\n private _loopTask?: PromiseLike<void>;\n private _abortController?: AbortController;\n /**\n * A specific partition to target.\n */\n private _processingTarget?: string;\n /**\n * Determines which partitions to claim as part of load balancing.\n */\n private _loadBalancingStrategy: LoadBalancingStrategy;\n /**\n * The amount of time between load balancing attempts.\n */\n private _loopIntervalInMs: number;\n private _eventHubName: string;\n private _fullyQualifiedNamespace: string;\n\n /**\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param eventHubClient - An instance of `EventHubClient` that was created for the Event Hub instance.\n * @param PartitionProcessorClass - A user-provided class that extends the `PartitionProcessor` class.\n * This class will be responsible for processing and checkpointing events.\n * @param checkpointStore - An instance of `CheckpointStore`. See @azure/eventhubs-checkpointstore-blob for an implementation.\n * For production, choose an implementation that will store checkpoints and partition ownership details to a durable store.\n * @param options - A set of options to configure the Event Processor\n * - `maxBatchSize` : The max size of the batch of events passed each time to user code for processing.\n * - `maxWaitTimeInSeconds` : 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 constructor(\n private _consumerGroup: string,\n private _context: ConnectionContext,\n private _subscriptionEventHandlers: SubscriptionEventHandlers,\n private _checkpointStore: CheckpointStore,\n options: FullEventProcessorOptions,\n ) {\n if (options.ownerId) {\n this._id = options.ownerId;\n logger.verbose(`Starting event processor with ID ${this._id}`);\n } else {\n this._id = getRandomName();\n logger.verbose(`Starting event processor with autogenerated ID ${this._id}`);\n }\n\n this._eventHubName = this._context.config.entityPath;\n this._fullyQualifiedNamespace = this._context.config.host;\n this._processorOptions = options;\n this._pumpManager =\n options.pumpManager || new PumpManagerImpl(this._id, this._processorOptions);\n this._processingTarget = options.processingTarget;\n this._loopIntervalInMs = options.loopIntervalInMs;\n this._loadBalancingStrategy = options.loadBalancingStrategy;\n }\n\n /**\n * The unique identifier for the EventProcessor.\n */\n get id(): string {\n return this._id;\n }\n\n private _createPartitionOwnershipRequest(\n partitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIdToClaim: string,\n ): PartitionOwnership {\n const previousPartitionOwnership = partitionOwnershipMap.get(partitionIdToClaim);\n const partitionOwnership: PartitionOwnership = {\n ownerId: this._id,\n partitionId: partitionIdToClaim,\n fullyQualifiedNamespace: this._fullyQualifiedNamespace,\n consumerGroup: this._consumerGroup,\n eventHubName: this._eventHubName,\n etag: previousPartitionOwnership ? previousPartitionOwnership.etag : undefined,\n };\n\n return partitionOwnership;\n }\n\n /*\n * Claim ownership of the given partition if it's available\n */\n private async _claimOwnership(\n ownershipRequest: PartitionOwnership,\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n if (abortSignal.aborted) {\n logger.verbose(\n `[${this._id}] Subscription was closed before claiming ownership of ${ownershipRequest.partitionId}.`,\n );\n return;\n }\n logger.info(\n `[${this._id}] Attempting to claim ownership of partition ${ownershipRequest.partitionId}.`,\n );\n try {\n const claimedOwnerships = await this._checkpointStore.claimOwnership([ownershipRequest]);\n\n // can happen if the partition was claimed out from underneath us - we shouldn't\n // attempt to spin up a processor.\n if (!claimedOwnerships.length) {\n return;\n }\n\n logger.info(\n `[${this._id}] Successfully claimed ownership of partition ${ownershipRequest.partitionId}.`,\n );\n\n await this._startPump(ownershipRequest.partitionId, abortSignal);\n } catch (err: any) {\n logger.warning(\n `[${this._id}] Failed to claim ownership of partition ${ownershipRequest.partitionId}`,\n );\n logErrorStackTrace(err);\n await this._handleSubscriptionError(err);\n }\n }\n\n private async _startPump(partitionId: string, abortSignal: AbortSignalLike): Promise<void> {\n if (abortSignal.aborted) {\n logger.verbose(\n `[${this._id}] The subscription was closed before starting to read from ${partitionId}.`,\n );\n return;\n }\n\n if (this._pumpManager.isReceivingFromPartition(partitionId)) {\n logger.verbose(\n `[${this._id}] There is already an active partitionPump for partition \"${partitionId}\", skipping pump creation.`,\n );\n return;\n }\n\n logger.verbose(\n `[${this._id}] [${partitionId}] Calling user-provided PartitionProcessorFactory.`,\n );\n\n const partitionProcessor = new PartitionProcessor(\n this._subscriptionEventHandlers,\n this._checkpointStore,\n {\n fullyQualifiedNamespace: this._fullyQualifiedNamespace,\n eventHubName: this._eventHubName,\n consumerGroup: this._consumerGroup,\n partitionId: partitionId,\n eventProcessorId: this._id,\n },\n );\n\n const eventPosition = await this._getStartingPosition(partitionId);\n await this._pumpManager.createPump(\n eventPosition,\n this._context,\n partitionProcessor,\n abortSignal,\n );\n\n logger.verbose(`[${this._id}] PartitionPump created successfully.`);\n }\n\n private async _getStartingPosition(partitionIdToClaim: string): Promise<EventPosition> {\n const availableCheckpoints = await this._checkpointStore.listCheckpoints(\n this._fullyQualifiedNamespace,\n this._eventHubName,\n this._consumerGroup,\n );\n\n const validCheckpoints = availableCheckpoints.filter(\n (chk) => chk.partitionId === partitionIdToClaim,\n );\n\n if (validCheckpoints.length > 0) {\n return { offset: validCheckpoints[0].offset };\n }\n\n logger.verbose(\n `No checkpoint found for partition ${partitionIdToClaim}. Looking for fallback.`,\n );\n return getStartPosition(partitionIdToClaim, this._processorOptions.startPosition);\n }\n\n private async _runLoopForSinglePartition(\n partitionId: string,\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n while (!abortSignal.aborted) {\n try {\n await this._startPump(partitionId, abortSignal);\n } catch (err: any) {\n logger.warning(\n `[${this._id}] An error occurred within the EventProcessor loop: ${err?.name}: ${err?.message}`,\n );\n logErrorStackTrace(err);\n await this._handleSubscriptionError(err);\n } finally {\n // sleep for some time after which we can attempt to create a pump again.\n logger.verbose(\n `[${this._id}] Pausing the EventProcessor loop for ${this._loopIntervalInMs} ms.`,\n );\n // swallow errors from delay since it's fine for delay to exit early\n await delayWithoutThrow(this._loopIntervalInMs, abortSignal);\n }\n }\n this._isRunning = false;\n }\n\n /**\n * Every loop to this method will result in this EventProcessor owning at most one new partition.\n *\n * The load is considered balanced when no active EventProcessor owns 2 partitions more than any other active\n * EventProcessor. Given that each invocation to this method results in ownership claim of at most one partition,\n * this algorithm converges gradually towards a steady state.\n *\n * When a new partition is claimed, this method is also responsible for starting a partition pump that creates an\n * EventHubConsumer for processing events from that partition.\n */\n private async _runLoopWithLoadBalancing(\n loadBalancingStrategy: LoadBalancingStrategy,\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n let cancelLoopResolver;\n // This provides a mechanism for exiting the loop early\n // if the subscription has had `close` called.\n const cancelLoopPromise = new Promise<void>((resolve) => {\n cancelLoopResolver = resolve;\n if (abortSignal.aborted) {\n resolve();\n return;\n }\n\n abortSignal.addEventListener(\"abort\", resolve);\n });\n\n // Periodically check if any partitions need to be claimed and claim them.\n while (!abortSignal.aborted) {\n const iterationStartTimeInMs = Date.now();\n try {\n const { partitionIds } = await this._context.managementSession!.getEventHubProperties({\n abortSignal,\n });\n await this._performLoadBalancing(loadBalancingStrategy, partitionIds, abortSignal);\n } catch (err: any) {\n logger.warning(\n `[${this._id}] An error occurred within the EventProcessor loop: ${err?.name}: ${err?.message}`,\n );\n logErrorStackTrace(err);\n // Protect against the scenario where the user awaits on subscription.close() from inside processError.\n await Promise.race([this._handleSubscriptionError(err), cancelLoopPromise]);\n } finally {\n // Sleep for some time, then continue the loop.\n const iterationDeltaInMs = Date.now() - iterationStartTimeInMs;\n const delayDurationInMs = Math.max(this._loopIntervalInMs - iterationDeltaInMs, 0);\n logger.verbose(\n `[${this._id}] Pausing the EventProcessor loop for ${delayDurationInMs} ms.`,\n );\n // Swallow the error since it's fine to exit early from the delay.\n await delayWithoutThrow(delayDurationInMs, abortSignal);\n }\n }\n\n if (cancelLoopResolver) {\n abortSignal.removeEventListener(\"abort\", cancelLoopResolver);\n }\n this._isRunning = false;\n }\n\n private async _performLoadBalancing(\n loadBalancingStrategy: LoadBalancingStrategy,\n partitionIds: string[],\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n if (abortSignal.aborted) throw new AbortError(StandardAbortMessage);\n\n // Retrieve current partition ownership details from the datastore.\n const partitionOwnership = await this._checkpointStore.listOwnership(\n this._fullyQualifiedNamespace,\n this._eventHubName,\n this._consumerGroup,\n );\n\n if (abortSignal.aborted) throw new AbortError(StandardAbortMessage);\n\n const { partitionOwnershipMap, partitionsToClaim } = computePartitionsToClaim({\n id: this._id,\n isReceivingFromPartition: (partitionId: string) =>\n this._pumpManager.isReceivingFromPartition(partitionId),\n loadBalancingStrategy,\n partitionIds,\n partitionOwnership,\n });\n\n for (const partitionToClaim of partitionsToClaim) {\n const partitionOwnershipRequest = this._createPartitionOwnershipRequest(\n partitionOwnershipMap,\n partitionToClaim,\n );\n\n await this._claimOwnership(partitionOwnershipRequest, abortSignal);\n }\n }\n\n /**\n * This is called when there are errors that are not specific to a partition (ex: load balancing)\n */\n private async _handleSubscriptionError(err: Error): Promise<void> {\n // filter out any internal \"expected\" errors\n if (err.name === \"AbortError\") {\n return;\n }\n\n if (this._subscriptionEventHandlers.processError) {\n try {\n await this._subscriptionEventHandlers.processError(err, {\n fullyQualifiedNamespace: this._fullyQualifiedNamespace,\n eventHubName: this._eventHubName,\n consumerGroup: this._consumerGroup,\n partitionId: \"\",\n updateCheckpoint: async () => {\n /* no-op */\n },\n });\n } catch (errorFromUser: any) {\n logger.verbose(\n `[${this._id}] An error was thrown from the user's processError handler: ${errorFromUser}`,\n );\n }\n }\n }\n\n /**\n * Starts the `EventProcessor`. Based on the number of instances of `EventProcessor` that are running for the\n * same consumer group, the partitions are distributed among these instances to process events.\n *\n * For each partition, the user provided `PartitionProcessor` is instantiated.\n *\n * Subsequent calls to start will be ignored if this event processor is already running.\n * Calling `start()` after `stop()` is called will restart this event processor.\n *\n */\n start(): void {\n if (this._isRunning) {\n logger.verbose(`[${this._id}] Attempted to start an already running EventProcessor.`);\n return;\n }\n\n this._isRunning = true;\n this._abortController = new AbortController();\n logger.verbose(`[${this._id}] Starting an EventProcessor.`);\n\n if (this._processingTarget) {\n logger.verbose(`[${this._id}] Single partition target: ${this._processingTarget}`);\n this._loopTask = this._runLoopForSinglePartition(\n this._processingTarget,\n this._abortController.signal,\n );\n } else {\n logger.verbose(`[${this._id}] Multiple partitions, using load balancer`);\n this._loopTask = this._runLoopWithLoadBalancing(\n this._loadBalancingStrategy,\n this._abortController.signal,\n );\n }\n }\n\n isRunning(): boolean {\n return this._isRunning;\n }\n\n /**\n * Stops processing events for all partitions owned by this event processor.\n * All `PartitionProcessor` will be shutdown and any open resources will be closed.\n *\n * Subsequent calls to stop will be ignored if the event processor is not running.\n *\n */\n async stop(): Promise<void> {\n logger.verbose(`[${this._id}] Stopping an EventProcessor.`);\n // cancel the event processor loop\n this._abortController?.abort();\n\n try {\n // remove all existing pumps\n await this._pumpManager.removeAllPumps(CloseReason.Shutdown);\n\n // waits for the event processor loop to complete\n // will complete immediately if _loopTask is undefined\n if (this._loopTask) {\n await this._loopTask;\n }\n } catch (err: any) {\n logger.verbose(`[${this._id}] An error occurred while stopping the EventProcessor: ${err}`);\n } finally {\n logger.verbose(`[${this._id}] EventProcessor stopped.`);\n }\n\n if (this._processingTarget) {\n logger.verbose(`[${this._id}] No partitions owned, skipping abandoning.`);\n } else {\n await this.abandonPartitionOwnerships();\n }\n }\n\n private async abandonPartitionOwnerships(): Promise<PartitionOwnership[]> {\n logger.verbose(`[${this._id}] Abandoning owned partitions`);\n const allOwnerships = await this._checkpointStore.listOwnership(\n this._fullyQualifiedNamespace,\n this._eventHubName,\n this._consumerGroup,\n );\n const ourOwnerships = allOwnerships.filter((ownership) => ownership.ownerId === this._id);\n // unclaim any partitions that we currently own\n for (const ownership of ourOwnerships) {\n ownership.ownerId = \"\";\n }\n return this._checkpointStore.claimOwnership(ourOwnerships);\n }\n}\n\nfunction isAbandoned(ownership: PartitionOwnership): boolean {\n return ownership.ownerId === \"\";\n}\n\nfunction getStartPosition(\n partitionIdToClaim: string,\n startPositions?: EventPosition | { [partitionId: string]: EventPosition },\n): EventPosition {\n if (startPositions == null) {\n return latestEventPosition;\n }\n\n if (isEventPosition(startPositions)) {\n return startPositions;\n }\n\n const startPosition = (startPositions as { [partitionId: string]: EventPosition })[\n partitionIdToClaim\n ];\n\n if (startPosition == null) {\n return latestEventPosition;\n }\n\n return startPosition;\n}\n\nfunction computePartitionsToClaim(inputs: {\n partitionOwnership: PartitionOwnership[];\n id: string;\n isReceivingFromPartition: (id: string) => boolean;\n loadBalancingStrategy: LoadBalancingStrategy;\n partitionIds: string[];\n}): {\n partitionsToClaim: Set<string>;\n partitionOwnershipMap: Map<string, PartitionOwnership>;\n} {\n const { partitionOwnership, id, isReceivingFromPartition, loadBalancingStrategy, partitionIds } =\n inputs;\n\n const partitionOwnershipMap = new Map<string, PartitionOwnership>();\n const nonAbandonedPartitionOwnershipMap = new Map<string, PartitionOwnership>();\n const partitionsToRenew: string[] = [];\n\n // Separate abandoned ownerships from claimed ownerships.\n // We only want to pass active partition ownerships to the\n // load balancer, but we need to hold onto the abandoned\n // partition ownerships because we need the etag to claim them.\n for (const ownership of partitionOwnership) {\n partitionOwnershipMap.set(ownership.partitionId, ownership);\n if (!isAbandoned(ownership)) {\n nonAbandonedPartitionOwnershipMap.set(ownership.partitionId, ownership);\n }\n if (ownership.ownerId === id && isReceivingFromPartition(ownership.partitionId)) {\n partitionsToRenew.push(ownership.partitionId);\n }\n }\n\n // Pass the list of all the partition ids and the collection of claimed partition ownerships\n // to the load balance strategy.\n // The load balancing strategy only needs to know the full list of partitions,\n // and which of those are currently claimed.\n // Since abandoned partitions are no longer claimed, we exclude them.\n const partitionsToClaim = loadBalancingStrategy.getPartitionsToClaim(\n id,\n nonAbandonedPartitionOwnershipMap,\n partitionIds,\n );\n partitionsToClaim.push(...partitionsToRenew);\n\n return {\n partitionsToClaim: new Set(partitionsToClaim),\n partitionOwnershipMap,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"awaitableQueue.d.ts","sourceRoot":"","sources":["../../../src/impl/awaitableQueue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"awaitableQueue.d.ts","sourceRoot":"","sources":["../../../src/impl/awaitableQueue.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD;;;;;;;GAOG;AACH,qBAAa,cAAc,CAAC,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAM;IAE7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiC;;IAMrD,IAAI,IAAI,MAAM;IAIrB;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC;IAYhD;;OAEG;IACI,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAM1B,OAAO,CAAC,gBAAgB;CASzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"awaitableQueue.js","sourceRoot":"","sources":["../../../src/impl/awaitableQueue.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"awaitableQueue.js","sourceRoot":"","sources":["../../../src/impl/awaitableQueue.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IAKzB;QAFiB,eAAU,GAA8B,EAAE,CAAC;QAG1D,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAsB;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QAED,OAAO,sBAAsB,CAAI,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,kCACtE,OAAO,KACV,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAC/C,CAAC;IACL,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,IAAO;QACjB,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,IAAO;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,KAAK,CAAC;QACf,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortOptions } from \"@azure/core-util\";\nimport { createAbortablePromise } from \"@azure/core-util\";\n\n/**\n * `AwaitableQueue` stores items in the order that they are received.\n *\n * This differs from ordinary Queues in that `shift` returns a Promise for a value.\n * This allows a consumer of the queue to request an item that the queue does not yet have.\n *\n * @internal\n */\nexport class AwaitableQueue<T> {\n private readonly _items: T[];\n\n private readonly _resolvers: Array<(value: T) => void> = [];\n\n constructor() {\n this._items = [];\n }\n\n public size(): number {\n return this._items.length;\n }\n\n /**\n * Returns a Promise that will resolve with the next item in the queue.\n */\n public shift(options?: AbortOptions): Promise<T> {\n const item = this._items.shift();\n if (typeof item !== \"undefined\") {\n return Promise.resolve(item);\n }\n\n return createAbortablePromise<T>((resolve) => this._resolvers.push(resolve), {\n ...options,\n cleanupBeforeAbort: () => this._resolvers.pop(),\n });\n }\n\n /**\n * Appends new item to the queue.\n */\n public push(item: T): void {\n if (!this._resolveNextItem(item)) {\n this._items.push(item);\n }\n }\n\n private _resolveNextItem(item: T) {\n const resolver = this._resolvers.shift();\n if (!resolver) {\n return false;\n }\n\n resolver(item);\n return true;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CheckpointStore, PartitionOwnership } from "./eventProcessor.js";
|
|
2
|
-
import { Checkpoint } from "./partitionProcessor.js";
|
|
1
|
+
import type { CheckpointStore, PartitionOwnership } from "./eventProcessor.js";
|
|
2
|
+
import type { Checkpoint } from "./partitionProcessor.js";
|
|
3
3
|
/**
|
|
4
4
|
* The `EventProcessor` relies on a `CheckpointStore` to store checkpoints and handle partition
|
|
5
5
|
* ownerships. `InMemoryCheckpointStore` is simple partition manager that stores checkpoints and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inMemoryCheckpointStore.d.ts","sourceRoot":"","sources":["../../src/inMemoryCheckpointStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"inMemoryCheckpointStore.d.ts","sourceRoot":"","sources":["../../src/inMemoryCheckpointStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAI1D;;;;;;;;;;GAUG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAC7D,OAAO,CAAC,sBAAsB,CAA8C;IAC5E,OAAO,CAAC,qBAAqB,CAAmD;IAEhF;;;;;;;;;OASG;IACG,aAAa,CACjB,wBAAwB,EAAE,MAAM,EAChC,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAUhC;;;;;;OAMG;IACG,cAAc,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAuB7F;;;;OAIG;IACG,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BvD,eAAe,CACnB,uBAAuB,EAAE,MAAM,EAC/B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,EAAE,CAAC;CAiBzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inMemoryCheckpointStore.js","sourceRoot":"","sources":["../../src/inMemoryCheckpointStore.ts"],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,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,WAAW,GAAG,EAAE,CAAC;QAEvB,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,WAAW,CAAC,IAAI,mBAAM,KAAK,EAAG,CAAC;QACjC,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CheckpointStore, PartitionOwnership } from \"./eventProcessor.js\";\nimport { Checkpoint } from \"./partitionProcessor.js\";\nimport { throwTypeErrorIfParameterMissing } from \"./util/error.js\";\nimport { getRandomName } from \"./util/utils.js\";\n\n/**\n * The `EventProcessor` relies on a `CheckpointStore` to store checkpoints and handle partition\n * ownerships. `InMemoryCheckpointStore` is simple partition manager that stores checkpoints and\n * partition ownerships in memory of your program.\n *\n * You can use the `InMemoryCheckpointStore` to get started with using the `EventProcessor`.\n * But in production, you should choose an implementation of the `CheckpointStore` interface that will\n * store the checkpoints and partition ownerships to a durable store instead.\n *\n * @internal\n */\nexport class InMemoryCheckpointStore implements CheckpointStore {\n private _partitionOwnershipMap: Map<string, PartitionOwnership> = new Map();\n private _committedCheckpoints: Map<string, Map<string, Checkpoint>> = new Map();\n\n /**\n * Get the list of all existing partition ownership from the underlying data store. Could return empty\n * results if there are is no existing ownership information.\n *\n * @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net.\n * @param eventHubName - The event hub name.\n * @param consumerGroup - The consumer group name.\n * @returns Partition ownership details of all the partitions that have/had an owner..\n */\n async listOwnership(\n _fullyQualifiedNamespace: string,\n _eventHubName: string,\n _consumerGroup: string,\n ): Promise<PartitionOwnership[]> {\n const ownerships = [];\n\n for (const value of this._partitionOwnershipMap.values()) {\n ownerships.push({ ...value });\n }\n\n return ownerships;\n }\n\n /**\n * Claim ownership of a list of partitions. This will return the list of partitions that were owned\n * successfully.\n *\n * @param partitionOwnership - The list of partition ownership this instance is claiming to own.\n * @returns A list partitions this instance successfully claimed ownership.\n */\n async claimOwnership(partitionOwnership: PartitionOwnership[]): Promise<PartitionOwnership[]> {\n const claimedOwnerships = [];\n\n for (const ownership of partitionOwnership) {\n if (\n !this._partitionOwnershipMap.has(ownership.partitionId) ||\n this._partitionOwnershipMap.get(ownership.partitionId)!.etag === ownership.etag\n ) {\n const date = new Date();\n\n const newOwnership = {\n ...ownership,\n etag: getRandomName(),\n lastModifiedTimeInMs: date.getTime(),\n };\n\n this._partitionOwnershipMap.set(newOwnership.partitionId, newOwnership);\n claimedOwnerships.push(newOwnership);\n }\n }\n return claimedOwnerships;\n }\n\n /**\n * Updates the checkpoint in the data store for a partition.\n *\n * @param checkpoint - The checkpoint.\n */\n async updateCheckpoint(checkpoint: Checkpoint): Promise<void> {\n throwTypeErrorIfParameterMissing(\n \"\",\n \"updateCheckpoint\",\n \"sequenceNumber\",\n checkpoint.sequenceNumber,\n );\n throwTypeErrorIfParameterMissing(\"\", \"updateCheckpoint\", \"offset\", checkpoint.offset);\n\n checkpoint = { ...checkpoint };\n\n const partitionOwnership = this._partitionOwnershipMap.get(checkpoint.partitionId);\n if (partitionOwnership) {\n partitionOwnership.etag = getRandomName();\n\n const key = `${checkpoint.fullyQualifiedNamespace}:${checkpoint.eventHubName}:${checkpoint.consumerGroup}`;\n let partitionMap = this._committedCheckpoints.get(key);\n\n if (partitionMap == null) {\n partitionMap = new Map();\n this._committedCheckpoints.set(key, partitionMap);\n }\n\n partitionMap.set(checkpoint.partitionId, checkpoint);\n }\n }\n\n async listCheckpoints(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n ): Promise<Checkpoint[]> {\n const key = `${fullyQualifiedNamespace}:${eventHubName}:${consumerGroup}`;\n\n const partitionMap = this._committedCheckpoints.get(key);\n\n if (partitionMap == null) {\n return [];\n }\n\n const checkpoints = [];\n\n for (const value of partitionMap.values()) {\n checkpoints.push({ ...value });\n }\n\n return checkpoints;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"inMemoryCheckpointStore.js","sourceRoot":"","sources":["../../src/inMemoryCheckpointStore.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,uBAAuB;IAApC;QACU,2BAAsB,GAAoC,IAAI,GAAG,EAAE,CAAC;QACpE,0BAAqB,GAAyC,IAAI,GAAG,EAAE,CAAC;IA6GlF,CAAC;IA3GC;;;;;;;;;OASG;IACH,KAAK,CAAC,aAAa,CACjB,wBAAgC,EAChC,aAAqB,EACrB,cAAsB;QAEtB,MAAM,UAAU,GAAG,EAAE,CAAC;QAEtB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,CAAC;YACzD,UAAU,CAAC,IAAI,mBAAM,KAAK,EAAG,CAAC;QAChC,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAAC,kBAAwC;QAC3D,MAAM,iBAAiB,GAAG,EAAE,CAAC;QAE7B,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;YAC3C,IACE,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC;gBACvD,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAE,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAC/E,CAAC;gBACD,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;gBAExB,MAAM,YAAY,mCACb,SAAS,KACZ,IAAI,EAAE,aAAa,EAAE,EACrB,oBAAoB,E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AM,GAAG,GAAG,GAAG,uBAAuB,IAAI,YAAY,IAAI,aAAa,EAAE,CAAC;QAE1E,MAAM,YAAY,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEzD,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,WAAW,GAAG,EAAE,CAAC;QAEvB,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,WAAW,CAAC,IAAI,mBAAM,KAAK,EAAG,CAAC;QACjC,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CheckpointStore, PartitionOwnership } from \"./eventProcessor.js\";\nimport type { Checkpoint } from \"./partitionProcessor.js\";\nimport { throwTypeErrorIfParameterMissing } from \"./util/error.js\";\nimport { getRandomName } from \"./util/utils.js\";\n\n/**\n * The `EventProcessor` relies on a `CheckpointStore` to store checkpoints and handle partition\n * ownerships. `InMemoryCheckpointStore` is simple partition manager that stores checkpoints and\n * partition ownerships in memory of your program.\n *\n * You can use the `InMemoryCheckpointStore` to get started with using the `EventProcessor`.\n * But in production, you should choose an implementation of the `CheckpointStore` interface that will\n * store the checkpoints and partition ownerships to a durable store instead.\n *\n * @internal\n */\nexport class InMemoryCheckpointStore implements CheckpointStore {\n private _partitionOwnershipMap: Map<string, PartitionOwnership> = new Map();\n private _committedCheckpoints: Map<string, Map<string, Checkpoint>> = new Map();\n\n /**\n * Get the list of all existing partition ownership from the underlying data store. Could return empty\n * results if there are is no existing ownership information.\n *\n * @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net.\n * @param eventHubName - The event hub name.\n * @param consumerGroup - The consumer group name.\n * @returns Partition ownership details of all the partitions that have/had an owner..\n */\n async listOwnership(\n _fullyQualifiedNamespace: string,\n _eventHubName: string,\n _consumerGroup: string,\n ): Promise<PartitionOwnership[]> {\n const ownerships = [];\n\n for (const value of this._partitionOwnershipMap.values()) {\n ownerships.push({ ...value });\n }\n\n return ownerships;\n }\n\n /**\n * Claim ownership of a list of partitions. This will return the list of partitions that were owned\n * successfully.\n *\n * @param partitionOwnership - The list of partition ownership this instance is claiming to own.\n * @returns A list partitions this instance successfully claimed ownership.\n */\n async claimOwnership(partitionOwnership: PartitionOwnership[]): Promise<PartitionOwnership[]> {\n const claimedOwnerships = [];\n\n for (const ownership of partitionOwnership) {\n if (\n !this._partitionOwnershipMap.has(ownership.partitionId) ||\n this._partitionOwnershipMap.get(ownership.partitionId)!.etag === ownership.etag\n ) {\n const date = new Date();\n\n const newOwnership = {\n ...ownership,\n etag: getRandomName(),\n lastModifiedTimeInMs: date.getTime(),\n };\n\n this._partitionOwnershipMap.set(newOwnership.partitionId, newOwnership);\n claimedOwnerships.push(newOwnership);\n }\n }\n return claimedOwnerships;\n }\n\n /**\n * Updates the checkpoint in the data store for a partition.\n *\n * @param checkpoint - The checkpoint.\n */\n async updateCheckpoint(checkpoint: Checkpoint): Promise<void> {\n throwTypeErrorIfParameterMissing(\n \"\",\n \"updateCheckpoint\",\n \"sequenceNumber\",\n checkpoint.sequenceNumber,\n );\n throwTypeErrorIfParameterMissing(\"\", \"updateCheckpoint\", \"offset\", checkpoint.offset);\n\n checkpoint = { ...checkpoint };\n\n const partitionOwnership = this._partitionOwnershipMap.get(checkpoint.partitionId);\n if (partitionOwnership) {\n partitionOwnership.etag = getRandomName();\n\n const key = `${checkpoint.fullyQualifiedNamespace}:${checkpoint.eventHubName}:${checkpoint.consumerGroup}`;\n let partitionMap = this._committedCheckpoints.get(key);\n\n if (partitionMap == null) {\n partitionMap = new Map();\n this._committedCheckpoints.set(key, partitionMap);\n }\n\n partitionMap.set(checkpoint.partitionId, checkpoint);\n }\n }\n\n async listCheckpoints(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n ): Promise<Checkpoint[]> {\n const key = `${fullyQualifiedNamespace}:${eventHubName}:${consumerGroup}`;\n\n const partitionMap = this._committedCheckpoints.get(key);\n\n if (partitionMap == null) {\n return [];\n }\n\n const checkpoints = [];\n\n for (const value of partitionMap.values()) {\n checkpoints.push({ ...value });\n }\n\n return checkpoints;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LoadBalancingStrategy } from "./loadBalancingStrategy.js";
|
|
2
|
-
import { PartitionOwnership } from "../eventProcessor.js";
|
|
1
|
+
import type { LoadBalancingStrategy } from "./loadBalancingStrategy.js";
|
|
2
|
+
import type { PartitionOwnership } from "../eventProcessor.js";
|
|
3
3
|
/**
|
|
4
4
|
* The BalancedLoadBalancerStrategy is meant to be used when the user
|
|
5
5
|
* wants to reach a load balanced state with less partition 'thrashing'.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balancedStrategy.d.ts","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/balancedStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"balancedStrategy.d.ts","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/balancedStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;;;;;;;GAQG;AACH,qBAAa,6BAA8B,YAAW,qBAAqB;IAM7D,OAAO,CAAC,QAAQ,CAAC,yCAAyC;IALtE;;;;OAIG;gBAC0B,yCAAyC,EAAE,MAAM;IAE9E;;;;;;;OAOG;IACI,oBAAoB,CACzB,UAAU,EAAE,MAAM,EAClB,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC7D,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,EAAE;CAeZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balancedStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/balancedStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"balancedStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/balancedStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAGrE;;;;;;;;GAQG;AACH,MAAM,OAAO,6BAA6B;IACxC;;;;OAIG;IACH,YAA6B,yCAAiD;QAAjD,8CAAyC,GAAzC,yCAAyC,CAAQ;IAAG,CAAC;IAElF;;;;;;;OAOG;IACI,oBAAoB,CACzB,UAAkB,EAClB,4BAA6D,EAC7D,YAAsB;QAEtB,MAAM,mBAAmB,GAAG,uBAAuB,CACjD,UAAU,EACV,4BAA4B,EAC5B,YAAY,EACZ,IAAI,CAAC,yCAAyC,CAC/C,CAAC;QAEF,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAChC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC3E,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { LoadBalancingStrategy } from \"./loadBalancingStrategy.js\";\nimport { listAvailablePartitions } from \"./loadBalancingStrategy.js\";\nimport type { PartitionOwnership } from \"../eventProcessor.js\";\n\n/**\n * The BalancedLoadBalancerStrategy is meant to be used when the user\n * wants to reach a load balanced state with less partition 'thrashing'.\n *\n * Partition thrashing - where a partition changes owners - is minimized\n * by only returning a single partition to claim at a time.\n * This minimizes the number of times a partition should need to be stolen.\n * @internal\n */\nexport class BalancedLoadBalancingStrategy implements LoadBalancingStrategy {\n /**\n * Creates an instance of BalancedLoadBalancingStrategy.\n *\n * @param _partitionOwnershipExpirationIntervalInMs - The length of time a partition claim is valid.\n */\n constructor(private readonly _partitionOwnershipExpirationIntervalInMs: number) {}\n\n /**\n * Implements load balancing by taking into account current ownership and\n * the full set of partitions in the Event Hub.\n * @param ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n public getPartitionsToClaim(\n ourOwnerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[] {\n const claimablePartitions = listAvailablePartitions(\n ourOwnerId,\n claimedPartitionOwnershipMap,\n partitionIds,\n this._partitionOwnershipExpirationIntervalInMs,\n );\n\n if (!claimablePartitions.length) {\n return [];\n }\n\n const randomIndex = Math.floor(Math.random() * claimablePartitions.length);\n return [claimablePartitions[randomIndex]];\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LoadBalancingStrategy } from "./loadBalancingStrategy.js";
|
|
2
|
-
import { PartitionOwnership } from "../eventProcessor.js";
|
|
1
|
+
import type { LoadBalancingStrategy } from "./loadBalancingStrategy.js";
|
|
2
|
+
import type { PartitionOwnership } from "../eventProcessor.js";
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greedyStrategy.d.ts","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/greedyStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"greedyStrategy.d.ts","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/greedyStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;GAEG;AACH,qBAAa,2BAA4B,YAAW,qBAAqB;IAM3D,OAAO,CAAC,QAAQ,CAAC,yCAAyC;IALtE;;;;OAIG;gBAC0B,yCAAyC,EAAE,MAAM;IAE9E;;;;;;;OAOG;IACI,oBAAoB,CACzB,UAAU,EAAE,MAAM,EAClB,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC7D,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,EAAE;CAQZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greedyStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/greedyStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"greedyStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/greedyStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAGrE;;GAEG;AACH,MAAM,OAAO,2BAA2B;IACtC;;;;OAIG;IACH,YAA6B,yCAAiD;QAAjD,8CAAyC,GAAzC,yCAAyC,CAAQ;IAAG,CAAC;IAElF;;;;;;;OAOG;IACI,oBAAoB,CACzB,UAAkB,EAClB,4BAA6D,EAC7D,YAAsB;QAEtB,OAAO,uBAAuB,CAC5B,UAAU,EACV,4BAA4B,EAC5B,YAAY,EACZ,IAAI,CAAC,yCAAyC,CAC/C,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { LoadBalancingStrategy } from \"./loadBalancingStrategy.js\";\nimport { listAvailablePartitions } from \"./loadBalancingStrategy.js\";\nimport type { PartitionOwnership } from \"../eventProcessor.js\";\n\n/**\n * @internal\n */\nexport class GreedyLoadBalancingStrategy implements LoadBalancingStrategy {\n /**\n * Creates an instance of GreedyLoadBalancingStrategy.\n *\n * @param _partitionOwnershipExpirationIntervalInMs - The length of time a partition claim is valid.\n */\n constructor(private readonly _partitionOwnershipExpirationIntervalInMs: number) {}\n\n /**\n * Implements load balancing by taking into account current ownership and\n * the new set of partitions to add.\n * @param ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n public getPartitionsToClaim(\n ourOwnerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[] {\n return listAvailablePartitions(\n ourOwnerId,\n claimedPartitionOwnershipMap,\n partitionIds,\n this._partitionOwnershipExpirationIntervalInMs,\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadBalancingStrategy.d.ts","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/loadBalancingStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"loadBalancingStrategy.d.ts","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/loadBalancingStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,oBAAoB,CAClB,OAAO,EAAE,MAAM,EACf,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC7D,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,EAAE,CAAC;CACb;AA2PD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC7D,YAAY,EAAE,MAAM,EAAE,EACtB,sBAAsB,EAAE,MAAM,GAC7B,MAAM,EAAE,CA8FV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadBalancingStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/loadBalancingStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA+CtC;;;;;;;;;GASG;AACH,SAAS,4BAA4B,CACnC,qBAAsD,EACtD,sBAA8B;IAE9B,MAAM,2BAA2B,GAAoC,IAAI,GAAG,EAAE,CAAC;IAC/E,qBAAqB,CAAC,OAAO,CAAC,CAAC,kBAAsC,EAAE,WAAmB,EAAE,EAAE;QAC5F,6DAA6D;QAC7D,IACE,OAAO,kBAAkB,CAAC,oBAAoB,KAAK,WAAW;YAC9D,kBAAkB,CAAC,oBAAoB,KAAK,IAAI,EAChD,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,yBAAyB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,CAAC,oBAAoB,CAAC;QACvF,IAAI,yBAAyB,GAAG,sBAAsB,IAAI,kBAAkB,CAAC,OAAO,EAAE,CAAC;YACrF,2BAA2B,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,2BAA2B,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,2BAA2B,CAClC,mBAAsD,EACtD,YAAsB;IAEtB,2FAA2F;IAC3F,yBAAyB;IACzB,MAAM,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEzF,+FAA+F;IAC/F,iGAAiG;IACjG,oBAAoB;IACpB,gFAAgF;IAChF,MAAM,wCAAwC,GAAG,YAAY,CAAC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C;IAEF,IAAI,yBAAyB,IAAI,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,MAAM,qBAAqB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,2BAA2B,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAEhG,iDAAiD;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC;QACzE,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAC9E,iBAAiB,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzE,yBAAyB,EAAE,CAAC;IAC9B,CAAC;IAED,IAAI,yBAAyB,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,iEAAiE;IACjE,MAAM,iBAAiB,GAAG,qBAAqB,CAC7C,yBAAyB,EACzB,qBAAqB,EACrB,wCAAwC,EACxC,OAAO,EACP,mBAAmB,CACpB,CAAC;IAEF,OAAO,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACrD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { PartitionOwnership } from \"../eventProcessor.js\";\nimport { logger } from \"../logger.js\";\n\n/**\n * Determines which partitions to claim as part of load balancing.\n * @internal\n */\nexport interface LoadBalancingStrategy {\n /**\n * Implements load balancing by taking into account current ownership and\n * the full set of partitions in the Event Hub.\n * @param ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n getPartitionsToClaim(\n ownerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[];\n}\n\n/**\n * Counts of the EventProcessors that currently own partitions.\n * @internal\n */\ninterface EventProcessorCounts {\n /**\n * The # of EventProcessors that only own the required # of\n * partitions.\n */\n haveRequiredPartitions: number;\n /**\n * The # of EventProcessors that currently own the required #\n * of partitions + 1 additional (ie, handling the case where\n * the number of partitions is not evenly divisible by the # of\n * EventProcessors).\n */\n haveAdditionalPartition: number;\n /**\n * EventProcessors which have more than the required or even required + 1\n * number of partitions. These will eventually be downsized by other\n * EventProcessors as they acquire their required number of partitions.\n */\n haveTooManyPartitions: number;\n}\n\n/**\n * This method will create a new map of partition id and PartitionOwnership containing only those partitions\n * that are actively owned.\n * All entries in the original map that haven't been modified for a duration of time greater than the allowed\n * inactivity time limit are assumed to be owned by dead event processors.\n * These will not be included in the map returned by this method.\n *\n * @param partitionOwnershipMap - The existing PartitionOwnerships mapped by partition.\n * @param expirationIntervalInMs - The length of time a PartitionOwnership claim is valid.\n */\nfunction getActivePartitionOwnerships(\n partitionOwnershipMap: Map<string, PartitionOwnership>,\n expirationIntervalInMs: number,\n): Map<string, PartitionOwnership> {\n const activePartitionOwnershipMap: Map<string, PartitionOwnership> = new Map();\n partitionOwnershipMap.forEach((partitionOwnership: PartitionOwnership, partitionId: string) => {\n // If lastModifiedtimeInMs is missing, assume it is inactive.\n if (\n typeof partitionOwnership.lastModifiedTimeInMs === \"undefined\" ||\n partitionOwnership.lastModifiedTimeInMs === null\n ) {\n return;\n }\n\n const timeSincePartitionClaimed = Date.now() - partitionOwnership.lastModifiedTimeInMs;\n if (timeSincePartitionClaimed < expirationIntervalInMs && partitionOwnership.ownerId) {\n activePartitionOwnershipMap.set(partitionId, partitionOwnership);\n }\n });\n\n return activePartitionOwnershipMap;\n}\n\n/**\n * Calculates the minimum number of partitions each EventProcessor should own,\n * and the number of EventProcessors that should have an extra partition assigned.\n * @param ownerToOwnershipMap - The current ownerships for partitions.\n * @param partitionIds - The full list of the Event Hub's partition ids.\n * @internal\n */\nfunction calculateBalancedLoadCounts(\n ownerToOwnershipMap: Map<string, PartitionOwnership[]>,\n partitionIds: string[],\n): { minPartitionsPerOwner: number; requiredNumberOfOwnersWithExtraPartition: number } {\n // Calculate the minimum number of partitions every EventProcessor should own when the load\n // is evenly distributed.\n const minPartitionsPerOwner = Math.floor(partitionIds.length / ownerToOwnershipMap.size);\n\n // If the number of partitions in the Event Hub is not evenly divisible by the number of active\n // EventProcesrrors, some EventProcessors may own 1 partition in addition to the minimum when the\n // load is balanced.\n // Calculate the number of EventProcessors that can own an additional partition.\n const requiredNumberOfOwnersWithExtraPartition = partitionIds.length % ownerToOwnershipMap.size;\n\n return {\n minPartitionsPerOwner,\n requiredNumberOfOwnersWithExtraPartition,\n };\n}\n\n/**\n * Counts the EventProcessors and tallies them by type.\n *\n * To be in balance we need to make sure that each EventProcessor is only consuming\n * their fair share.\n *\n * When the partitions are divvied up we will sometimes end up with some EventProcessors\n * that will have 1 more partition than others.\n * This can happen if the number of partitions is not evenly divisible by the number of EventProcessors.\n *\n * So this function largely exists to support isLoadBalanced() and\n * shouldOwnMorePartitions(), both of which depend on knowing if our current list\n * of EventProcessors is actually in the proper state.\n *\n * @param minPartitionsPerOwner - The number of required partitions per EventProcessor.\n * @param ownerToOwnershipMap - The current ownerships for partitions.\n * @internal\n */\nfunction getEventProcessorCounts(\n minPartitionsPerOwner: number,\n ownerToOwnershipMap: Map<string, PartitionOwnership[]>,\n): EventProcessorCounts {\n const counts: EventProcessorCounts = {\n haveRequiredPartitions: 0,\n haveAdditionalPartition: 0,\n haveTooManyPartitions: 0,\n };\n\n for (const ownershipList of ownerToOwnershipMap.values()) {\n const numberOfPartitions = ownershipList.length;\n\n // there are basically three kinds of partition counts\n // for a processor:\n\n if (numberOfPartitions === minPartitionsPerOwner) {\n // 1. Has _exactly_ the required number of partitions\n counts.haveRequiredPartitions++;\n } else if (numberOfPartitions === minPartitionsPerOwner + 1) {\n // 2. Has the required number plus one extra (correct in cases)\n // where the # of partitions is not evenly divisible by the\n // number of processors.\n counts.haveAdditionalPartition++;\n } else if (numberOfPartitions > minPartitionsPerOwner + 1) {\n // 3. has more than the possible # of partitions required\n counts.haveTooManyPartitions++;\n }\n }\n\n return counts;\n}\n\n/**\n * Validates that we are currently in a balanced state - all EventProcessors own the\n * minimum required number of partitions (and additional partitions, if the # of partitions\n * is not evenly divisible by the # of EventProcessors).\n *\n * @param requiredNumberOfOwnersWithExtraPartition - The # of EventProcessors that process an additional partition, in addition to the required minimum.\n * @param totalExpectedProcessors - The total # of EventProcessors we expect.\n * @param eventProcessorCounts - EventProcessor counts, grouped by criteria.\n * @internal\n */\nfunction isLoadBalanced(\n requiredNumberOfOwnersWithExtraPartition: number,\n totalExpectedEventProcessors: number,\n { haveAdditionalPartition, haveRequiredPartitions }: EventProcessorCounts,\n): boolean {\n return (\n haveAdditionalPartition === requiredNumberOfOwnersWithExtraPartition &&\n haveRequiredPartitions + haveAdditionalPartition === totalExpectedEventProcessors\n );\n}\n\n/**\n * Determines the number of new partitions to claim for this particular processor.\n *\n * @param minRequired - The minimum required number of partitions.\n * @param requiredNumberOfOwnersWithExtraPartition - The current number of processors that should have an additional partition.\n * @param numPartitionsOwnedByUs - The number of partitions we currently own.\n * @param eventProcessorCounts - Processors, grouped by criteria.\n * @internal\n */\nfunction getNumberOfPartitionsToClaim(\n minRequiredPartitionCount: number,\n requiredNumberOfOwnersWithExtraPartition: number,\n numPartitionsOwnedByUs: number,\n { haveAdditionalPartition, haveTooManyPartitions }: EventProcessorCounts,\n): number {\n let actualRequiredPartitionCount = minRequiredPartitionCount;\n\n if (\n requiredNumberOfOwnersWithExtraPartition > 0 &&\n // Eventually the `haveTooManyPartitions` will decay into `haveAdditionalPartition`\n // EventProcessors as partitions are balanced to consumers that aren't at par.\n // We can consider them to be `haveAdditionalPartition` EventProcessors for our purposes.\n haveAdditionalPartition + haveTooManyPartitions < requiredNumberOfOwnersWithExtraPartition\n ) {\n // Overall we don't have enough EventProcessors that are taking on an additional partition\n // so we should attempt to.\n actualRequiredPartitionCount = minRequiredPartitionCount + 1;\n }\n return actualRequiredPartitionCount - numPartitionsOwnedByUs;\n}\n\n/**\n * Determines which partitions can be stolen from other owners while maintaining\n * a balanced state.\n * @param numberOfPartitionsToClaim - The number of partitions the owner needs to claim to reach a balanced state.\n * @param minPartitionsPerOwner - The minimum number of partitions each owner needs for the partition load to be balanced.\n * @param requiredNumberOfOwnersWithExtraPartition - The number of owners that should have 1 extra partition.\n * @param ourOwnerId - The id of _our_ owner.\n * @param ownerToOwnershipMap - The current ownerships for partitions.\n * @internal\n */\nfunction findPartitionsToSteal(\n numberOfPartitionsToClaim: number,\n minPartitionsPerOwner: number,\n requiredNumberOfOwnersWithExtraPartition: number,\n ourOwnerId: string,\n ownerToOwnershipMap: Map<string, PartitionOwnership[]>,\n): string[] {\n const partitionsToSteal: string[] = [];\n // Create a list of PartitionOwnership lists that we can steal from.\n const listOfPartitionOwnerships: Array<PartitionOwnership[]> = [];\n ownerToOwnershipMap.forEach((partitionOwnerships, ownerId) => {\n if (ownerId === ourOwnerId || partitionOwnerships.length <= minPartitionsPerOwner) return;\n listOfPartitionOwnerships.push(partitionOwnerships);\n });\n\n // Sort the list in descending order based on the length of each element.\n listOfPartitionOwnerships.sort((a, b) => {\n if (a.length > b.length) return -1;\n if (a.length < b.length) return 1;\n return 0;\n });\n\n // Attempt to steal partitions from EventProcessors that have the most partitions 1st,\n // then work our way down.\n let ownersEncounteredWithExtraPartitions = 0;\n let currentPartitionOwnershipList = listOfPartitionOwnerships.shift();\n while (numberOfPartitionsToClaim > 0 && currentPartitionOwnershipList) {\n let ownersExpectedPartitionCount = minPartitionsPerOwner;\n // Determine if the current owner should be allowed to have an extra partition.\n if (ownersEncounteredWithExtraPartitions < requiredNumberOfOwnersWithExtraPartition) {\n ownersExpectedPartitionCount++;\n }\n ownersEncounteredWithExtraPartitions++;\n\n let numberAvailableToSteal =\n currentPartitionOwnershipList.length - ownersExpectedPartitionCount;\n // Claim as many random partitions as possible.\n while (Math.min(numberOfPartitionsToClaim, numberAvailableToSteal)) {\n const indexToClaim = Math.floor(Math.random() * currentPartitionOwnershipList.length);\n partitionsToSteal.push(currentPartitionOwnershipList.splice(indexToClaim, 1)[0].partitionId);\n numberOfPartitionsToClaim--;\n numberAvailableToSteal--;\n }\n\n // Move on to the next list of PartitionOwnership.\n currentPartitionOwnershipList = listOfPartitionOwnerships.shift();\n }\n\n return partitionsToSteal;\n}\n\n/**\n * Identifies all of the partitions that can be claimed by the specified owner for\n * that owner to reach a balanced state.\n * @param OwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @param expirationIntervalInMs - The length of time a partition claim is valid.\n * @returns Partition ids that may be claimed.\n * @internal\n */\nexport function listAvailablePartitions(\n ownerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n expirationIntervalInMs: number,\n): string[] {\n if (!partitionIds.length) {\n return [];\n }\n\n // Collect only the PartitionOwnership that have been updated within the expiration interval.\n // Any PartitionOwnership that has been updated outside the expiration interval can be claimed.\n const activePartitionOwnershipMap = getActivePartitionOwnerships(\n claimedPartitionOwnershipMap,\n expirationIntervalInMs,\n );\n logger.verbose(\n `[${ownerId}] Number of active ownership records: ${activePartitionOwnershipMap.size}.`,\n );\n\n if (activePartitionOwnershipMap.size === 0) {\n // All partitions in this Event Hub are available to claim.\n return partitionIds;\n }\n\n // Map ownerIds to the partitions they own so that we can determine how many each owner has.\n const ownerToOwnershipMap = new Map<string, PartitionOwnership[]>();\n for (const activeOwnership of activePartitionOwnershipMap.values()) {\n const partitionOwnershipList = ownerToOwnershipMap.get(activeOwnership.ownerId) || [];\n\n partitionOwnershipList.push(activeOwnership);\n ownerToOwnershipMap.set(activeOwnership.ownerId, partitionOwnershipList);\n }\n\n // Add the current EventProcessor to the map of owners to ownerships if it doesn't exist.\n if (!ownerToOwnershipMap.has(ownerId)) {\n ownerToOwnershipMap.set(ownerId, []);\n }\n\n logger.info(`[${ownerId}] Number of active event processors: ${ownerToOwnershipMap.size}.`);\n\n const { minPartitionsPerOwner, requiredNumberOfOwnersWithExtraPartition } =\n calculateBalancedLoadCounts(ownerToOwnershipMap, partitionIds);\n\n logger.verbose(\n `[${ownerId}] Expected minimum number of partitions per event processor: ${minPartitionsPerOwner},` +\n `expected number of event processors with additional partition: ${requiredNumberOfOwnersWithExtraPartition}.`,\n );\n\n // Get some stats representing the current state the world with regards to how balanced the\n // partitions are across EventProcessors.\n const eventProcessorCounts = getEventProcessorCounts(minPartitionsPerOwner, ownerToOwnershipMap);\n\n if (\n isLoadBalanced(\n requiredNumberOfOwnersWithExtraPartition,\n ownerToOwnershipMap.size,\n eventProcessorCounts,\n )\n ) {\n // When the partitions are evenly distributed, no change required.\n return [];\n }\n\n let numberOfPartitionsToClaim = getNumberOfPartitionsToClaim(\n minPartitionsPerOwner,\n requiredNumberOfOwnersWithExtraPartition,\n ownerToOwnershipMap.get(ownerId)!.length,\n eventProcessorCounts,\n );\n\n if (numberOfPartitionsToClaim <= 0) {\n return [];\n }\n\n const partitionsToClaim: string[] = [];\n const unclaimedPartitionIds = partitionIds.filter((id) => !activePartitionOwnershipMap.has(id));\n\n // Prioritize getting unclaimed partitions first.\n while (Math.min(numberOfPartitionsToClaim, unclaimedPartitionIds.length)) {\n const indexToClaim = Math.floor(Math.random() * unclaimedPartitionIds.length);\n partitionsToClaim.push(unclaimedPartitionIds.splice(indexToClaim, 1)[0]);\n numberOfPartitionsToClaim--;\n }\n\n if (numberOfPartitionsToClaim === 0) {\n return partitionsToClaim;\n }\n\n // Find partitions that can be stolen from other EventProcessors.\n const partitionsToSteal = findPartitionsToSteal(\n numberOfPartitionsToClaim,\n minPartitionsPerOwner,\n requiredNumberOfOwnersWithExtraPartition,\n ownerId,\n ownerToOwnershipMap,\n );\n\n return partitionsToClaim.concat(partitionsToSteal);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"loadBalancingStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/loadBalancingStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA+CtC;;;;;;;;;GASG;AACH,SAAS,4BAA4B,CACnC,qBAAsD,EACtD,sBAA8B;IAE9B,MAAM,2BAA2B,GAAoC,IAAI,GAAG,EAAE,CAAC;IAC/E,qBAAqB,CAAC,OAAO,CAAC,CAAC,kBAAsC,EAAE,WAAmB,EAAE,EAAE;QAC5F,6DAA6D;QAC7D,IACE,OAAO,kBAAkB,CAAC,oBAAoB,KAAK,WAAW;YAC9D,kBAAkB,CAAC,oBAAoB,KAAK,IAAI,EAChD,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,yBAAyB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,CAAC,oBAAoB,CAAC;QACvF,IAAI,yBAAyB,GAAG,sBAAsB,IAAI,kBAAkB,CAAC,OAAO,EAAE,CAAC;YACrF,2BAA2B,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,2BAA2B,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,2BAA2B,CAClC,mBAAsD,EACtD,YAAsB;IAEtB,2FAA2F;IAC3F,yBAAyB;IACzB,MAAM,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEzF,+FAA+F;IAC/F,iGAAiG;IACjG,oBAAoB;IACpB,gFAAgF;IAChF,MAAM,wCAAwC,GAAG,YAAY,CAAC,MAAM,GAAG,mBAAmB,CAAC,IAAI,CA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AAE,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,MAAM,qBAAqB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,2BAA2B,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAEhG,iDAAiD;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC;QACzE,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAC9E,iBAAiB,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzE,yBAAyB,EAAE,CAAC;IAC9B,CAAC;IAED,IAAI,yBAAyB,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,iEAAiE;IACjE,MAAM,iBAAiB,GAAG,qBAAqB,CAC7C,yBAAyB,EACzB,qBAAqB,EACrB,wCAAwC,EACxC,OAAO,EACP,mBAAmB,CACpB,CAAC;IAEF,OAAO,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACrD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PartitionOwnership } from \"../eventProcessor.js\";\nimport { logger } from \"../logger.js\";\n\n/**\n * Determines which partitions to claim as part of load balancing.\n * @internal\n */\nexport interface LoadBalancingStrategy {\n /**\n * Implements load balancing by taking into account current ownership and\n * the full set of partitions in the Event Hub.\n * @param ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n getPartitionsToClaim(\n ownerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[];\n}\n\n/**\n * Counts of the EventProcessors that currently own partitions.\n * @internal\n */\ninterface EventProcessorCounts {\n /**\n * The # of EventProcessors that only own the required # of\n * partitions.\n */\n haveRequiredPartitions: number;\n /**\n * The # of EventProcessors that currently own the required #\n * of partitions + 1 additional (ie, handling the case where\n * the number of partitions is not evenly divisible by the # of\n * EventProcessors).\n */\n haveAdditionalPartition: number;\n /**\n * EventProcessors which have more than the required or even required + 1\n * number of partitions. These will eventually be downsized by other\n * EventProcessors as they acquire their required number of partitions.\n */\n haveTooManyPartitions: number;\n}\n\n/**\n * This method will create a new map of partition id and PartitionOwnership containing only those partitions\n * that are actively owned.\n * All entries in the original map that haven't been modified for a duration of time greater than the allowed\n * inactivity time limit are assumed to be owned by dead event processors.\n * These will not be included in the map returned by this method.\n *\n * @param partitionOwnershipMap - The existing PartitionOwnerships mapped by partition.\n * @param expirationIntervalInMs - The length of time a PartitionOwnership claim is valid.\n */\nfunction getActivePartitionOwnerships(\n partitionOwnershipMap: Map<string, PartitionOwnership>,\n expirationIntervalInMs: number,\n): Map<string, PartitionOwnership> {\n const activePartitionOwnershipMap: Map<string, PartitionOwnership> = new Map();\n partitionOwnershipMap.forEach((partitionOwnership: PartitionOwnership, partitionId: string) => {\n // If lastModifiedtimeInMs is missing, assume it is inactive.\n if (\n typeof partitionOwnership.lastModifiedTimeInMs === \"undefined\" ||\n partitionOwnership.lastModifiedTimeInMs === null\n ) {\n return;\n }\n\n const timeSincePartitionClaimed = Date.now() - partitionOwnership.lastModifiedTimeInMs;\n if (timeSincePartitionClaimed < expirationIntervalInMs && partitionOwnership.ownerId) {\n activePartitionOwnershipMap.set(partitionId, partitionOwnership);\n }\n });\n\n return activePartitionOwnershipMap;\n}\n\n/**\n * Calculates the minimum number of partitions each EventProcessor should own,\n * and the number of EventProcessors that should have an extra partition assigned.\n * @param ownerToOwnershipMap - The current ownerships for partitions.\n * @param partitionIds - The full list of the Event Hub's partition ids.\n * @internal\n */\nfunction calculateBalancedLoadCounts(\n ownerToOwnershipMap: Map<string, PartitionOwnership[]>,\n partitionIds: string[],\n): { minPartitionsPerOwner: number; requiredNumberOfOwnersWithExtraPartition: number } {\n // Calculate the minimum number of partitions every EventProcessor should own when the load\n // is evenly distributed.\n const minPartitionsPerOwner = Math.floor(partitionIds.length / ownerToOwnershipMap.size);\n\n // If the number of partitions in the Event Hub is not evenly divisible by the number of active\n // EventProcesrrors, some EventProcessors may own 1 partition in addition to the minimum when the\n // load is balanced.\n // Calculate the number of EventProcessors that can own an additional partition.\n const requiredNumberOfOwnersWithExtraPartition = partitionIds.length % ownerToOwnershipMap.size;\n\n return {\n minPartitionsPerOwner,\n requiredNumberOfOwnersWithExtraPartition,\n };\n}\n\n/**\n * Counts the EventProcessors and tallies them by type.\n *\n * To be in balance we need to make sure that each EventProcessor is only consuming\n * their fair share.\n *\n * When the partitions are divvied up we will sometimes end up with some EventProcessors\n * that will have 1 more partition than others.\n * This can happen if the number of partitions is not evenly divisible by the number of EventProcessors.\n *\n * So this function largely exists to support isLoadBalanced() and\n * shouldOwnMorePartitions(), both of which depend on knowing if our current list\n * of EventProcessors is actually in the proper state.\n *\n * @param minPartitionsPerOwner - The number of required partitions per EventProcessor.\n * @param ownerToOwnershipMap - The current ownerships for partitions.\n * @internal\n */\nfunction getEventProcessorCounts(\n minPartitionsPerOwner: number,\n ownerToOwnershipMap: Map<string, PartitionOwnership[]>,\n): EventProcessorCounts {\n const counts: EventProcessorCounts = {\n haveRequiredPartitions: 0,\n haveAdditionalPartition: 0,\n haveTooManyPartitions: 0,\n };\n\n for (const ownershipList of ownerToOwnershipMap.values()) {\n const numberOfPartitions = ownershipList.length;\n\n // there are basically three kinds of partition counts\n // for a processor:\n\n if (numberOfPartitions === minPartitionsPerOwner) {\n // 1. Has _exactly_ the required number of partitions\n counts.haveRequiredPartitions++;\n } else if (numberOfPartitions === minPartitionsPerOwner + 1) {\n // 2. Has the required number plus one extra (correct in cases)\n // where the # of partitions is not evenly divisible by the\n // number of processors.\n counts.haveAdditionalPartition++;\n } else if (numberOfPartitions > minPartitionsPerOwner + 1) {\n // 3. has more than the possible # of partitions required\n counts.haveTooManyPartitions++;\n }\n }\n\n return counts;\n}\n\n/**\n * Validates that we are currently in a balanced state - all EventProcessors own the\n * minimum required number of partitions (and additional partitions, if the # of partitions\n * is not evenly divisible by the # of EventProcessors).\n *\n * @param requiredNumberOfOwnersWithExtraPartition - The # of EventProcessors that process an additional partition, in addition to the required minimum.\n * @param totalExpectedProcessors - The total # of EventProcessors we expect.\n * @param eventProcessorCounts - EventProcessor counts, grouped by criteria.\n * @internal\n */\nfunction isLoadBalanced(\n requiredNumberOfOwnersWithExtraPartition: number,\n totalExpectedEventProcessors: number,\n { haveAdditionalPartition, haveRequiredPartitions }: EventProcessorCounts,\n): boolean {\n return (\n haveAdditionalPartition === requiredNumberOfOwnersWithExtraPartition &&\n haveRequiredPartitions + haveAdditionalPartition === totalExpectedEventProcessors\n );\n}\n\n/**\n * Determines the number of new partitions to claim for this particular processor.\n *\n * @param minRequired - The minimum required number of partitions.\n * @param requiredNumberOfOwnersWithExtraPartition - The current number of processors that should have an additional partition.\n * @param numPartitionsOwnedByUs - The number of partitions we currently own.\n * @param eventProcessorCounts - Processors, grouped by criteria.\n * @internal\n */\nfunction getNumberOfPartitionsToClaim(\n minRequiredPartitionCount: number,\n requiredNumberOfOwnersWithExtraPartition: number,\n numPartitionsOwnedByUs: number,\n { haveAdditionalPartition, haveTooManyPartitions }: EventProcessorCounts,\n): number {\n let actualRequiredPartitionCount = minRequiredPartitionCount;\n\n if (\n requiredNumberOfOwnersWithExtraPartition > 0 &&\n // Eventually the `haveTooManyPartitions` will decay into `haveAdditionalPartition`\n // EventProcessors as partitions are balanced to consumers that aren't at par.\n // We can consider them to be `haveAdditionalPartition` EventProcessors for our purposes.\n haveAdditionalPartition + haveTooManyPartitions < requiredNumberOfOwnersWithExtraPartition\n ) {\n // Overall we don't have enough EventProcessors that are taking on an additional partition\n // so we should attempt to.\n actualRequiredPartitionCount = minRequiredPartitionCount + 1;\n }\n return actualRequiredPartitionCount - numPartitionsOwnedByUs;\n}\n\n/**\n * Determines which partitions can be stolen from other owners while maintaining\n * a balanced state.\n * @param numberOfPartitionsToClaim - The number of partitions the owner needs to claim to reach a balanced state.\n * @param minPartitionsPerOwner - The minimum number of partitions each owner needs for the partition load to be balanced.\n * @param requiredNumberOfOwnersWithExtraPartition - The number of owners that should have 1 extra partition.\n * @param ourOwnerId - The id of _our_ owner.\n * @param ownerToOwnershipMap - The current ownerships for partitions.\n * @internal\n */\nfunction findPartitionsToSteal(\n numberOfPartitionsToClaim: number,\n minPartitionsPerOwner: number,\n requiredNumberOfOwnersWithExtraPartition: number,\n ourOwnerId: string,\n ownerToOwnershipMap: Map<string, PartitionOwnership[]>,\n): string[] {\n const partitionsToSteal: string[] = [];\n // Create a list of PartitionOwnership lists that we can steal from.\n const listOfPartitionOwnerships: Array<PartitionOwnership[]> = [];\n ownerToOwnershipMap.forEach((partitionOwnerships, ownerId) => {\n if (ownerId === ourOwnerId || partitionOwnerships.length <= minPartitionsPerOwner) return;\n listOfPartitionOwnerships.push(partitionOwnerships);\n });\n\n // Sort the list in descending order based on the length of each element.\n listOfPartitionOwnerships.sort((a, b) => {\n if (a.length > b.length) return -1;\n if (a.length < b.length) return 1;\n return 0;\n });\n\n // Attempt to steal partitions from EventProcessors that have the most partitions 1st,\n // then work our way down.\n let ownersEncounteredWithExtraPartitions = 0;\n let currentPartitionOwnershipList = listOfPartitionOwnerships.shift();\n while (numberOfPartitionsToClaim > 0 && currentPartitionOwnershipList) {\n let ownersExpectedPartitionCount = minPartitionsPerOwner;\n // Determine if the current owner should be allowed to have an extra partition.\n if (ownersEncounteredWithExtraPartitions < requiredNumberOfOwnersWithExtraPartition) {\n ownersExpectedPartitionCount++;\n }\n ownersEncounteredWithExtraPartitions++;\n\n let numberAvailableToSteal =\n currentPartitionOwnershipList.length - ownersExpectedPartitionCount;\n // Claim as many random partitions as possible.\n while (Math.min(numberOfPartitionsToClaim, numberAvailableToSteal)) {\n const indexToClaim = Math.floor(Math.random() * currentPartitionOwnershipList.length);\n partitionsToSteal.push(currentPartitionOwnershipList.splice(indexToClaim, 1)[0].partitionId);\n numberOfPartitionsToClaim--;\n numberAvailableToSteal--;\n }\n\n // Move on to the next list of PartitionOwnership.\n currentPartitionOwnershipList = listOfPartitionOwnerships.shift();\n }\n\n return partitionsToSteal;\n}\n\n/**\n * Identifies all of the partitions that can be claimed by the specified owner for\n * that owner to reach a balanced state.\n * @param OwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @param expirationIntervalInMs - The length of time a partition claim is valid.\n * @returns Partition ids that may be claimed.\n * @internal\n */\nexport function listAvailablePartitions(\n ownerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n expirationIntervalInMs: number,\n): string[] {\n if (!partitionIds.length) {\n return [];\n }\n\n // Collect only the PartitionOwnership that have been updated within the expiration interval.\n // Any PartitionOwnership that has been updated outside the expiration interval can be claimed.\n const activePartitionOwnershipMap = getActivePartitionOwnerships(\n claimedPartitionOwnershipMap,\n expirationIntervalInMs,\n );\n logger.verbose(\n `[${ownerId}] Number of active ownership records: ${activePartitionOwnershipMap.size}.`,\n );\n\n if (activePartitionOwnershipMap.size === 0) {\n // All partitions in this Event Hub are available to claim.\n return partitionIds;\n }\n\n // Map ownerIds to the partitions they own so that we can determine how many each owner has.\n const ownerToOwnershipMap = new Map<string, PartitionOwnership[]>();\n for (const activeOwnership of activePartitionOwnershipMap.values()) {\n const partitionOwnershipList = ownerToOwnershipMap.get(activeOwnership.ownerId) || [];\n\n partitionOwnershipList.push(activeOwnership);\n ownerToOwnershipMap.set(activeOwnership.ownerId, partitionOwnershipList);\n }\n\n // Add the current EventProcessor to the map of owners to ownerships if it doesn't exist.\n if (!ownerToOwnershipMap.has(ownerId)) {\n ownerToOwnershipMap.set(ownerId, []);\n }\n\n logger.info(`[${ownerId}] Number of active event processors: ${ownerToOwnershipMap.size}.`);\n\n const { minPartitionsPerOwner, requiredNumberOfOwnersWithExtraPartition } =\n calculateBalancedLoadCounts(ownerToOwnershipMap, partitionIds);\n\n logger.verbose(\n `[${ownerId}] Expected minimum number of partitions per event processor: ${minPartitionsPerOwner},` +\n `expected number of event processors with additional partition: ${requiredNumberOfOwnersWithExtraPartition}.`,\n );\n\n // Get some stats representing the current state the world with regards to how balanced the\n // partitions are across EventProcessors.\n const eventProcessorCounts = getEventProcessorCounts(minPartitionsPerOwner, ownerToOwnershipMap);\n\n if (\n isLoadBalanced(\n requiredNumberOfOwnersWithExtraPartition,\n ownerToOwnershipMap.size,\n eventProcessorCounts,\n )\n ) {\n // When the partitions are evenly distributed, no change required.\n return [];\n }\n\n let numberOfPartitionsToClaim = getNumberOfPartitionsToClaim(\n minPartitionsPerOwner,\n requiredNumberOfOwnersWithExtraPartition,\n ownerToOwnershipMap.get(ownerId)!.length,\n eventProcessorCounts,\n );\n\n if (numberOfPartitionsToClaim <= 0) {\n return [];\n }\n\n const partitionsToClaim: string[] = [];\n const unclaimedPartitionIds = partitionIds.filter((id) => !activePartitionOwnershipMap.has(id));\n\n // Prioritize getting unclaimed partitions first.\n while (Math.min(numberOfPartitionsToClaim, unclaimedPartitionIds.length)) {\n const indexToClaim = Math.floor(Math.random() * unclaimedPartitionIds.length);\n partitionsToClaim.push(unclaimedPartitionIds.splice(indexToClaim, 1)[0]);\n numberOfPartitionsToClaim--;\n }\n\n if (numberOfPartitionsToClaim === 0) {\n return partitionsToClaim;\n }\n\n // Find partitions that can be stolen from other EventProcessors.\n const partitionsToSteal = findPartitionsToSteal(\n numberOfPartitionsToClaim,\n minPartitionsPerOwner,\n requiredNumberOfOwnersWithExtraPartition,\n ownerId,\n ownerToOwnershipMap,\n );\n\n return partitionsToClaim.concat(partitionsToSteal);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LoadBalancingStrategy } from "./loadBalancingStrategy.js";
|
|
2
|
-
import { PartitionOwnership } from "../eventProcessor.js";
|
|
1
|
+
import type { LoadBalancingStrategy } from "./loadBalancingStrategy.js";
|
|
2
|
+
import type { PartitionOwnership } from "../eventProcessor.js";
|
|
3
3
|
/**
|
|
4
4
|
* The UnbalancedLoadBalancingStrategy does no actual load balancing.
|
|
5
5
|
* It is intended to be used when you want to avoid load balancing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unbalancedStrategy.d.ts","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/unbalancedStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"unbalancedStrategy.d.ts","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/unbalancedStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;;;;GAKG;AACH,qBAAa,+BAAgC,YAAW,qBAAqB;IAC3E;;;;;;;OAOG;IACI,oBAAoB,CACzB,WAAW,EAAE,MAAM,EACnB,6BAA6B,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC9D,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,EAAE;CAGZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unbalancedStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/unbalancedStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;;;;GAKG;AACH,MAAM,OAAO,+BAA+B;IAC1C;;;;;;;OAOG;IACI,oBAAoB,CACzB,WAAmB,EACnB,6BAA8D,EAC9D,YAAsB;QAEtB,OAAO,YAAY,CAAC;IACtB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { LoadBalancingStrategy } from \"./loadBalancingStrategy.js\";\nimport { PartitionOwnership } from \"../eventProcessor.js\";\n\n/**\n * The UnbalancedLoadBalancingStrategy does no actual load balancing.\n * It is intended to be used when you want to avoid load balancing\n * and consume a set of partitions.\n * @internal\n */\nexport class UnbalancedLoadBalancingStrategy implements LoadBalancingStrategy {\n /**\n * Implements load balancing by taking into account current ownership and\n * the full set of partitions in the Event Hub.\n * @param _ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param _claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n public getPartitionsToClaim(\n _ourOwnerId: string,\n _claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[] {\n return partitionIds;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"unbalancedStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/unbalancedStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;;;;GAKG;AACH,MAAM,OAAO,+BAA+B;IAC1C;;;;;;;OAOG;IACI,oBAAoB,CACzB,WAAmB,EACnB,6BAA8D,EAC9D,YAAsB;QAEtB,OAAO,YAAY,CAAC;IACtB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { LoadBalancingStrategy } from \"./loadBalancingStrategy.js\";\nimport type { PartitionOwnership } from \"../eventProcessor.js\";\n\n/**\n * The UnbalancedLoadBalancingStrategy does no actual load balancing.\n * It is intended to be used when you want to avoid load balancing\n * and consume a set of partitions.\n * @internal\n */\nexport class UnbalancedLoadBalancingStrategy implements LoadBalancingStrategy {\n /**\n * Implements load balancing by taking into account current ownership and\n * the full set of partitions in the Event Hub.\n * @param _ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param _claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n public getPartitionsToClaim(\n _ourOwnerId: string,\n _claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[] {\n return partitionIds;\n }\n}\n"]}
|
package/dist/browser/logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAiB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI1E;;;GAGG;AACH,eAAO,MAAM,MAAM,aAAmC,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAIvD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAEpF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;KACxB,QAAQ,IAAI,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC;CACjD,CAAC;AAcF;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAOzF;AAED,gBAAgB;AAChB,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAEzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,sBAAsB,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAC7C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAAkB,EAClB,YAAoB,EACpB,WAAmB;IAEnB,OAAO,IAAI,YAAY,eAAe,WAAW,IAAI,UAAU,EAAE,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB,EAAE,YAAoB;IAC1E,OAAO,IAAI,YAAY,YAAY,QAAQ,EAAE,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,YAAoB;IAC5D,OAAO,IAAI,YAAY,cAAc,CAAC;AACxC,CAAC;AASD,SAAS,iBAAiB,CACxB,WAAwB,EACxB,MAAc,EACd,KAAoB;IAEpB,OAAO,CAAC,GAAQ,EAAE,GAAG,IAAW,EAAE,EAAE,CAClC,WAAW,CAAC,KAAK,CAAC,CAChB,GAAG,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EACpE,GAAG,IAAI,CACR,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAwB,EAAE,MAAc;IACzE,OAAO;QACL,IAAI,EAAE,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC;QACpD,KAAK,EAAE,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC;QACtD,OAAO,EAAE,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC;QAC1D,OAAO,EAAE,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC;KAC3D,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,MAAM,CAAC,GAAY;IACjC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AzureLogger, AzureLogLevel, Debugger } from \"@azure/logger\";\nimport { createClientLogger } from \"@azure/logger\";\nimport { isObjectWithProperties } from \"@azure/core-util\";\n\n/**\n * The `@azure/logger` configuration for this package.\n * This will output logs using the `azure:event-hubs` namespace prefix.\n */\nexport const logger = createClientLogger(\"event-hubs\");\n\n/**\n * Logs the error's stack trace to \"verbose\" if a stack trace is available.\n * @param error - Error containing a stack trace.\n * @internal\n */\nexport function logErrorStackTrace(error: unknown): void {\n if (isObjectWithProperties(error, [\"stack\"])) {\n logger.verbose(error.stack);\n }\n}\n\n/**\n * @internal\n */\nexport function createReceiverLogPrefix(\n consumerId: string,\n connectionId: string,\n partitionId: string,\n): string {\n return `[${connectionId}] Receiver P${partitionId}-${consumerId}`;\n}\n\n/**\n * @internal\n */\nexport function createSenderLogPrefix(senderId: string, connectionId: string): string {\n return `[${connectionId}] Sender ${senderId}`;\n}\n\n/**\n * @internal\n */\nexport function createManagementLogPrefix(connectionId: string): string {\n return `[${connectionId}] Management`;\n}\n\n/**\n * @internal\n */\nexport type SimpleLogger = {\n [Property in keyof AzureLogger]: Debugger[\"log\"];\n};\n\nfunction createLogFunction(\n azureLogger: AzureLogger,\n prefix: string,\n level: AzureLogLevel,\n): (arg: any, ...args: any[]) => void {\n return (arg: any, ...args: any[]) =>\n azureLogger[level](\n ...(typeof arg === \"string\" ? [`${prefix}: ${arg}`] : [prefix, arg]),\n ...args,\n );\n}\n\n/**\n * @internal\n */\nexport function createSimpleLogger(azureLogger: AzureLogger, prefix: string): SimpleLogger {\n return {\n info: createLogFunction(azureLogger, prefix, \"info\"),\n error: createLogFunction(azureLogger, prefix, \"error\"),\n verbose: createLogFunction(azureLogger, prefix, \"verbose\"),\n warning: createLogFunction(azureLogger, prefix, \"warning\"),\n };\n}\n\n/** @internal */\nexport function logObj(obj: unknown): void {\n JSON.stringify(obj, undefined, 2);\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RetryOptions } from "@azure/core-amqp";
|
|
2
|
-
import { AccessToken } from "@azure/core-auth";
|
|
3
|
-
import { ConnectionContext } from "./connectionContext.js";
|
|
4
|
-
import { OperationOptions } from "./util/operationOptions.js";
|
|
1
|
+
import type { RetryOptions } from "@azure/core-amqp";
|
|
2
|
+
import type { AccessToken } from "@azure/core-auth";
|
|
3
|
+
import type { ConnectionContext } from "./connectionContext.js";
|
|
4
|
+
import type { OperationOptions } from "./util/operationOptions.js";
|
|
5
5
|
/**
|
|
6
6
|
* Describes the runtime information of an Event Hub.
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managementClient.d.ts","sourceRoot":"","sources":["../../src/managementClient.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"managementClient.d.ts","sour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AAC,QAAQ,CAAC,OAAO,CAAS;IACjC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,CAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IAEtC;;;;;OAKG;gBACS,OAAO,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAE,uBAA4B;IAS3F;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAiBrD;;OAEG;IACG,qBAAqB,CACzB,OAAO,GAAE,gBAAgB,GAAG;QAAE,YAAY,CAAC,EAAE,YAAY,CAAA;KAAO,GAC/D,OAAO,CAAC,kBAAkB,CAAC;IA8C9B;;;OAGG;IACG,sBAAsB,CAC1B,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,gBAAgB,GAAG;QAAE,YAAY,CAAC,EAAE,YAAY,CAAA;KAAO,GAC/D,OAAO,CAAC,mBAAmB,CAAC;IAyD/B;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBd,KAAK;IAuEnB;;;;OAIG;YACW,sBAAsB;IA6FpC,OAAO,CAAC,8BAA8B;CAGvC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { Constants, RequestResponseLink, RetryOperationType, defaultCancellableLock, isSasTokenProvider, retry, translate, } from "@azure/core-amqp";
|
|
4
|
-
import { ReceiverEvents, SenderEvents
|
|
4
|
+
import { ReceiverEvents, SenderEvents } from "rhea-promise";
|
|
5
5
|
import { logErrorStackTrace, createSimpleLogger, logger, createManagementLogPrefix, } from "./logger.js";
|
|
6
6
|
import { throwErrorIfConnectionClosed, throwTypeErrorIfParameterMissing } from "./util/error.js";
|
|
7
7
|
import { toSpanOptions, tracingClient } from "./diagnostics/tracing.js";
|