@azure/event-hubs 6.0.1-alpha.20250618.1 → 6.0.1-alpha.20250730.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.
Files changed (140) hide show
  1. package/dist/browser/batchingPartitionChannel.js +23 -17
  2. package/dist/browser/batchingPartitionChannel.js.map +1 -1
  3. package/dist/browser/connectionContext.js +18 -32
  4. package/dist/browser/connectionContext.js.map +1 -1
  5. package/dist/browser/diagnostics/instrumentEventData.js +6 -7
  6. package/dist/browser/diagnostics/instrumentEventData.js.map +1 -1
  7. package/dist/browser/eventData.js +6 -4
  8. package/dist/browser/eventData.js.map +1 -1
  9. package/dist/browser/eventDataAdapter.js +5 -2
  10. package/dist/browser/eventDataAdapter.js.map +1 -1
  11. package/dist/browser/eventDataBatch.js +61 -9
  12. package/dist/browser/eventDataBatch.js.map +1 -1
  13. package/dist/browser/eventHubBufferedProducerClient.js +65 -50
  14. package/dist/browser/eventHubBufferedProducerClient.js.map +1 -1
  15. package/dist/browser/eventHubConsumerClient.js +70 -24
  16. package/dist/browser/eventHubConsumerClient.js.map +1 -1
  17. package/dist/browser/eventHubProducerClient.js +58 -15
  18. package/dist/browser/eventHubProducerClient.js.map +1 -1
  19. package/dist/browser/eventHubSender.js +118 -35
  20. package/dist/browser/eventHubSender.js.map +1 -1
  21. package/dist/browser/eventProcessor.js +27 -5
  22. package/dist/browser/eventProcessor.js.map +1 -1
  23. package/dist/browser/impl/awaitableQueue.js +6 -2
  24. package/dist/browser/impl/awaitableQueue.js.map +1 -1
  25. package/dist/browser/impl/partitionAssigner.js +2 -4
  26. package/dist/browser/impl/partitionAssigner.js.map +1 -1
  27. package/dist/browser/impl/partitionGate.js +1 -3
  28. package/dist/browser/impl/partitionGate.js.map +1 -1
  29. package/dist/browser/inMemoryCheckpointStore.js +10 -8
  30. package/dist/browser/inMemoryCheckpointStore.js.map +1 -1
  31. package/dist/browser/loadBalancerStrategies/balancedStrategy.js +1 -0
  32. package/dist/browser/loadBalancerStrategies/balancedStrategy.js.map +1 -1
  33. package/dist/browser/loadBalancerStrategies/greedyStrategy.js +1 -0
  34. package/dist/browser/loadBalancerStrategies/greedyStrategy.js.map +1 -1
  35. package/dist/browser/managementClient.js +53 -19
  36. package/dist/browser/managementClient.js.map +1 -1
  37. package/dist/browser/partitionProcessor.js +5 -2
  38. package/dist/browser/partitionProcessor.js.map +1 -1
  39. package/dist/browser/partitionPump.js +15 -6
  40. package/dist/browser/partitionPump.js.map +1 -1
  41. package/dist/browser/partitionReceiver.js +30 -25
  42. package/dist/browser/partitionReceiver.js.map +1 -1
  43. package/dist/browser/pumpManager.js +3 -1
  44. package/dist/browser/pumpManager.js.map +1 -1
  45. package/dist/browser/util/delayWithoutThrow.js +1 -1
  46. package/dist/browser/util/delayWithoutThrow.js.map +1 -1
  47. package/dist/commonjs/batchingPartitionChannel.js +23 -17
  48. package/dist/commonjs/batchingPartitionChannel.js.map +1 -1
  49. package/dist/commonjs/connectionContext.js +18 -32
  50. package/dist/commonjs/connectionContext.js.map +1 -1
  51. package/dist/commonjs/diagnostics/instrumentEventData.js +6 -7
  52. package/dist/commonjs/diagnostics/instrumentEventData.js.map +1 -1
  53. package/dist/commonjs/eventData.js +6 -4
  54. package/dist/commonjs/eventData.js.map +1 -1
  55. package/dist/commonjs/eventDataAdapter.js +5 -2
  56. package/dist/commonjs/eventDataAdapter.js.map +1 -1
  57. package/dist/commonjs/eventDataBatch.js +61 -9
  58. package/dist/commonjs/eventDataBatch.js.map +1 -1
  59. package/dist/commonjs/eventHubBufferedProducerClient.js +65 -50
  60. package/dist/commonjs/eventHubBufferedProducerClient.js.map +1 -1
  61. package/dist/commonjs/eventHubConsumerClient.js +70 -24
  62. package/dist/commonjs/eventHubConsumerClient.js.map +1 -1
  63. package/dist/commonjs/eventHubProducerClient.js +58 -15
  64. package/dist/commonjs/eventHubProducerClient.js.map +1 -1
  65. package/dist/commonjs/eventHubSender.js +118 -35
  66. package/dist/commonjs/eventHubSender.js.map +1 -1
  67. package/dist/commonjs/eventProcessor.js +27 -5
  68. package/dist/commonjs/eventProcessor.js.map +1 -1
  69. package/dist/commonjs/impl/awaitableQueue.js +6 -2
  70. package/dist/commonjs/impl/awaitableQueue.js.map +1 -1
  71. package/dist/commonjs/impl/partitionAssigner.js +2 -4
  72. package/dist/commonjs/impl/partitionAssigner.js.map +1 -1
  73. package/dist/commonjs/impl/partitionGate.js +1 -3
  74. package/dist/commonjs/impl/partitionGate.js.map +1 -1
  75. package/dist/commonjs/inMemoryCheckpointStore.js +10 -8
  76. package/dist/commonjs/inMemoryCheckpointStore.js.map +1 -1
  77. package/dist/commonjs/loadBalancerStrategies/balancedStrategy.js +1 -0
  78. package/dist/commonjs/loadBalancerStrategies/balancedStrategy.js.map +1 -1
  79. package/dist/commonjs/loadBalancerStrategies/greedyStrategy.js +1 -0
  80. package/dist/commonjs/loadBalancerStrategies/greedyStrategy.js.map +1 -1
  81. package/dist/commonjs/managementClient.js +53 -19
  82. package/dist/commonjs/managementClient.js.map +1 -1
  83. package/dist/commonjs/partitionProcessor.js +5 -2
  84. package/dist/commonjs/partitionProcessor.js.map +1 -1
  85. package/dist/commonjs/partitionPump.js +15 -6
  86. package/dist/commonjs/partitionPump.js.map +1 -1
  87. package/dist/commonjs/partitionReceiver.js +30 -25
  88. package/dist/commonjs/partitionReceiver.js.map +1 -1
  89. package/dist/commonjs/pumpManager.js +3 -1
  90. package/dist/commonjs/pumpManager.js.map +1 -1
  91. package/dist/commonjs/tsdoc-metadata.json +11 -11
  92. package/dist/commonjs/util/delayWithoutThrow.js +1 -1
  93. package/dist/commonjs/util/delayWithoutThrow.js.map +1 -1
  94. package/dist/esm/batchingPartitionChannel.js +23 -17
  95. package/dist/esm/batchingPartitionChannel.js.map +1 -1
  96. package/dist/esm/connectionContext.js +18 -32
  97. package/dist/esm/connectionContext.js.map +1 -1
  98. package/dist/esm/diagnostics/instrumentEventData.js +6 -7
  99. package/dist/esm/diagnostics/instrumentEventData.js.map +1 -1
  100. package/dist/esm/eventData.js +6 -4
  101. package/dist/esm/eventData.js.map +1 -1
  102. package/dist/esm/eventDataAdapter.js +5 -2
  103. package/dist/esm/eventDataAdapter.js.map +1 -1
  104. package/dist/esm/eventDataBatch.js +61 -9
  105. package/dist/esm/eventDataBatch.js.map +1 -1
  106. package/dist/esm/eventHubBufferedProducerClient.js +65 -50
  107. package/dist/esm/eventHubBufferedProducerClient.js.map +1 -1
  108. package/dist/esm/eventHubConsumerClient.js +70 -24
  109. package/dist/esm/eventHubConsumerClient.js.map +1 -1
  110. package/dist/esm/eventHubProducerClient.js +58 -15
  111. package/dist/esm/eventHubProducerClient.js.map +1 -1
  112. package/dist/esm/eventHubSender.js +118 -35
  113. package/dist/esm/eventHubSender.js.map +1 -1
  114. package/dist/esm/eventProcessor.js +27 -5
  115. package/dist/esm/eventProcessor.js.map +1 -1
  116. package/dist/esm/impl/awaitableQueue.js +6 -2
  117. package/dist/esm/impl/awaitableQueue.js.map +1 -1
  118. package/dist/esm/impl/partitionAssigner.js +2 -4
  119. package/dist/esm/impl/partitionAssigner.js.map +1 -1
  120. package/dist/esm/impl/partitionGate.js +1 -3
  121. package/dist/esm/impl/partitionGate.js.map +1 -1
  122. package/dist/esm/inMemoryCheckpointStore.js +10 -8
  123. package/dist/esm/inMemoryCheckpointStore.js.map +1 -1
  124. package/dist/esm/loadBalancerStrategies/balancedStrategy.js +1 -0
  125. package/dist/esm/loadBalancerStrategies/balancedStrategy.js.map +1 -1
  126. package/dist/esm/loadBalancerStrategies/greedyStrategy.js +1 -0
  127. package/dist/esm/loadBalancerStrategies/greedyStrategy.js.map +1 -1
  128. package/dist/esm/managementClient.js +53 -19
  129. package/dist/esm/managementClient.js.map +1 -1
  130. package/dist/esm/partitionProcessor.js +5 -2
  131. package/dist/esm/partitionProcessor.js.map +1 -1
  132. package/dist/esm/partitionPump.js +15 -6
  133. package/dist/esm/partitionPump.js.map +1 -1
  134. package/dist/esm/partitionReceiver.js +30 -25
  135. package/dist/esm/partitionReceiver.js.map +1 -1
  136. package/dist/esm/pumpManager.js +3 -1
  137. package/dist/esm/pumpManager.js.map +1 -1
  138. package/dist/esm/util/delayWithoutThrow.js +1 -1
  139. package/dist/esm/util/delayWithoutThrow.js.map +1 -1
  140. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"eventDataBatch.js","sourceRoot":"","sources":["../../src/eventDataBatch.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oCAAoC,EACpC,aAAa,GACd,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AAGnE;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B;;GAEG;AACH,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,cAAuB;IACtD,OAAO,CACL,sBAAsB,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC1E,OAAO,cAAc,CAAC,MAAM,KAAK,UAAU;QAC3C,OAAO,cAAc,CAAC,KAAK,KAAK,QAAQ;QACxC,OAAO,cAAc,CAAC,WAAW,KAAK,QAAQ,CAC/C,CAAC;AACJ,CAAC;AAsED;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IA4D7B;;;;OAIG;IACH,YACE,OAA0B,EAC1B,cAAsB,EACtB,YAAqB,EACrB,YAAqB,EACrB,WAAoB;QA9CtB;;WAEG;QACK,qBA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AAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport type { EventData } from \"./eventData.js\";\nimport {\n assertIsEventData,\n isAmqpAnnotatedMessage,\n populateIdempotentMessageAnnotations,\n toRheaMessage,\n} from \"./eventData.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { MessageAnnotations, Message as RheaMessage } from \"rhea-promise\";\nimport { message } from \"rhea-promise\";\nimport { isDefined, isObjectWithProperties } from \"@azure/core-util\";\nimport type { OperationTracingOptions, TracingContext } from \"@azure/core-tracing\";\nimport { instrumentEventData } from \"./diagnostics/instrumentEventData.js\";\nimport { throwTypeErrorIfParameterMissing } from \"./util/error.js\";\nimport type { PartitionPublishingProperties } from \"./models/private.js\";\n\n/**\n * The amount of bytes to reserve as overhead for a small message.\n */\nconst smallMessageOverhead = 5;\n/**\n * The amount of bytes to reserve as overhead for a large message.\n */\nconst largeMessageOverhead = 8;\n/**\n * The maximum number of bytes that a message may be to be considered small.\n */\nconst smallMessageMaxBytes = 255;\n\n/**\n * Checks if the provided eventDataBatch is an instance of `EventDataBatch`.\n * @param eventDataBatch - The instance of `EventDataBatch` to verify.\n * @internal\n */\nexport function isEventDataBatch(eventDataBatch: unknown): eventDataBatch is EventDataBatch {\n return (\n isObjectWithProperties(eventDataBatch, [\"count\", \"sizeInBytes\", \"tryAdd\"]) &&\n typeof eventDataBatch.tryAdd === \"function\" &&\n typeof eventDataBatch.count === \"number\" &&\n typeof eventDataBatch.sizeInBytes === \"number\"\n );\n}\n\n/**\n * Options to configure the behavior of the `tryAdd` method on the `EventDataBatch` class.\n */\nexport interface TryAddOptions {\n /**\n * The options to use when creating Spans for tracing.\n */\n tracingOptions?: OperationTracingOptions;\n}\n\n/**\n * An interface representing a batch of events which can be used to send events to Event Hub.\n *\n * To create the batch, use the `createBatch()` method on the `EventHubProducerClient`.\n * To send the batch, use the `sendBatch()` method on the same client.\n * To fill the batch, use the `tryAdd()` method on the batch itself.\n *\n */\nexport interface EventDataBatch {\n /**\n * A value that is hashed and used by the Azure Event Hubs service to determine the partition to\n * which the events are sent. Use the `createBatch()` method on the `EventHubProducerClient` to\n * set the partitionKey.\n * @readonly\n * @internal\n */\n readonly partitionKey?: string;\n\n /**\n * Id of the partition to which the batch of events are sent. Use the `createBatch()` method on\n * the `EventHubProducerClient` to set the partitionId.\n * @readonly\n * @internal\n */\n readonly partitionId?: string;\n\n /**\n * Size of the batch in bytes after the events added to it have been encoded into a single AMQP\n * message.\n * @readonly\n */\n readonly sizeInBytes: number;\n\n /**\n * Number of events added to the batch.\n * @readonly\n */\n readonly count: number;\n\n /**\n * The maximum size of the batch, in bytes. The `tryAdd` function on the batch will return `false`\n * if the event being added causes the size of the batch to exceed this limit. Use the `createBatch()` method on\n * the `EventHubProducerClient` to set the maxSizeInBytes.\n * @readonly\n */\n readonly maxSizeInBytes: number;\n\n /**\n * Adds an event to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next event.\n *\n * @param eventData - An individual event data object or AmqpAnnotatedMessage.\n * @returns A boolean value indicating if the event data has been added to the batch or not.\n */\n tryAdd(eventData: EventData | AmqpAnnotatedMessage, options?: TryAddOptions): boolean;\n}\n\n/**\n * An internal class representing a batch of events which can be used to send events to Event Hub.\n *\n * @internal\n */\nexport class EventDataBatchImpl implements EventDataBatch {\n /**\n * Describes the amqp connection context for the Client.\n */\n private _context: ConnectionContext;\n /**\n * The Id of the partition to which the batch is expected to be sent to.\n * Specifying this will throw an error if the batch was created using a `partitionKey`.\n */\n private _partitionId?: string;\n /**\n * A value that is hashed to produce a partition assignment.\n * It guarantees that messages with the same partitionKey end up in the same partition.\n * Specifying this will throw an error if the batch was created using a `partitionId`.\n */\n private _partitionKey?: string;\n /**\n * The maximum size allowed for the batch.\n */\n private _maxSizeInBytes: number;\n /**\n * Current size of the batch in bytes.\n */\n private _sizeInBytes: number;\n /**\n * Encoded amqp messages.\n */\n private _encodedMessages: Buffer[] = [];\n /**\n * Number of events in the batch.\n */\n private _count: number;\n /**\n * List of 'message' span contexts.\n */\n private _spanContexts: TracingContext[] = [];\n /**\n * The message annotations to apply on the batch envelope.\n * This will reflect the message annotations on the first event\n * that was added to the batch.\n * A common annotation is the partition key.\n */\n private _batchAnnotations?: MessageAnnotations;\n /**\n * Indicates that the batch should be treated as idempotent.\n */\n private _isIdempotent: boolean;\n /**\n * The sequence number assigned to the first event in the batch while\n * the batch is being sent to the service.\n */\n private _pendingStartingSequenceNumber?: number;\n /**\n * The publishing sequence number assigned to the first event in the batch at the time\n * the batch was successfully published.\n * If the producer was not configured to apply sequence numbering or if the batch\n * has not yet been successfully published, the value will be `undefined`.\n */\n private _startingPublishSequenceNumber?: number;\n\n /**\n * EventDataBatch should not be constructed using `new EventDataBatch()`\n * Use the `createBatch()` method on your `EventHubProducer` instead.\n * @internal\n */\n constructor(\n context: ConnectionContext,\n maxSizeInBytes: number,\n isIdempotent: boolean,\n partitionKey?: string,\n partitionId?: string,\n ) {\n this._context = context;\n this._maxSizeInBytes = maxSizeInBytes;\n this._isIdempotent = isIdempotent;\n this._partitionKey = isDefined(partitionKey) ? String(partitionKey) : partitionKey;\n this._partitionId = isDefined(partitionId) ? String(partitionId) : partitionId;\n this._sizeInBytes = 0;\n this._count = 0;\n }\n\n /**\n * The maximum size of the batch, in bytes.\n * @readonly\n */\n get maxSizeInBytes(): number {\n return this._maxSizeInBytes;\n }\n\n /**\n * The partitionKey set during `EventDataBatch` creation. This value is hashed to\n * produce a partition assignment when the producer is created without a `partitionId`\n * @readonly\n */\n get partitionKey(): string | undefined {\n return this._partitionKey;\n }\n\n /**\n * The partitionId set during `EventDataBatch` creation.\n * If this value is set then partitionKey can not be set.\n * @readonly\n */\n get partitionId(): string | undefined {\n return this._partitionId;\n }\n\n /**\n * Size of the `EventDataBatch` instance after the events added to it have been\n * encoded into a single AMQP message.\n * @readonly\n */\n get sizeInBytes(): number {\n return this._sizeInBytes;\n }\n\n /**\n * Number of events in the `EventDataBatch` instance.\n * @readonly\n */\n get count(): number {\n return this._count;\n }\n\n /**\n * The publishing sequence number assigned to the first event in the batch at the time\n * the batch was successfully published.\n * If the producer was not configured to apply sequence numbering or if the batch\n * has not yet been successfully published, the value will be `undefined`.\n */\n get startingPublishedSequenceNumber(): number | undefined {\n return this._startingPublishSequenceNumber;\n }\n\n /**\n * Gets the \"message\" span contexts that were created when adding events to the batch.\n * @internal\n */\n get _messageSpanContexts(): TracingContext[] {\n return this._spanContexts;\n }\n\n /**\n * Generates an AMQP message that contains the provided encoded events and annotations.\n * @param encodedEvents - The already encoded events to include in the AMQP batch.\n * @param annotations - The message annotations to set on the batch.\n * @param publishingProps - Idempotent publishing properties used to decorate the events in the batch while sending.\n */\n private _generateBatch(\n encodedEvents: Buffer[],\n annotations: MessageAnnotations | undefined,\n publishingProps?: PartitionPublishingProperties,\n ): Buffer {\n if (this._isIdempotent && publishingProps) {\n // We need to decode the encoded events, add the idempotent annotations, and re-encode them.\n // We can't lazily encode the events because we rely on `message.encode` to capture the\n // byte length of anything not in `event.body`.\n // Events can't be decorated ahead of time because the publishing properties aren't known\n // until the events are being sent to the service.\n const decodedEvents = encodedEvents.map(message.decode) as unknown as RheaMessage[];\n const decoratedEvents = this._decorateRheaMessagesWithPublishingProps(\n decodedEvents,\n publishingProps,\n );\n encodedEvents = decoratedEvents.map(message.encode);\n }\n\n const batchEnvelope: RheaMessage = {\n body: message.data_sections(encodedEvents),\n };\n if (annotations) {\n batchEnvelope.message_annotations = annotations;\n }\n return message.encode(batchEnvelope);\n }\n\n /**\n * Uses the publishingProps to add idempotent properties as message annotations to rhea messages.\n */\n private _decorateRheaMessagesWithPublishingProps(\n events: RheaMessage[],\n publishingProps: PartitionPublishingProperties,\n ): RheaMessage[] {\n if (!this._isIdempotent) {\n return events;\n }\n\n const { lastPublishedSequenceNumber = 0, ownerLevel, producerGroupId } = publishingProps;\n const startingSequenceNumber = lastPublishedSequenceNumber + 1;\n for (let i = 0; i < events.length; i++) {\n const event = events[i];\n populateIdempotentMessageAnnotations(event, {\n isIdempotentPublishingEnabled: this._isIdempotent,\n ownerLevel,\n producerGroupId,\n publishSequenceNumber: startingSequenceNumber + i,\n });\n }\n\n this._pendingStartingSequenceNumber = startingSequenceNumber;\n return events;\n }\n\n /**\n * Annotates a rhea message with placeholder idempotent properties if the batch is idempotent.\n * This is necessary so that we can accurately calculate the size of the batch while adding events.\n * Placeholder values are used because real values won't be known until we attempt to send the batch.\n */\n private _decorateRheaMessageWithPlaceholderIdempotencyProps(event: RheaMessage): RheaMessage {\n if (!this._isIdempotent) {\n return event;\n }\n\n if (!event.message_annotations) {\n event.message_annotations = {};\n }\n\n // Set placeholder values for these annotations.\n populateIdempotentMessageAnnotations(event, {\n isIdempotentPublishingEnabled: this._isIdempotent,\n ownerLevel: 0,\n publishSequenceNumber: 0,\n producerGroupId: 0,\n });\n\n return event;\n }\n\n /**\n * Generates the single AMQP message which is the result of encoding all the events\n * added into the `EventDataBatch` instance.\n *\n * This is not meant for the user to use directly.\n *\n * When the `EventDataBatch` instance is passed to the `send()` method on the `EventHubProducer`,\n * this single batched AMQP message is what gets sent over the wire to the service.\n * @readonly\n */\n _generateMessage(publishingProps?: PartitionPublishingProperties): Buffer {\n return this._generateBatch(this._encodedMessages, this._batchAnnotations, publishingProps);\n }\n\n /**\n * Sets startingPublishSequenceNumber to the pending publish sequence number.\n */\n _commitPublish(): void {\n this._startingPublishSequenceNumber = this._pendingStartingSequenceNumber;\n }\n\n /**\n * Tries to add an event data to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next event.\n *\n * @param eventData - An individual event data object.\n * @returns A boolean value indicating if the event data has been added to the batch or not.\n */\n public tryAdd(eventData: EventData | AmqpAnnotatedMessage, options: TryAddOptions = {}): boolean {\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"tryAdd\", \"eventData\", eventData);\n if (!isAmqpAnnotatedMessage(eventData)) {\n assertIsEventData(eventData);\n }\n\n const { entityPath, host } = this._context.config;\n const { event: instrumentedEvent, spanContext } = instrumentEventData(\n eventData,\n options,\n entityPath,\n host,\n );\n\n // Convert EventData to RheaMessage.\n const amqpMessage = toRheaMessage(instrumentedEvent, this._partitionKey);\n const originalAnnotations = amqpMessage.message_annotations && {\n ...amqpMessage.message_annotations,\n };\n this._decorateRheaMessageWithPlaceholderIdempotencyProps(amqpMessage);\n const encodedMessage = message.encode(amqpMessage);\n\n let currentSize = this._sizeInBytes;\n // The first time an event is added, we need to calculate\n // the overhead of creating an AMQP batch, including the\n // message_annotations that are taken from the 1st message.\n if (this.count === 0) {\n if (originalAnnotations) {\n this._batchAnnotations = originalAnnotations;\n }\n\n // Figure out the overhead of creating a batch by generating an empty batch\n // with the expected batch annotations.\n currentSize += this._generateBatch([], this._batchAnnotations).length;\n }\n\n const messageSize = encodedMessage.length;\n const messageOverhead =\n messageSize <= smallMessageMaxBytes ? smallMessageOverhead : largeMessageOverhead;\n currentSize += messageSize + messageOverhead;\n\n // Check if the size of the batch exceeds the maximum allowed size\n // once we add the new event to it.\n if (currentSize > this._maxSizeInBytes) {\n return false;\n }\n\n // The event will fit in the batch, so it is now safe to store it.\n this._encodedMessages.push(encodedMessage);\n if (spanContext) {\n this._spanContexts.push(spanContext);\n }\n\n this._sizeInBytes = currentSize;\n this._count++;\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"eventDataBatch.js","sourceRoot":"","sources":["../../src/eventDataBatch.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oCAAoC,EACpC,aAAa,GACd,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,mBAAmB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AC;QACtE,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAEnD,IAAI,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACpC,yDAAyD;QACzD,wDAAwD;QACxD,2DAA2D;QAC3D,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YACrB,IAAI,mBAAmB,EAAE,CAAC;gBACxB,IAAI,CAAC,iBAAiB,GAAG,mBAAmB,CAAC;YAC/C,CAAC;YAED,2EAA2E;YAC3E,uCAAuC;YACvC,WAAW,IAAI,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC;QACxE,CAAC;QAED,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC;QAC1C,MAAM,eAAe,GACnB,WAAW,IAAI,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,CAAC;QACpF,WAAW,IAAI,WAAW,GAAG,eAAe,CAAC;QAE7C,kEAAkE;QAClE,mCAAmC;QACnC,IAAI,WAAW,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,kEAAkE;QAClE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3C,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport type { EventData } from \"./eventData.js\";\nimport {\n assertIsEventData,\n isAmqpAnnotatedMessage,\n populateIdempotentMessageAnnotations,\n toRheaMessage,\n} from \"./eventData.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { MessageAnnotations, Message as RheaMessage } from \"rhea-promise\";\nimport { message } from \"rhea-promise\";\nimport { isDefined, isObjectWithProperties } from \"@azure/core-util\";\nimport type { OperationTracingOptions, TracingContext } from \"@azure/core-tracing\";\nimport { instrumentEventData } from \"./diagnostics/instrumentEventData.js\";\nimport { throwTypeErrorIfParameterMissing } from \"./util/error.js\";\nimport type { PartitionPublishingProperties } from \"./models/private.js\";\n\n/**\n * The amount of bytes to reserve as overhead for a small message.\n */\nconst smallMessageOverhead = 5;\n/**\n * The amount of bytes to reserve as overhead for a large message.\n */\nconst largeMessageOverhead = 8;\n/**\n * The maximum number of bytes that a message may be to be considered small.\n */\nconst smallMessageMaxBytes = 255;\n\n/**\n * Checks if the provided eventDataBatch is an instance of `EventDataBatch`.\n * @param eventDataBatch - The instance of `EventDataBatch` to verify.\n * @internal\n */\nexport function isEventDataBatch(eventDataBatch: unknown): eventDataBatch is EventDataBatch {\n return (\n isObjectWithProperties(eventDataBatch, [\"count\", \"sizeInBytes\", \"tryAdd\"]) &&\n typeof eventDataBatch.tryAdd === \"function\" &&\n typeof eventDataBatch.count === \"number\" &&\n typeof eventDataBatch.sizeInBytes === \"number\"\n );\n}\n\n/**\n * Options to configure the behavior of the `tryAdd` method on the `EventDataBatch` class.\n */\nexport interface TryAddOptions {\n /**\n * The options to use when creating Spans for tracing.\n */\n tracingOptions?: OperationTracingOptions;\n}\n\n/**\n * An interface representing a batch of events which can be used to send events to Event Hub.\n *\n * To create the batch, use the `createBatch()` method on the `EventHubProducerClient`.\n * To send the batch, use the `sendBatch()` method on the same client.\n * To fill the batch, use the `tryAdd()` method on the batch itself.\n *\n */\nexport interface EventDataBatch {\n /**\n * A value that is hashed and used by the Azure Event Hubs service to determine the partition to\n * which the events are sent. Use the `createBatch()` method on the `EventHubProducerClient` to\n * set the partitionKey.\n * @readonly\n * @internal\n */\n readonly partitionKey?: string;\n\n /**\n * Id of the partition to which the batch of events are sent. Use the `createBatch()` method on\n * the `EventHubProducerClient` to set the partitionId.\n * @readonly\n * @internal\n */\n readonly partitionId?: string;\n\n /**\n * Size of the batch in bytes after the events added to it have been encoded into a single AMQP\n * message.\n * @readonly\n */\n readonly sizeInBytes: number;\n\n /**\n * Number of events added to the batch.\n * @readonly\n */\n readonly count: number;\n\n /**\n * The maximum size of the batch, in bytes. The `tryAdd` function on the batch will return `false`\n * if the event being added causes the size of the batch to exceed this limit. Use the `createBatch()` method on\n * the `EventHubProducerClient` to set the maxSizeInBytes.\n * @readonly\n */\n readonly maxSizeInBytes: number;\n\n /**\n * Adds an event to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next event.\n *\n * @param eventData - An individual event data object or AmqpAnnotatedMessage.\n * @returns A boolean value indicating if the event data has been added to the batch or not.\n */\n tryAdd(eventData: EventData | AmqpAnnotatedMessage, options?: TryAddOptions): boolean;\n}\n\n/**\n * An internal class representing a batch of events which can be used to send events to Event Hub.\n *\n * @internal\n */\nexport class EventDataBatchImpl implements EventDataBatch {\n /**\n * Describes the amqp connection context for the Client.\n */\n private _context: ConnectionContext;\n /**\n * The Id of the partition to which the batch is expected to be sent to.\n * Specifying this will throw an error if the batch was created using a `partitionKey`.\n */\n private _partitionId?: string;\n /**\n * A value that is hashed to produce a partition assignment.\n * It guarantees that messages with the same partitionKey end up in the same partition.\n * Specifying this will throw an error if the batch was created using a `partitionId`.\n */\n private _partitionKey?: string;\n /**\n * The maximum size allowed for the batch.\n */\n private _maxSizeInBytes: number;\n /**\n * Current size of the batch in bytes.\n */\n private _sizeInBytes: number;\n /**\n * Encoded amqp messages.\n */\n private _encodedMessages: Buffer[] = [];\n /**\n * Number of events in the batch.\n */\n private _count: number;\n /**\n * List of 'message' span contexts.\n */\n private _spanContexts: TracingContext[] = [];\n /**\n * The message annotations to apply on the batch envelope.\n * This will reflect the message annotations on the first event\n * that was added to the batch.\n * A common annotation is the partition key.\n */\n private _batchAnnotations?: MessageAnnotations;\n /**\n * Indicates that the batch should be treated as idempotent.\n */\n private _isIdempotent: boolean;\n /**\n * The sequence number assigned to the first event in the batch while\n * the batch is being sent to the service.\n */\n private _pendingStartingSequenceNumber?: number;\n /**\n * The publishing sequence number assigned to the first event in the batch at the time\n * the batch was successfully published.\n * If the producer was not configured to apply sequence numbering or if the batch\n * has not yet been successfully published, the value will be `undefined`.\n */\n private _startingPublishSequenceNumber?: number;\n\n /**\n * EventDataBatch should not be constructed using `new EventDataBatch()`\n * Use the `createBatch()` method on your `EventHubProducer` instead.\n * @internal\n */\n constructor(\n context: ConnectionContext,\n maxSizeInBytes: number,\n isIdempotent: boolean,\n partitionKey?: string,\n partitionId?: string,\n ) {\n this._context = context;\n this._maxSizeInBytes = maxSizeInBytes;\n this._isIdempotent = isIdempotent;\n this._partitionKey = isDefined(partitionKey) ? String(partitionKey) : partitionKey;\n this._partitionId = isDefined(partitionId) ? String(partitionId) : partitionId;\n this._sizeInBytes = 0;\n this._count = 0;\n }\n\n /**\n * The maximum size of the batch, in bytes.\n * @readonly\n */\n get maxSizeInBytes(): number {\n return this._maxSizeInBytes;\n }\n\n /**\n * The partitionKey set during `EventDataBatch` creation. This value is hashed to\n * produce a partition assignment when the producer is created without a `partitionId`\n * @readonly\n */\n get partitionKey(): string | undefined {\n return this._partitionKey;\n }\n\n /**\n * The partitionId set during `EventDataBatch` creation.\n * If this value is set then partitionKey can not be set.\n * @readonly\n */\n get partitionId(): string | undefined {\n return this._partitionId;\n }\n\n /**\n * Size of the `EventDataBatch` instance after the events added to it have been\n * encoded into a single AMQP message.\n * @readonly\n */\n get sizeInBytes(): number {\n return this._sizeInBytes;\n }\n\n /**\n * Number of events in the `EventDataBatch` instance.\n * @readonly\n */\n get count(): number {\n return this._count;\n }\n\n /**\n * The publishing sequence number assigned to the first event in the batch at the time\n * the batch was successfully published.\n * If the producer was not configured to apply sequence numbering or if the batch\n * has not yet been successfully published, the value will be `undefined`.\n */\n get startingPublishedSequenceNumber(): number | undefined {\n return this._startingPublishSequenceNumber;\n }\n\n /**\n * Gets the \"message\" span contexts that were created when adding events to the batch.\n * @internal\n */\n get _messageSpanContexts(): TracingContext[] {\n return this._spanContexts;\n }\n\n /**\n * Generates an AMQP message that contains the provided encoded events and annotations.\n * @param encodedEvents - The already encoded events to include in the AMQP batch.\n * @param annotations - The message annotations to set on the batch.\n * @param publishingProps - Idempotent publishing properties used to decorate the events in the batch while sending.\n */\n private _generateBatch(\n encodedEvents: Buffer[],\n annotations: MessageAnnotations | undefined,\n publishingProps?: PartitionPublishingProperties,\n ): Buffer {\n if (this._isIdempotent && publishingProps) {\n // We need to decode the encoded events, add the idempotent annotations, and re-encode them.\n // We can't lazily encode the events because we rely on `message.encode` to capture the\n // byte length of anything not in `event.body`.\n // Events can't be decorated ahead of time because the publishing properties aren't known\n // until the events are being sent to the service.\n const decodedEvents = encodedEvents.map(message.decode) as unknown as RheaMessage[];\n const decoratedEvents = this._decorateRheaMessagesWithPublishingProps(\n decodedEvents,\n publishingProps,\n );\n encodedEvents = decoratedEvents.map(message.encode);\n }\n\n const batchEnvelope: RheaMessage = {\n body: message.data_sections(encodedEvents),\n };\n if (annotations) {\n batchEnvelope.message_annotations = annotations;\n }\n return message.encode(batchEnvelope);\n }\n\n /**\n * Uses the publishingProps to add idempotent properties as message annotations to rhea messages.\n */\n private _decorateRheaMessagesWithPublishingProps(\n events: RheaMessage[],\n publishingProps: PartitionPublishingProperties,\n ): RheaMessage[] {\n if (!this._isIdempotent) {\n return events;\n }\n\n const { lastPublishedSequenceNumber = 0, ownerLevel, producerGroupId } = publishingProps;\n const startingSequenceNumber = lastPublishedSequenceNumber + 1;\n for (let i = 0; i < events.length; i++) {\n const event = events[i];\n populateIdempotentMessageAnnotations(event, {\n isIdempotentPublishingEnabled: this._isIdempotent,\n ownerLevel,\n producerGroupId,\n publishSequenceNumber: startingSequenceNumber + i,\n });\n }\n\n this._pendingStartingSequenceNumber = startingSequenceNumber;\n return events;\n }\n\n /**\n * Annotates a rhea message with placeholder idempotent properties if the batch is idempotent.\n * This is necessary so that we can accurately calculate the size of the batch while adding events.\n * Placeholder values are used because real values won't be known until we attempt to send the batch.\n */\n private _decorateRheaMessageWithPlaceholderIdempotencyProps(event: RheaMessage): RheaMessage {\n if (!this._isIdempotent) {\n return event;\n }\n\n if (!event.message_annotations) {\n event.message_annotations = {};\n }\n\n // Set placeholder values for these annotations.\n populateIdempotentMessageAnnotations(event, {\n isIdempotentPublishingEnabled: this._isIdempotent,\n ownerLevel: 0,\n publishSequenceNumber: 0,\n producerGroupId: 0,\n });\n\n return event;\n }\n\n /**\n * Generates the single AMQP message which is the result of encoding all the events\n * added into the `EventDataBatch` instance.\n *\n * This is not meant for the user to use directly.\n *\n * When the `EventDataBatch` instance is passed to the `send()` method on the `EventHubProducer`,\n * this single batched AMQP message is what gets sent over the wire to the service.\n * @readonly\n */\n _generateMessage(publishingProps?: PartitionPublishingProperties): Buffer {\n return this._generateBatch(this._encodedMessages, this._batchAnnotations, publishingProps);\n }\n\n /**\n * Sets startingPublishSequenceNumber to the pending publish sequence number.\n */\n _commitPublish(): void {\n this._startingPublishSequenceNumber = this._pendingStartingSequenceNumber;\n }\n\n /**\n * Tries to add an event data to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next event.\n *\n * @param eventData - An individual event data object.\n * @returns A boolean value indicating if the event data has been added to the batch or not.\n */\n public tryAdd(eventData: EventData | AmqpAnnotatedMessage, options: TryAddOptions = {}): boolean {\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"tryAdd\", \"eventData\", eventData);\n if (!isAmqpAnnotatedMessage(eventData)) {\n assertIsEventData(eventData);\n }\n\n const { entityPath, host } = this._context.config;\n const { event: instrumentedEvent, spanContext } = instrumentEventData(\n eventData,\n options,\n entityPath,\n host,\n );\n\n // Convert EventData to RheaMessage.\n const amqpMessage = toRheaMessage(instrumentedEvent, this._partitionKey);\n const originalAnnotations = amqpMessage.message_annotations && {\n ...amqpMessage.message_annotations,\n };\n this._decorateRheaMessageWithPlaceholderIdempotencyProps(amqpMessage);\n const encodedMessage = message.encode(amqpMessage);\n\n let currentSize = this._sizeInBytes;\n // The first time an event is added, we need to calculate\n // the overhead of creating an AMQP batch, including the\n // message_annotations that are taken from the 1st message.\n if (this.count === 0) {\n if (originalAnnotations) {\n this._batchAnnotations = originalAnnotations;\n }\n\n // Figure out the overhead of creating a batch by generating an empty batch\n // with the expected batch annotations.\n currentSize += this._generateBatch([], this._batchAnnotations).length;\n }\n\n const messageSize = encodedMessage.length;\n const messageOverhead =\n messageSize <= smallMessageMaxBytes ? smallMessageOverhead : largeMessageOverhead;\n currentSize += messageSize + messageOverhead;\n\n // Check if the size of the batch exceeds the maximum allowed size\n // once we add the new event to it.\n if (currentSize > this._maxSizeInBytes) {\n return false;\n }\n\n // The event will fit in the batch, so it is now safe to store it.\n this._encodedMessages.push(encodedMessage);\n if (spanContext) {\n this._spanContexts.push(spanContext);\n }\n\n this._sizeInBytes = currentSize;\n this._count++;\n return true;\n }\n}\n"]}
@@ -37,6 +37,44 @@ import { getRandomName } from "./util/utils.js";
37
37
  * `EventHubProducerClient` is recommended.
38
38
  */
39
39
  export class EventHubBufferedProducerClient {
40
+ /**
41
+ * Controls the `abortSignal` passed to each `BatchingPartitionChannel`.
42
+ * Used to signal when a channel should stop waiting for events.
43
+ */
44
+ _abortController = new AbortController();
45
+ /**
46
+ * Indicates whether the client has been explicitly closed.
47
+ */
48
+ _isClosed = false;
49
+ /**
50
+ * Handles assigning partitions.
51
+ */
52
+ _partitionAssigner = new PartitionAssigner();
53
+ /**
54
+ * The known partitionIds that will be used when assigning events to partitions.
55
+ */
56
+ _partitionIds = [];
57
+ /**
58
+ * The EventHubProducerClient to use when creating and sending batches to the Event Hub.
59
+ */
60
+ _producer;
61
+ /**
62
+ * Mapping of partitionIds to `BatchingPartitionChannels`.
63
+ * Each `BatchingPartitionChannel` handles buffering events and backpressure independently.
64
+ */
65
+ _partitionChannels = new Map();
66
+ /**
67
+ * The options passed by the user when creating the EventHubBufferedProducerClient instance.
68
+ */
69
+ _clientOptions;
70
+ /**
71
+ * The interval at which the background management operation should run.
72
+ */
73
+ _backgroundManagementInterval = 10000; // 10 seconds
74
+ /**
75
+ * Indicates whether the background management loop is running.
76
+ */
77
+ _isBackgroundManagementRunning = false;
40
78
  /**
41
79
  * @readonly
42
80
  * The name of the Event Hub instance for which this client is created.
@@ -52,52 +90,29 @@ export class EventHubBufferedProducerClient {
52
90
  get fullyQualifiedNamespace() {
53
91
  return this._producer.fullyQualifiedNamespace;
54
92
  }
93
+ /**
94
+ * The name used to identify this EventHubBufferedProducerClient.
95
+ * If not specified or empty, a random unique one will be generated.
96
+ */
97
+ identifier;
55
98
  constructor(fullyQualifiedNamespaceOrConnectionString1, eventHubNameOrOptions2, credentialOrOptions3, options4) {
56
- var _a, _b, _c;
57
- /**
58
- * Controls the `abortSignal` passed to each `BatchingPartitionChannel`.
59
- * Used to signal when a channel should stop waiting for events.
60
- */
61
- this._abortController = new AbortController();
62
- /**
63
- * Indicates whether the client has been explicitly closed.
64
- */
65
- this._isClosed = false;
66
- /**
67
- * Handles assigning partitions.
68
- */
69
- this._partitionAssigner = new PartitionAssigner();
70
- /**
71
- * The known partitionIds that will be used when assigning events to partitions.
72
- */
73
- this._partitionIds = [];
74
- /**
75
- * Mapping of partitionIds to `BatchingPartitionChannels`.
76
- * Each `BatchingPartitionChannel` handles buffering events and backpressure independently.
77
- */
78
- this._partitionChannels = new Map();
79
- /**
80
- * The interval at which the background management operation should run.
81
- */
82
- this._backgroundManagementInterval = 10000; // 10 seconds
83
- /**
84
- * Indicates whether the background management loop is running.
85
- */
86
- this._isBackgroundManagementRunning = false;
87
99
  if (typeof eventHubNameOrOptions2 !== "string") {
88
- this.identifier = (_a = eventHubNameOrOptions2.identifier) !== null && _a !== void 0 ? _a : getRandomName();
89
- this._producer = new EventHubProducerClient(fullyQualifiedNamespaceOrConnectionString1, Object.assign(Object.assign({}, eventHubNameOrOptions2), { identifier: this.identifier }));
90
- this._clientOptions = Object.assign({}, eventHubNameOrOptions2);
100
+ this.identifier = eventHubNameOrOptions2.identifier ?? getRandomName();
101
+ this._producer = new EventHubProducerClient(fullyQualifiedNamespaceOrConnectionString1, {
102
+ ...eventHubNameOrOptions2,
103
+ identifier: this.identifier,
104
+ });
105
+ this._clientOptions = { ...eventHubNameOrOptions2 };
91
106
  }
92
107
  else if (!isCredential(credentialOrOptions3)) {
93
- this.identifier = (_b = credentialOrOptions3 === null || credentialOrOptions3 === void 0 ? void 0 : credentialOrOptions3.identifier) !== null && _b !== void 0 ? _b : getRandomName();
94
- this._producer = new EventHubProducerClient(fullyQualifiedNamespaceOrConnectionString1, eventHubNameOrOptions2, Object.assign(Object.assign({}, credentialOrOptions3), { identifier: this.identifier }));
95
- this._clientOptions = Object.assign({}, credentialOrOptions3);
108
+ this.identifier = credentialOrOptions3?.identifier ?? getRandomName();
109
+ this._producer = new EventHubProducerClient(fullyQualifiedNamespaceOrConnectionString1, eventHubNameOrOptions2, { ...credentialOrOptions3, identifier: this.identifier });
110
+ this._clientOptions = { ...credentialOrOptions3 };
96
111
  }
97
112
  else {
98
- this.identifier = (_c = options4 === null || options4 === void 0 ? void 0 : options4.identifier) !== null && _c !== void 0 ? _c : getRandomName();
99
- this._producer = new EventHubProducerClient(fullyQualifiedNamespaceOrConnectionString1, eventHubNameOrOptions2, credentialOrOptions3, Object.assign(Object.assign({}, options4), { identifier: this.identifier }));
100
- this._clientOptions = Object.assign({}, options4);
113
+ this.identifier = options4?.identifier ?? getRandomName();
114
+ this._producer = new EventHubProducerClient(fullyQualifiedNamespaceOrConnectionString1, eventHubNameOrOptions2, credentialOrOptions3, { ...options4, identifier: this.identifier });
115
+ this._clientOptions = { ...options4 };
101
116
  }
102
117
  // setting internal idempotent publishing option on the standard producer.
103
118
  this._producer._enableIdempotentRetries = this._clientOptions.enableIdempotentRetries;
@@ -240,16 +255,16 @@ export class EventHubBufferedProducerClient {
240
255
  * If one does not exist, it is created.
241
256
  */
242
257
  _getPartitionChannel(partitionId) {
243
- var _a;
244
- const partitionChannel = (_a = this._partitionChannels.get(partitionId)) !== null && _a !== void 0 ? _a : new BatchingPartitionChannel({
245
- loopAbortSignal: this._abortController.signal,
246
- maxBufferSize: this._clientOptions.maxEventBufferLengthPerPartition || 1500,
247
- maxWaitTimeInMs: this._clientOptions.maxWaitTimeInMs || 1000,
248
- onSendEventsErrorHandler: this._clientOptions.onSendEventsErrorHandler,
249
- onSendEventsSuccessHandler: this._clientOptions.onSendEventsSuccessHandler,
250
- partitionId,
251
- producer: this._producer,
252
- });
258
+ const partitionChannel = this._partitionChannels.get(partitionId) ??
259
+ new BatchingPartitionChannel({
260
+ loopAbortSignal: this._abortController.signal,
261
+ maxBufferSize: this._clientOptions.maxEventBufferLengthPerPartition || 1500,
262
+ maxWaitTimeInMs: this._clientOptions.maxWaitTimeInMs || 1000,
263
+ onSendEventsErrorHandler: this._clientOptions.onSendEventsErrorHandler,
264
+ onSendEventsSuccessHandler: this._clientOptions.onSendEventsSuccessHandler,
265
+ partitionId,
266
+ producer: this._producer,
267
+ });
253
268
  this._partitionChannels.set(partitionId, partitionChannel);
254
269
  return partitionChannel;
255
270
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eventHubBufferedProducerClient.js","sourceRoot":"","sources":["../../src/eventHubBufferedProducerClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAWrE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,M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C,GAAG,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;QAC3D,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,4BAA4B;QAClC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACnD,KAAK,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;QAC7C,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,KAAK,CAAC,mBAAmB;QAC/B,MAAM,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC;QACvD,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAEzD,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAC7D,MAAM,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;YAChD,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC;YACzC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,4BAA4B;QACxC,MAAM,CAAC,OAAO,CAAC,uEAAuE,CAAC,CAAC;QACxF,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YAChE,MAAM,KAAK,CAAO,IAAI,CAAC,6BAA6B,CAAC,CAAC;YACtD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACpB,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { EventData } from \"./eventData.js\";\nimport { EventHubProducerClient } from \"./eventHubProducerClient.js\";\nimport type { OperationOptions } from \"./util/operationOptions.js\";\nimport type {\n EventHubClientOptions,\n GetEventHubPropertiesOptions,\n GetPartitionIdsOptions,\n GetPartitionPropertiesOptions,\n SendBatchOptions,\n} from \"./models/public.js\";\nimport type { EventHubProperties, PartitionProperties } from \"./managementClient.js\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isDefined } from \"@azure/core-util\";\nimport { isCredential } from \"./util/typeGuards.js\";\nimport type { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { delay } from \"@azure/core-amqp\";\nimport { BatchingPartitionChannel } from \"./batchingPartitionChannel.js\";\nimport { PartitionAssigner } from \"./impl/partitionAssigner.js\";\nimport { logger } from \"./logger.js\";\nimport { getRandomName } from \"./util/utils.js\";\n\n/**\n * Contains the events that were successfully sent to the Event Hub,\n * and the partition they were assigned to.\n */\nexport interface OnSendEventsSuccessContext {\n /**\n * The partition each event was assigned.\n */\n partitionId: string;\n /**\n * The array of {@link EventData} and/or `AmqpAnnotatedMessage` that were successfully sent to the Event Hub.\n */\n events: Array<EventData | AmqpAnnotatedMessage>;\n}\n\n/**\n * Contains the events that were not successfully sent to the Event Hub,\n * the partition they were assigned to, and the error that was encountered while sending.\n */\nexport interface OnSendEventsErrorContext {\n /**\n * The partition each event was assigned.\n */\n partitionId: string;\n /**\n * The array of {@link EventData} and/or `AmqpAnnotatedMessage` that were not successfully sent to the Event Hub.\n */\n events: Array<EventData | AmqpAnnotatedMessage>;\n /**\n * The error that occurred when sending the associated events to the Event Hub.\n */\n error: Error;\n}\n\n/**\n * Describes the options that can be provided while creating the `EventHubBufferedProducerClient`.\n */\nexport interface EventHubBufferedProducerClientOptions extends EventHubClientOptions {\n /**\n * The total number of events that can be buffered for publishing at a given time for a given partition.\n *\n * Default: 1500\n */\n maxEventBufferLengthPerPartition?: number;\n /**\n * The amount of time to wait for a new event to be enqueued in the buffer before publishing a partially full batch.\n *\n * Default: 1 second.\n */\n maxWaitTimeInMs?: number;\n /**\n * The handler to call once a batch has successfully published.\n */\n onSendEventsSuccessHandler?: (ctx: OnSendEventsSuccessContext) => void;\n /**\n * The handler to call when a batch fails to publish.\n */\n onSendEventsErrorHandler: (ctx: OnSendEventsErrorContext) => void;\n /**\n * Indicates whether or not the EventHubProducerClient should enable idempotent publishing to Event Hub partitions.\n * If enabled, the producer will only be able to publish directly to partitions;\n * it will not be able to publish to the Event Hubs gateway for automatic partition routing\n * nor will it be able to use a partition key.\n * Default: false\n */\n enableIdempotentRetries?: boolean;\n}\n\n/**\n * Options to configure the `flush` method on the `EventHubBufferedProducerClient`.\n */\nexport interface BufferedFlushOptions extends OperationOptions {}\n\n/**\n * Options to configure the `close` method on the `EventHubBufferedProducerClient`.\n */\nexport interface BufferedCloseOptions extends OperationOptions {\n /**\n * When `true`, all buffered events that are pending should be sent before closing.\n * When `false`, abandon all buffered events and close immediately.\n * Defaults to `true`.\n */\n flush?: boolean;\n}\n\n/**\n * Options to configure the `enqueueEvents` method on the `EventHubBufferedProducerClient`.\n */\nexport interface EnqueueEventOptions extends SendBatchOptions {}\n\n/**\n * The `EventHubBufferedProducerClient`is used to publish events to a specific Event Hub.\n *\n * The `EventHubBufferedProducerClient` does not publish events immediately.\n * Instead, events are buffered so they can be efficiently batched and published\n * when the batch is full or the `maxWaitTimeInMs` has elapsed with no new events\n * enqueued.\n *\n * Depending on the options specified when events are enqueued, they may be\n * automatically assigned to a partition, grouped according to the specified partition key,\n * or assigned a specifically requested partition.\n *\n * This model is intended to shift the burden of batch management from callers, at the cost of\n * non-deterministic timing, for when events will be published. There are additional trade-offs\n * to consider, as well:\n * - If the application crashes, events in the buffer will not have been published. To prevent\n * data loss, callers are encouraged to track publishing progress using the\n * `onSendEventsSuccessHandler` and `onSendEventsErrorHandler` handlers.\n * - Events specifying a partition key may be assigned a different partition than those using\n * the same key with other producers.\n * - In the unlikely event that a partition becomes temporarily unavailable, the\n * `EventHubBufferedProducerClient` may take longer to recover than other producers.\n *\n * In scenarios where it is important to have events published immediately with a deterministic\n * outcome, ensure that partition keys are assigned to a partition consistent with other\n * publishers, or where maximizing availability is a requirement, using the\n * `EventHubProducerClient` is recommended.\n */\nexport class EventHubBufferedProducerClient {\n /**\n * Controls the `abortSignal` passed to each `BatchingPartitionChannel`.\n * Used to signal when a channel should stop waiting for events.\n */\n private _abortController = new AbortController();\n\n /**\n * Indicates whether the client has been explicitly closed.\n */\n private _isClosed: boolean = false;\n\n /**\n * Handles assigning partitions.\n */\n private _partitionAssigner = new PartitionAssigner();\n\n /**\n * The known partitionIds that will be used when assigning events to partitions.\n */\n private _partitionIds: string[] = [];\n\n /**\n * The EventHubProducerClient to use when creating and sending batches to the Event Hub.\n */\n private _producer: EventHubProducerClient;\n\n /**\n * Mapping of partitionIds to `BatchingPartitionChannels`.\n * Each `BatchingPartitionChannel` handles buffering events and backpressure independently.\n */\n private _partitionChannels = new Map<string, BatchingPartitionChannel>();\n\n /**\n * The options passed by the user when creating the EventHubBufferedProducerClient instance.\n */\n private _clientOptions: EventHubBufferedProducerClientOptions;\n\n /**\n * The interval at which the background management operation should run.\n */\n private _backgroundManagementInterval = 10000; // 10 seconds\n\n /**\n * Indicates whether the background management loop is running.\n */\n private _isBackgroundManagementRunning = false;\n\n /**\n * @readonly\n * The name of the Event Hub instance for which this client is created.\n */\n get eventHubName(): string {\n return this._producer.eventHubName;\n }\n\n /**\n * @readonly\n * The fully qualified namespace of the Event Hub instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n get fullyQualifiedNamespace(): string {\n return this._producer.fullyQualifiedNamespace;\n }\n\n /**\n * The name used to identify this EventHubBufferedProducerClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public readonly identifier: string;\n\n /**\n * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(connectionString: string, options: EventHubBufferedProducerClientOptions);\n /**\n * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n connectionString: string,\n eventHubName: string,\n options: EventHubBufferedProducerClientOptions,\n );\n /**\n * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See &commat;azure/identity for creating credentials that support AAD auth.\n * Use the `AzureNamedKeyCredential` from &commat;azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from &commat;azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options: EventHubBufferedProducerClientOptions,\n );\n constructor(\n fullyQualifiedNamespaceOrConnectionString1: string,\n eventHubNameOrOptions2: string | EventHubBufferedProducerClientOptions,\n credentialOrOptions3?:\n | TokenCredential\n | NamedKeyCredential\n | SASCredential\n | EventHubBufferedProducerClientOptions,\n options4?: EventHubBufferedProducerClientOptions,\n ) {\n if (typeof eventHubNameOrOptions2 !== \"string\") {\n this.identifier = eventHubNameOrOptions2.identifier ?? getRandomName();\n this._producer = new EventHubProducerClient(fullyQualifiedNamespaceOrConnectionString1, {\n ...eventHubNameOrOptions2,\n identifier: this.identifier,\n });\n this._clientOptions = { ...eventHubNameOrOptions2 };\n } else if (!isCredential(credentialOrOptions3)) {\n this.identifier = credentialOrOptions3?.identifier ?? getRandomName();\n this._producer = new EventHubProducerClient(\n fullyQualifiedNamespaceOrConnectionString1,\n eventHubNameOrOptions2,\n { ...credentialOrOptions3, identifier: this.identifier },\n );\n this._clientOptions = { ...credentialOrOptions3! };\n } else {\n this.identifier = options4?.identifier ?? getRandomName();\n this._producer = new EventHubProducerClient(\n fullyQualifiedNamespaceOrConnectionString1,\n eventHubNameOrOptions2,\n credentialOrOptions3,\n { ...options4, identifier: this.identifier },\n );\n this._clientOptions = { ...options4! };\n }\n // setting internal idempotent publishing option on the standard producer.\n (this._producer as any)._enableIdempotentRetries = this._clientOptions.enableIdempotentRetries;\n }\n\n /**\n * Closes the AMQP connection to the Event Hub instance,\n * returning a promise that will be resolved when disconnection is completed.\n *\n * This will wait for enqueued events to be flushed to the service before closing\n * the connection.\n * To close without flushing, set the `flush` option to `false`.\n *\n * @param options - The set of options to apply to the operation call.\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n async close(options: BufferedCloseOptions = {}): Promise<void> {\n logger.verbose(\"closing buffered producer client...\");\n if (!isDefined(options.flush) || options.flush === true) {\n await this.flush(options);\n }\n // Calling abort signals to the BatchingPartitionChannels that they\n // should stop reading/sending events, and to the background management\n // loop that it should stop periodic partition id updates.\n this._abortController.abort();\n await this._producer.close();\n this._isClosed = true;\n }\n\n /**\n * Enqueues an event into the buffer to be published to the Event Hub.\n * If there is no capacity in the buffer when this method is invoked,\n * it will wait for space to become available and ensure that the event\n * has been enqueued.\n *\n * When this call returns, the event has been accepted into the buffer,\n * but it may not have been published yet.\n * Publishing will take place at a nondeterministic point in the future as the buffer is processed.\n *\n * @param events - An {@link EventData} or `AmqpAnnotatedMessage`.\n * @param options - A set of options that can be specified to influence the way in which\n * the event is sent to the associated Event Hub.\n * - `abortSignal` : A signal used to cancel the enqueueEvent operation.\n * - `partitionId` : The partition this set of events will be sent to. If set, `partitionKey` can not be set.\n * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.\n * @returns The total number of events that are currently buffered and waiting to be published, across all partitions.\n */\n async enqueueEvent(\n event: EventData | AmqpAnnotatedMessage,\n options: EnqueueEventOptions = {},\n ): Promise<number> {\n if (this._isClosed) {\n throw new Error(\n `This EventHubBufferedProducerClient has already been closed. Create a new client to enqueue events.`,\n );\n }\n\n if (!this._partitionIds.length) {\n await this._updatePartitionIds();\n }\n if (!this._isBackgroundManagementRunning) {\n this._startPartitionIdsUpdateLoop().catch((e) => {\n logger.error(\n `The following error occured during batch creation or sending: ${JSON.stringify(\n e,\n undefined,\n \" \",\n )}`,\n );\n });\n this._isBackgroundManagementRunning = true;\n }\n\n const partitionId = this._partitionAssigner.assignPartition({\n partitionId: options.partitionId,\n partitionKey: options.partitionKey,\n });\n\n const partitionChannel = this._getPartitionChannel(partitionId);\n await partitionChannel.enqueueEvent(event);\n return this._getTotalBufferedEventsCount();\n }\n\n /**\n * Enqueues events into the buffer to be published to the Event Hub.\n * If there is no capacity in the buffer when this method is invoked,\n * it will wait for space to become available and ensure that the events\n * have been enqueued.\n *\n * When this call returns, the events have been accepted into the buffer,\n * but it may not have been published yet.\n * Publishing will take place at a nondeterministic point in the future as the buffer is processed.\n *\n * @param events - An array of {@link EventData} or `AmqpAnnotatedMessage`.\n * @param options - A set of options that can be specified to influence the way in which\n * events are sent to the associated Event Hub.\n * - `abortSignal` : A signal used to cancel the enqueueEvents operation.\n * - `partitionId` : The partition this set of events will be sent to. If set, `partitionKey` can not be set.\n * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.\n * @returns The total number of events that are currently buffered and waiting to be published, across all partitions.\n */\n async enqueueEvents(\n events: EventData[] | AmqpAnnotatedMessage[],\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: EnqueueEventOptions = {},\n ): Promise<number> {\n for (const event of events) {\n await this.enqueueEvent(event, options);\n }\n\n return this._getTotalBufferedEventsCount();\n }\n\n /**\n * Attempts to publish all events in the buffer immediately.\n * This may result in multiple batches being published,\n * the outcome of each of which will be individually reported by\n * the `onSendEventsSuccessHandler` and `onSendEventsErrorHandler` handlers.\n *\n * @param options - The set of options to apply to the operation call.\n */\n async flush(options: BufferedFlushOptions = {}): Promise<void> {\n await Promise.all(\n Array.from(this._partitionChannels.values()).map((channel) => channel.flush(options)),\n );\n }\n\n /**\n * Provides the Event Hub runtime information.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the Event Hub instance.\n * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise<EventHubProperties> {\n return this._producer.getEventHubProperties(options);\n }\n\n /**\n * Provides the id for each partition associated with the Event Hub.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with an Array of strings representing the id for\n * each partition associated with the Event Hub.\n * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionIds(options: GetPartitionIdsOptions = {}): Promise<Array<string>> {\n return this._producer.getPartitionIds(options);\n }\n\n /**\n * Provides information about the state of the specified partition.\n * @param partitionId - The id of the partition for which information is required.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the state of the partition .\n * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionProperties(\n partitionId: string,\n options: GetPartitionPropertiesOptions = {},\n ): Promise<PartitionProperties> {\n return this._producer.getPartitionProperties(partitionId, options);\n }\n\n /**\n * Gets the `BatchingPartitionChannel` associated with the partitionId.\n *\n * If one does not exist, it is created.\n */\n private _getPartitionChannel(partitionId: string): BatchingPartitionChannel {\n const partitionChannel =\n this._partitionChannels.get(partitionId) ??\n new BatchingPartitionChannel({\n loopAbortSignal: this._abortController.signal,\n maxBufferSize: this._clientOptions.maxEventBufferLengthPerPartition || 1500,\n maxWaitTimeInMs: this._clientOptions.maxWaitTimeInMs || 1000,\n onSendEventsErrorHandler: this._clientOptions.onSendEventsErrorHandler,\n onSendEventsSuccessHandler: this._clientOptions.onSendEventsSuccessHandler,\n partitionId,\n producer: this._producer,\n });\n this._partitionChannels.set(partitionId, partitionChannel);\n return partitionChannel;\n }\n\n /**\n * Returns the total number of buffered events across all partitions.\n */\n private _getTotalBufferedEventsCount(): number {\n let total = 0;\n for (const [_, channel] of this._partitionChannels) {\n total += channel.getCurrentBufferedCount();\n }\n\n return total;\n }\n\n private async _updatePartitionIds(): Promise<void> {\n logger.verbose(\"Checking for partition Id updates...\");\n const queriedPartitionIds = await this.getPartitionIds();\n\n if (this._partitionIds.length !== queriedPartitionIds.length) {\n logger.verbose(\"Applying partition Id updates\");\n this._partitionIds = queriedPartitionIds;\n this._partitionAssigner.setPartitionIds(this._partitionIds);\n }\n }\n\n private async _startPartitionIdsUpdateLoop(): Promise<void> {\n logger.verbose(\"Starting a background loop to check and apply partition id updates...\");\n while (!this._abortController.signal.aborted && !this._isClosed) {\n await delay<void>(this._backgroundManagementInterval);\n if (!this._isClosed) {\n await this._updatePartitionIds();\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"eventHubBufferedProducerClient.js","sourceRoot":"","sources":["../../src/eventHubBufferedProducerClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAWrE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA4FhD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,8BAA8B;IACzC;;;OAGG;IACK,gBAAgB,GAAG,IAAI,eAAe,EAAE,CAAC;IAEjD;;OAEG;IACK,SAAS,GAAY,KAAK,CAAC;IAEnC;;OAEG;IACK,kBAAkB,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAErD;;OAEG;IACK,aAAa,GAAa,EAAE,CAAC;IAErC;;OAEG;IACK,SAA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ACf,CAAC;IAEO,KAAK,CAAC,mBAAmB;QAC/B,MAAM,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC;QACvD,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAEzD,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAC7D,MAAM,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;YAChD,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC;YACzC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,4BAA4B;QACxC,MAAM,CAAC,OAAO,CAAC,uEAAuE,CAAC,CAAC;QACxF,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YAChE,MAAM,KAAK,CAAO,IAAI,CAAC,6BAA6B,CAAC,CAAC;YACtD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACpB,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { EventData } from \"./eventData.js\";\nimport { EventHubProducerClient } from \"./eventHubProducerClient.js\";\nimport type { OperationOptions } from \"./util/operationOptions.js\";\nimport type {\n EventHubClientOptions,\n GetEventHubPropertiesOptions,\n GetPartitionIdsOptions,\n GetPartitionPropertiesOptions,\n SendBatchOptions,\n} from \"./models/public.js\";\nimport type { EventHubProperties, PartitionProperties } from \"./managementClient.js\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isDefined } from \"@azure/core-util\";\nimport { isCredential } from \"./util/typeGuards.js\";\nimport type { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { delay } from \"@azure/core-amqp\";\nimport { BatchingPartitionChannel } from \"./batchingPartitionChannel.js\";\nimport { PartitionAssigner } from \"./impl/partitionAssigner.js\";\nimport { logger } from \"./logger.js\";\nimport { getRandomName } from \"./util/utils.js\";\n\n/**\n * Contains the events that were successfully sent to the Event Hub,\n * and the partition they were assigned to.\n */\nexport interface OnSendEventsSuccessContext {\n /**\n * The partition each event was assigned.\n */\n partitionId: string;\n /**\n * The array of {@link EventData} and/or `AmqpAnnotatedMessage` that were successfully sent to the Event Hub.\n */\n events: Array<EventData | AmqpAnnotatedMessage>;\n}\n\n/**\n * Contains the events that were not successfully sent to the Event Hub,\n * the partition they were assigned to, and the error that was encountered while sending.\n */\nexport interface OnSendEventsErrorContext {\n /**\n * The partition each event was assigned.\n */\n partitionId: string;\n /**\n * The array of {@link EventData} and/or `AmqpAnnotatedMessage` that were not successfully sent to the Event Hub.\n */\n events: Array<EventData | AmqpAnnotatedMessage>;\n /**\n * The error that occurred when sending the associated events to the Event Hub.\n */\n error: Error;\n}\n\n/**\n * Describes the options that can be provided while creating the `EventHubBufferedProducerClient`.\n */\nexport interface EventHubBufferedProducerClientOptions extends EventHubClientOptions {\n /**\n * The total number of events that can be buffered for publishing at a given time for a given partition.\n *\n * Default: 1500\n */\n maxEventBufferLengthPerPartition?: number;\n /**\n * The amount of time to wait for a new event to be enqueued in the buffer before publishing a partially full batch.\n *\n * Default: 1 second.\n */\n maxWaitTimeInMs?: number;\n /**\n * The handler to call once a batch has successfully published.\n */\n onSendEventsSuccessHandler?: (ctx: OnSendEventsSuccessContext) => void;\n /**\n * The handler to call when a batch fails to publish.\n */\n onSendEventsErrorHandler: (ctx: OnSendEventsErrorContext) => void;\n /**\n * Indicates whether or not the EventHubProducerClient should enable idempotent publishing to Event Hub partitions.\n * If enabled, the producer will only be able to publish directly to partitions;\n * it will not be able to publish to the Event Hubs gateway for automatic partition routing\n * nor will it be able to use a partition key.\n * Default: false\n */\n enableIdempotentRetries?: boolean;\n}\n\n/**\n * Options to configure the `flush` method on the `EventHubBufferedProducerClient`.\n */\nexport interface BufferedFlushOptions extends OperationOptions {}\n\n/**\n * Options to configure the `close` method on the `EventHubBufferedProducerClient`.\n */\nexport interface BufferedCloseOptions extends OperationOptions {\n /**\n * When `true`, all buffered events that are pending should be sent before closing.\n * When `false`, abandon all buffered events and close immediately.\n * Defaults to `true`.\n */\n flush?: boolean;\n}\n\n/**\n * Options to configure the `enqueueEvents` method on the `EventHubBufferedProducerClient`.\n */\nexport interface EnqueueEventOptions extends SendBatchOptions {}\n\n/**\n * The `EventHubBufferedProducerClient`is used to publish events to a specific Event Hub.\n *\n * The `EventHubBufferedProducerClient` does not publish events immediately.\n * Instead, events are buffered so they can be efficiently batched and published\n * when the batch is full or the `maxWaitTimeInMs` has elapsed with no new events\n * enqueued.\n *\n * Depending on the options specified when events are enqueued, they may be\n * automatically assigned to a partition, grouped according to the specified partition key,\n * or assigned a specifically requested partition.\n *\n * This model is intended to shift the burden of batch management from callers, at the cost of\n * non-deterministic timing, for when events will be published. There are additional trade-offs\n * to consider, as well:\n * - If the application crashes, events in the buffer will not have been published. To prevent\n * data loss, callers are encouraged to track publishing progress using the\n * `onSendEventsSuccessHandler` and `onSendEventsErrorHandler` handlers.\n * - Events specifying a partition key may be assigned a different partition than those using\n * the same key with other producers.\n * - In the unlikely event that a partition becomes temporarily unavailable, the\n * `EventHubBufferedProducerClient` may take longer to recover than other producers.\n *\n * In scenarios where it is important to have events published immediately with a deterministic\n * outcome, ensure that partition keys are assigned to a partition consistent with other\n * publishers, or where maximizing availability is a requirement, using the\n * `EventHubProducerClient` is recommended.\n */\nexport class EventHubBufferedProducerClient {\n /**\n * Controls the `abortSignal` passed to each `BatchingPartitionChannel`.\n * Used to signal when a channel should stop waiting for events.\n */\n private _abortController = new AbortController();\n\n /**\n * Indicates whether the client has been explicitly closed.\n */\n private _isClosed: boolean = false;\n\n /**\n * Handles assigning partitions.\n */\n private _partitionAssigner = new PartitionAssigner();\n\n /**\n * The known partitionIds that will be used when assigning events to partitions.\n */\n private _partitionIds: string[] = [];\n\n /**\n * The EventHubProducerClient to use when creating and sending batches to the Event Hub.\n */\n private _producer: EventHubProducerClient;\n\n /**\n * Mapping of partitionIds to `BatchingPartitionChannels`.\n * Each `BatchingPartitionChannel` handles buffering events and backpressure independently.\n */\n private _partitionChannels = new Map<string, BatchingPartitionChannel>();\n\n /**\n * The options passed by the user when creating the EventHubBufferedProducerClient instance.\n */\n private _clientOptions: EventHubBufferedProducerClientOptions;\n\n /**\n * The interval at which the background management operation should run.\n */\n private _backgroundManagementInterval = 10000; // 10 seconds\n\n /**\n * Indicates whether the background management loop is running.\n */\n private _isBackgroundManagementRunning = false;\n\n /**\n * @readonly\n * The name of the Event Hub instance for which this client is created.\n */\n get eventHubName(): string {\n return this._producer.eventHubName;\n }\n\n /**\n * @readonly\n * The fully qualified namespace of the Event Hub instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n get fullyQualifiedNamespace(): string {\n return this._producer.fullyQualifiedNamespace;\n }\n\n /**\n * The name used to identify this EventHubBufferedProducerClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public readonly identifier: string;\n\n /**\n * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(connectionString: string, options: EventHubBufferedProducerClientOptions);\n /**\n * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n connectionString: string,\n eventHubName: string,\n options: EventHubBufferedProducerClientOptions,\n );\n /**\n * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See &commat;azure/identity for creating credentials that support AAD auth.\n * Use the `AzureNamedKeyCredential` from &commat;azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from &commat;azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options: EventHubBufferedProducerClientOptions,\n );\n constructor(\n fullyQualifiedNamespaceOrConnectionString1: string,\n eventHubNameOrOptions2: string | EventHubBufferedProducerClientOptions,\n credentialOrOptions3?:\n | TokenCredential\n | NamedKeyCredential\n | SASCredential\n | EventHubBufferedProducerClientOptions,\n options4?: EventHubBufferedProducerClientOptions,\n ) {\n if (typeof eventHubNameOrOptions2 !== \"string\") {\n this.identifier = eventHubNameOrOptions2.identifier ?? getRandomName();\n this._producer = new EventHubProducerClient(fullyQualifiedNamespaceOrConnectionString1, {\n ...eventHubNameOrOptions2,\n identifier: this.identifier,\n });\n this._clientOptions = { ...eventHubNameOrOptions2 };\n } else if (!isCredential(credentialOrOptions3)) {\n this.identifier = credentialOrOptions3?.identifier ?? getRandomName();\n this._producer = new EventHubProducerClient(\n fullyQualifiedNamespaceOrConnectionString1,\n eventHubNameOrOptions2,\n { ...credentialOrOptions3, identifier: this.identifier },\n );\n this._clientOptions = { ...credentialOrOptions3! };\n } else {\n this.identifier = options4?.identifier ?? getRandomName();\n this._producer = new EventHubProducerClient(\n fullyQualifiedNamespaceOrConnectionString1,\n eventHubNameOrOptions2,\n credentialOrOptions3,\n { ...options4, identifier: this.identifier },\n );\n this._clientOptions = { ...options4! };\n }\n // setting internal idempotent publishing option on the standard producer.\n (this._producer as any)._enableIdempotentRetries = this._clientOptions.enableIdempotentRetries;\n }\n\n /**\n * Closes the AMQP connection to the Event Hub instance,\n * returning a promise that will be resolved when disconnection is completed.\n *\n * This will wait for enqueued events to be flushed to the service before closing\n * the connection.\n * To close without flushing, set the `flush` option to `false`.\n *\n * @param options - The set of options to apply to the operation call.\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n async close(options: BufferedCloseOptions = {}): Promise<void> {\n logger.verbose(\"closing buffered producer client...\");\n if (!isDefined(options.flush) || options.flush === true) {\n await this.flush(options);\n }\n // Calling abort signals to the BatchingPartitionChannels that they\n // should stop reading/sending events, and to the background management\n // loop that it should stop periodic partition id updates.\n this._abortController.abort();\n await this._producer.close();\n this._isClosed = true;\n }\n\n /**\n * Enqueues an event into the buffer to be published to the Event Hub.\n * If there is no capacity in the buffer when this method is invoked,\n * it will wait for space to become available and ensure that the event\n * has been enqueued.\n *\n * When this call returns, the event has been accepted into the buffer,\n * but it may not have been published yet.\n * Publishing will take place at a nondeterministic point in the future as the buffer is processed.\n *\n * @param events - An {@link EventData} or `AmqpAnnotatedMessage`.\n * @param options - A set of options that can be specified to influence the way in which\n * the event is sent to the associated Event Hub.\n * - `abortSignal` : A signal used to cancel the enqueueEvent operation.\n * - `partitionId` : The partition this set of events will be sent to. If set, `partitionKey` can not be set.\n * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.\n * @returns The total number of events that are currently buffered and waiting to be published, across all partitions.\n */\n async enqueueEvent(\n event: EventData | AmqpAnnotatedMessage,\n options: EnqueueEventOptions = {},\n ): Promise<number> {\n if (this._isClosed) {\n throw new Error(\n `This EventHubBufferedProducerClient has already been closed. Create a new client to enqueue events.`,\n );\n }\n\n if (!this._partitionIds.length) {\n await this._updatePartitionIds();\n }\n if (!this._isBackgroundManagementRunning) {\n this._startPartitionIdsUpdateLoop().catch((e) => {\n logger.error(\n `The following error occured during batch creation or sending: ${JSON.stringify(\n e,\n undefined,\n \" \",\n )}`,\n );\n });\n this._isBackgroundManagementRunning = true;\n }\n\n const partitionId = this._partitionAssigner.assignPartition({\n partitionId: options.partitionId,\n partitionKey: options.partitionKey,\n });\n\n const partitionChannel = this._getPartitionChannel(partitionId);\n await partitionChannel.enqueueEvent(event);\n return this._getTotalBufferedEventsCount();\n }\n\n /**\n * Enqueues events into the buffer to be published to the Event Hub.\n * If there is no capacity in the buffer when this method is invoked,\n * it will wait for space to become available and ensure that the events\n * have been enqueued.\n *\n * When this call returns, the events have been accepted into the buffer,\n * but it may not have been published yet.\n * Publishing will take place at a nondeterministic point in the future as the buffer is processed.\n *\n * @param events - An array of {@link EventData} or `AmqpAnnotatedMessage`.\n * @param options - A set of options that can be specified to influence the way in which\n * events are sent to the associated Event Hub.\n * - `abortSignal` : A signal used to cancel the enqueueEvents operation.\n * - `partitionId` : The partition this set of events will be sent to. If set, `partitionKey` can not be set.\n * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.\n * @returns The total number of events that are currently buffered and waiting to be published, across all partitions.\n */\n async enqueueEvents(\n events: EventData[] | AmqpAnnotatedMessage[],\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: EnqueueEventOptions = {},\n ): Promise<number> {\n for (const event of events) {\n await this.enqueueEvent(event, options);\n }\n\n return this._getTotalBufferedEventsCount();\n }\n\n /**\n * Attempts to publish all events in the buffer immediately.\n * This may result in multiple batches being published,\n * the outcome of each of which will be individually reported by\n * the `onSendEventsSuccessHandler` and `onSendEventsErrorHandler` handlers.\n *\n * @param options - The set of options to apply to the operation call.\n */\n async flush(options: BufferedFlushOptions = {}): Promise<void> {\n await Promise.all(\n Array.from(this._partitionChannels.values()).map((channel) => channel.flush(options)),\n );\n }\n\n /**\n * Provides the Event Hub runtime information.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the Event Hub instance.\n * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise<EventHubProperties> {\n return this._producer.getEventHubProperties(options);\n }\n\n /**\n * Provides the id for each partition associated with the Event Hub.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with an Array of strings representing the id for\n * each partition associated with the Event Hub.\n * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionIds(options: GetPartitionIdsOptions = {}): Promise<Array<string>> {\n return this._producer.getPartitionIds(options);\n }\n\n /**\n * Provides information about the state of the specified partition.\n * @param partitionId - The id of the partition for which information is required.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the state of the partition .\n * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionProperties(\n partitionId: string,\n options: GetPartitionPropertiesOptions = {},\n ): Promise<PartitionProperties> {\n return this._producer.getPartitionProperties(partitionId, options);\n }\n\n /**\n * Gets the `BatchingPartitionChannel` associated with the partitionId.\n *\n * If one does not exist, it is created.\n */\n private _getPartitionChannel(partitionId: string): BatchingPartitionChannel {\n const partitionChannel =\n this._partitionChannels.get(partitionId) ??\n new BatchingPartitionChannel({\n loopAbortSignal: this._abortController.signal,\n maxBufferSize: this._clientOptions.maxEventBufferLengthPerPartition || 1500,\n maxWaitTimeInMs: this._clientOptions.maxWaitTimeInMs || 1000,\n onSendEventsErrorHandler: this._clientOptions.onSendEventsErrorHandler,\n onSendEventsSuccessHandler: this._clientOptions.onSendEventsSuccessHandler,\n partitionId,\n producer: this._producer,\n });\n this._partitionChannels.set(partitionId, partitionChannel);\n return partitionChannel;\n }\n\n /**\n * Returns the total number of buffered events across all partitions.\n */\n private _getTotalBufferedEventsCount(): number {\n let total = 0;\n for (const [_, channel] of this._partitionChannels) {\n total += channel.getCurrentBufferedCount();\n }\n\n return total;\n }\n\n private async _updatePartitionIds(): Promise<void> {\n logger.verbose(\"Checking for partition Id updates...\");\n const queriedPartitionIds = await this.getPartitionIds();\n\n if (this._partitionIds.length !== queriedPartitionIds.length) {\n logger.verbose(\"Applying partition Id updates\");\n this._partitionIds = queriedPartitionIds;\n this._partitionAssigner.setPartitionIds(this._partitionIds);\n }\n }\n\n private async _startPartitionIdsUpdateLoop(): Promise<void> {\n logger.verbose(\"Starting a background loop to check and apply partition id updates...\");\n while (!this._abortController.signal.aborted && !this._isClosed) {\n await delay<void>(this._backgroundManagementInterval);\n if (!this._isClosed) {\n await this._updatePartitionIds();\n }\n }\n }\n}\n"]}
@@ -34,6 +34,32 @@ const defaultConsumerClientOptions = {
34
34
  * to load balance multiple instances of your application.
35
35
  */
36
36
  export class EventHubConsumerClient {
37
+ _consumerGroup;
38
+ /**
39
+ * Describes the amqp connection context for the client.
40
+ */
41
+ _context;
42
+ /**
43
+ * The options passed by the user when creating the EventHubClient instance.
44
+ */
45
+ _clientOptions;
46
+ _partitionGate = new PartitionGate();
47
+ /**
48
+ * The Subscriptions that were spawned by calling `subscribe()`.
49
+ * Subscriptions that have been stopped by the user will not
50
+ * be present in this set.
51
+ */
52
+ _subscriptions = new Set();
53
+ /**
54
+ * The name of the default consumer group in the Event Hubs service.
55
+ */
56
+ static defaultConsumerGroupName = Constants.defaultConsumerGroup;
57
+ _checkpointStore;
58
+ _userChoseCheckpointStore;
59
+ /**
60
+ * Options for configuring load balancing.
61
+ */
62
+ _loadBalancingOptions;
37
63
  /**
38
64
  * @readonly
39
65
  * The name of the Event Hub instance for which this client is created.
@@ -49,16 +75,13 @@ export class EventHubConsumerClient {
49
75
  get fullyQualifiedNamespace() {
50
76
  return this._context.config.host;
51
77
  }
78
+ /**
79
+ * The name used to identify this EventHubConsumerClient.
80
+ * If not specified or empty, a random unique one will be generated.
81
+ */
82
+ identifier;
52
83
  constructor(_consumerGroup, connectionStringOrFullyQualifiedNamespace2, checkpointStoreOrEventHubNameOrOptions3, checkpointStoreOrCredentialOrOptions4, checkpointStoreOrOptions5, options6) {
53
- var _a, _b;
54
84
  this._consumerGroup = _consumerGroup;
55
- this._partitionGate = new PartitionGate();
56
- /**
57
- * The Subscriptions that were spawned by calling `subscribe()`.
58
- * Subscriptions that have been stopped by the user will not
59
- * be present in this set.
60
- */
61
- this._subscriptions = new Set();
62
85
  if (isCredential(checkpointStoreOrCredentialOrOptions4)) {
63
86
  // #3 or 3.1
64
87
  logger.info("Creating EventHubConsumerClient with TokenCredential.");
@@ -111,10 +134,15 @@ export class EventHubConsumerClient {
111
134
  }
112
135
  this._context = createConnectionContext(connectionStringOrFullyQualifiedNamespace2, this._clientOptions);
113
136
  }
114
- this.identifier = (_a = this._clientOptions.identifier) !== null && _a !== void 0 ? _a : getRandomName();
115
- this._loadBalancingOptions = Object.assign({
137
+ this.identifier = this._clientOptions.identifier ?? getRandomName();
138
+ this._loadBalancingOptions = {
116
139
  // default options
117
- strategy: "balanced", updateIntervalInMs: 10000, partitionOwnershipExpirationIntervalInMs: 60000 }, (_b = this._clientOptions) === null || _b === void 0 ? void 0 : _b.loadBalancingOptions);
140
+ strategy: "balanced",
141
+ updateIntervalInMs: 10000,
142
+ partitionOwnershipExpirationIntervalInMs: 60000,
143
+ // options supplied by user
144
+ ...this._clientOptions?.loadBalancingOptions,
145
+ };
118
146
  }
119
147
  /**
120
148
  * Closes the AMQP connection to the Event Hub instance,
@@ -141,7 +169,10 @@ export class EventHubConsumerClient {
141
169
  */
142
170
  getPartitionIds(options = {}) {
143
171
  return this._context
144
- .managementSession.getEventHubProperties(Object.assign(Object.assign({}, options), { retryOptions: this._clientOptions.retryOptions }))
172
+ .managementSession.getEventHubProperties({
173
+ ...options,
174
+ retryOptions: this._clientOptions.retryOptions,
175
+ })
145
176
  .then((eventHubProperties) => {
146
177
  return eventHubProperties.partitionIds;
147
178
  });
@@ -155,7 +186,10 @@ export class EventHubConsumerClient {
155
186
  * @throws AbortError if the operation is cancelled via the abortSignal.
156
187
  */
157
188
  getPartitionProperties(partitionId, options = {}) {
158
- return this._context.managementSession.getPartitionProperties(partitionId, Object.assign(Object.assign({}, options), { retryOptions: this._clientOptions.retryOptions }));
189
+ return this._context.managementSession.getPartitionProperties(partitionId, {
190
+ ...options,
191
+ retryOptions: this._clientOptions.retryOptions,
192
+ });
159
193
  }
160
194
  /**
161
195
  * Provides the Event Hub runtime information.
@@ -165,7 +199,10 @@ export class EventHubConsumerClient {
165
199
  * @throws AbortError if the operation is cancelled via the abortSignal.
166
200
  */
167
201
  getEventHubProperties(options = {}) {
168
- return this._context.managementSession.getEventHubProperties(Object.assign(Object.assign({}, options), { retryOptions: this._clientOptions.retryOptions }));
202
+ return this._context.managementSession.getEventHubProperties({
203
+ ...options,
204
+ retryOptions: this._clientOptions.retryOptions,
205
+ });
169
206
  }
170
207
  subscribe(handlersOrPartitionId1, optionsOrHandlers2, possibleOptions3) {
171
208
  let eventProcessor;
@@ -210,14 +247,13 @@ export class EventHubConsumerClient {
210
247
  * Gets the LoadBalancing strategy that should be used based on what the user provided.
211
248
  */
212
249
  _getLoadBalancingStrategy() {
213
- var _a;
214
250
  if (!this._userChoseCheckpointStore) {
215
251
  // The default behavior when a checkpointstore isn't provided
216
252
  // is to always grab all the partitions.
217
253
  return new UnbalancedLoadBalancingStrategy();
218
254
  }
219
255
  const partitionOwnershipExpirationIntervalInMs = this._loadBalancingOptions.partitionOwnershipExpirationIntervalInMs;
220
- if (((_a = this._loadBalancingOptions) === null || _a === void 0 ? void 0 : _a.strategy) === "greedy") {
256
+ if (this._loadBalancingOptions?.strategy === "greedy") {
221
257
  return new GreedyLoadBalancingStrategy(partitionOwnershipExpirationIntervalInMs);
222
258
  }
223
259
  // The default behavior when a checkpointstore is provided is
@@ -233,14 +269,20 @@ export class EventHubConsumerClient {
233
269
  logger.verbose("EventHubConsumerClient subscribing to all partitions, no checkpoint store.");
234
270
  }
235
271
  const loadBalancingStrategy = this._getLoadBalancingStrategy();
236
- const eventProcessor = this._createEventProcessor(this._context, subscriptionEventHandlers, this._checkpointStore, Object.assign(Object.assign(Object.assign({}, defaultConsumerClientOptions), options), { ownerLevel: getOwnerLevel(options, this._userChoseCheckpointStore),
272
+ const eventProcessor = this._createEventProcessor(this._context, subscriptionEventHandlers, this._checkpointStore, {
273
+ ...defaultConsumerClientOptions,
274
+ ...options,
275
+ ownerLevel: getOwnerLevel(options, this._userChoseCheckpointStore),
237
276
  // make it so all the event processors process work with the same overarching owner ID
238
277
  // this allows the EventHubConsumer to unify all the work for any processors that it spawns
239
- ownerId: this.identifier, retryOptions: this._clientOptions.retryOptions, loadBalancingStrategy, loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs }));
278
+ ownerId: this.identifier,
279
+ retryOptions: this._clientOptions.retryOptions,
280
+ loadBalancingStrategy,
281
+ loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs,
282
+ });
240
283
  return { targetedPartitionId: "all", eventProcessor };
241
284
  }
242
285
  createEventProcessorForSinglePartition(partitionId, eventHandlers, options) {
243
- var _a;
244
286
  this._partitionGate.add(partitionId);
245
287
  const subscribeOptions = options;
246
288
  if (this._userChoseCheckpointStore) {
@@ -249,17 +291,21 @@ export class EventHubConsumerClient {
249
291
  else {
250
292
  logger.verbose(`EventHubConsumerClient subscribing to specific partition (${partitionId}), no checkpoint store.`);
251
293
  }
252
- const eventProcessor = this._createEventProcessor(this._context, eventHandlers, this._checkpointStore, Object.assign(Object.assign(Object.assign({}, defaultConsumerClientOptions), options), { processingTarget: partitionId, ownerLevel: getOwnerLevel(subscribeOptions, this._userChoseCheckpointStore), retryOptions: this._clientOptions.retryOptions, loadBalancingStrategy: new UnbalancedLoadBalancingStrategy(), loopIntervalInMs: (_a = this._loadBalancingOptions.updateIntervalInMs) !== null && _a !== void 0 ? _a : 10000 }));
294
+ const eventProcessor = this._createEventProcessor(this._context, eventHandlers, this._checkpointStore, {
295
+ ...defaultConsumerClientOptions,
296
+ ...options,
297
+ processingTarget: partitionId,
298
+ ownerLevel: getOwnerLevel(subscribeOptions, this._userChoseCheckpointStore),
299
+ retryOptions: this._clientOptions.retryOptions,
300
+ loadBalancingStrategy: new UnbalancedLoadBalancingStrategy(),
301
+ loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs ?? 10000,
302
+ });
253
303
  return { targetedPartitionId: partitionId, eventProcessor };
254
304
  }
255
305
  _createEventProcessor(connectionContext, subscriptionEventHandlers, checkpointStore, options) {
256
306
  return new EventProcessor(this._consumerGroup, connectionContext, subscriptionEventHandlers, checkpointStore, options);
257
307
  }
258
308
  }
259
- /**
260
- * The name of the default consumer group in the Event Hubs service.
261
- */
262
- EventHubConsumerClient.defaultConsumerGroupName = Constants.defaultConsumerGroup;
263
309
  /**
264
310
  * @internal
265
311
  */