@azure/event-hubs 6.0.2-alpha.20251014.1 → 6.0.2-alpha.20251021.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 (259) hide show
  1. package/dist/browser/batchingPartitionChannel.d.ts.map +1 -1
  2. package/dist/browser/batchingPartitionChannel.js +2 -1
  3. package/dist/browser/batchingPartitionChannel.js.map +1 -1
  4. package/dist/browser/connectionContext.d.ts.map +1 -1
  5. package/dist/browser/connectionContext.js +10 -4
  6. package/dist/browser/connectionContext.js.map +1 -1
  7. package/dist/browser/eventHubBufferedProducerClient.d.ts.map +1 -1
  8. package/dist/browser/eventHubBufferedProducerClient.js +2 -1
  9. package/dist/browser/eventHubBufferedProducerClient.js.map +1 -1
  10. package/dist/browser/eventHubConsumerClient.d.ts.map +1 -1
  11. package/dist/browser/eventHubConsumerClient.js +3 -6
  12. package/dist/browser/eventHubConsumerClient.js.map +1 -1
  13. package/dist/browser/eventHubProducerClient.d.ts.map +1 -1
  14. package/dist/browser/eventHubProducerClient.js +3 -6
  15. package/dist/browser/eventHubProducerClient.js.map +1 -1
  16. package/dist/browser/eventHubSender.d.ts.map +1 -1
  17. package/dist/browser/eventHubSender.js +6 -4
  18. package/dist/browser/eventHubSender.js.map +1 -1
  19. package/dist/browser/partitionReceiver.js +4 -4
  20. package/dist/browser/partitionReceiver.js.map +1 -1
  21. package/dist/browser/util/timerLoop.d.ts.map +1 -1
  22. package/dist/browser/util/timerLoop.js +12 -5
  23. package/dist/browser/util/timerLoop.js.map +1 -1
  24. package/dist/commonjs/batchingPartitionChannel.d.ts.map +1 -1
  25. package/dist/commonjs/batchingPartitionChannel.js +2 -1
  26. package/dist/commonjs/batchingPartitionChannel.js.map +1 -1
  27. package/dist/commonjs/connectionContext.d.ts.map +1 -1
  28. package/dist/commonjs/connectionContext.js +10 -4
  29. package/dist/commonjs/connectionContext.js.map +1 -1
  30. package/dist/commonjs/eventHubBufferedProducerClient.d.ts.map +1 -1
  31. package/dist/commonjs/eventHubBufferedProducerClient.js +2 -1
  32. package/dist/commonjs/eventHubBufferedProducerClient.js.map +1 -1
  33. package/dist/commonjs/eventHubConsumerClient.d.ts.map +1 -1
  34. package/dist/commonjs/eventHubConsumerClient.js +3 -6
  35. package/dist/commonjs/eventHubConsumerClient.js.map +1 -1
  36. package/dist/commonjs/eventHubProducerClient.d.ts.map +1 -1
  37. package/dist/commonjs/eventHubProducerClient.js +3 -6
  38. package/dist/commonjs/eventHubProducerClient.js.map +1 -1
  39. package/dist/commonjs/eventHubSender.d.ts.map +1 -1
  40. package/dist/commonjs/eventHubSender.js +6 -4
  41. package/dist/commonjs/eventHubSender.js.map +1 -1
  42. package/dist/commonjs/partitionReceiver.js +4 -4
  43. package/dist/commonjs/partitionReceiver.js.map +1 -1
  44. package/dist/commonjs/util/timerLoop.d.ts.map +1 -1
  45. package/dist/commonjs/util/timerLoop.js +12 -5
  46. package/dist/commonjs/util/timerLoop.js.map +1 -1
  47. package/dist/esm/batchingPartitionChannel.d.ts.map +1 -1
  48. package/dist/esm/batchingPartitionChannel.js +2 -1
  49. package/dist/esm/batchingPartitionChannel.js.map +1 -1
  50. package/dist/esm/connectionContext.d.ts.map +1 -1
  51. package/dist/esm/connectionContext.js +10 -4
  52. package/dist/esm/connectionContext.js.map +1 -1
  53. package/dist/esm/eventHubBufferedProducerClient.d.ts.map +1 -1
  54. package/dist/esm/eventHubBufferedProducerClient.js +2 -1
  55. package/dist/esm/eventHubBufferedProducerClient.js.map +1 -1
  56. package/dist/esm/eventHubConsumerClient.d.ts.map +1 -1
  57. package/dist/esm/eventHubConsumerClient.js +3 -6
  58. package/dist/esm/eventHubConsumerClient.js.map +1 -1
  59. package/dist/esm/eventHubProducerClient.d.ts.map +1 -1
  60. package/dist/esm/eventHubProducerClient.js +3 -6
  61. package/dist/esm/eventHubProducerClient.js.map +1 -1
  62. package/dist/esm/eventHubSender.d.ts.map +1 -1
  63. package/dist/esm/eventHubSender.js +6 -4
  64. package/dist/esm/eventHubSender.js.map +1 -1
  65. package/dist/esm/partitionReceiver.js +4 -4
  66. package/dist/esm/partitionReceiver.js.map +1 -1
  67. package/dist/esm/util/timerLoop.d.ts.map +1 -1
  68. package/dist/esm/util/timerLoop.js +12 -5
  69. package/dist/esm/util/timerLoop.js.map +1 -1
  70. package/dist/react-native/batchingPartitionChannel.d.ts +94 -0
  71. package/dist/react-native/batchingPartitionChannel.d.ts.map +1 -0
  72. package/dist/react-native/batchingPartitionChannel.js +255 -0
  73. package/dist/react-native/batchingPartitionChannel.js.map +1 -0
  74. package/dist/react-native/connectionContext.d.ts +108 -0
  75. package/dist/react-native/connectionContext.d.ts.map +1 -0
  76. package/dist/react-native/connectionContext.js +310 -0
  77. package/dist/react-native/connectionContext.js.map +1 -0
  78. package/dist/react-native/dataTransformer.d.ts +53 -0
  79. package/dist/react-native/dataTransformer.d.ts.map +1 -0
  80. package/dist/react-native/dataTransformer.js +133 -0
  81. package/dist/react-native/dataTransformer.js.map +1 -0
  82. package/dist/react-native/diagnostics/instrumentEventData.d.ts +28 -0
  83. package/dist/react-native/diagnostics/instrumentEventData.d.ts.map +1 -0
  84. package/dist/react-native/diagnostics/instrumentEventData.js +67 -0
  85. package/dist/react-native/diagnostics/instrumentEventData.js.map +1 -0
  86. package/dist/react-native/diagnostics/tracing.d.ts +19 -0
  87. package/dist/react-native/diagnostics/tracing.d.ts.map +1 -0
  88. package/dist/react-native/diagnostics/tracing.js +40 -0
  89. package/dist/react-native/diagnostics/tracing.js.map +1 -0
  90. package/dist/react-native/eventData.d.ts +295 -0
  91. package/dist/react-native/eventData.d.ts.map +1 -0
  92. package/dist/react-native/eventData.js +247 -0
  93. package/dist/react-native/eventData.js.map +1 -0
  94. package/dist/react-native/eventDataAdapter.d.ts +69 -0
  95. package/dist/react-native/eventDataAdapter.d.ts.map +1 -0
  96. package/dist/react-native/eventDataAdapter.js +38 -0
  97. package/dist/react-native/eventDataAdapter.js.map +1 -0
  98. package/dist/react-native/eventDataBatch.d.ts +225 -0
  99. package/dist/react-native/eventDataBatch.d.ts.map +1 -0
  100. package/dist/react-native/eventDataBatch.js +301 -0
  101. package/dist/react-native/eventDataBatch.js.map +1 -0
  102. package/dist/react-native/eventHubBufferedProducerClient.d.ts +323 -0
  103. package/dist/react-native/eventHubBufferedProducerClient.d.ts.map +1 -0
  104. package/dist/react-native/eventHubBufferedProducerClient.js +301 -0
  105. package/dist/react-native/eventHubBufferedProducerClient.js.map +1 -0
  106. package/dist/react-native/eventHubConsumerClient.d.ts +293 -0
  107. package/dist/react-native/eventHubConsumerClient.d.ts.map +1 -0
  108. package/dist/react-native/eventHubConsumerClient.js +336 -0
  109. package/dist/react-native/eventHubConsumerClient.js.map +1 -0
  110. package/dist/react-native/eventHubConsumerClientModels.d.ts +218 -0
  111. package/dist/react-native/eventHubConsumerClientModels.d.ts.map +1 -0
  112. package/dist/react-native/eventHubConsumerClientModels.js +4 -0
  113. package/dist/react-native/eventHubConsumerClientModels.js.map +1 -0
  114. package/dist/react-native/eventHubProducerClient.d.ts +299 -0
  115. package/dist/react-native/eventHubProducerClient.d.ts.map +1 -0
  116. package/dist/react-native/eventHubProducerClient.js +366 -0
  117. package/dist/react-native/eventHubProducerClient.js.map +1 -0
  118. package/dist/react-native/eventHubSender.d.ts +227 -0
  119. package/dist/react-native/eventHubSender.d.ts.map +1 -0
  120. package/dist/react-native/eventHubSender.js +626 -0
  121. package/dist/react-native/eventHubSender.js.map +1 -0
  122. package/dist/react-native/eventPosition.d.ts +73 -0
  123. package/dist/react-native/eventPosition.d.ts.map +1 -0
  124. package/dist/react-native/eventPosition.js +121 -0
  125. package/dist/react-native/eventPosition.js.map +1 -0
  126. package/dist/react-native/eventProcessor.d.ts +232 -0
  127. package/dist/react-native/eventProcessor.d.ts.map +1 -0
  128. package/dist/react-native/eventProcessor.js +389 -0
  129. package/dist/react-native/eventProcessor.js.map +1 -0
  130. package/dist/react-native/eventhubConnectionConfig.d.ts +96 -0
  131. package/dist/react-native/eventhubConnectionConfig.d.ts.map +1 -0
  132. package/dist/react-native/eventhubConnectionConfig.js +98 -0
  133. package/dist/react-native/eventhubConnectionConfig.js.map +1 -0
  134. package/dist/react-native/impl/awaitableQueue.d.ts +25 -0
  135. package/dist/react-native/impl/awaitableQueue.d.ts.map +1 -0
  136. package/dist/react-native/impl/awaitableQueue.js +51 -0
  137. package/dist/react-native/impl/awaitableQueue.js.map +1 -0
  138. package/dist/react-native/impl/partitionAssigner.d.ts +29 -0
  139. package/dist/react-native/impl/partitionAssigner.d.ts.map +1 -0
  140. package/dist/react-native/impl/partitionAssigner.js +52 -0
  141. package/dist/react-native/impl/partitionAssigner.js.map +1 -0
  142. package/dist/react-native/impl/partitionGate.d.ts +27 -0
  143. package/dist/react-native/impl/partitionGate.d.ts.map +1 -0
  144. package/dist/react-native/impl/partitionGate.js +38 -0
  145. package/dist/react-native/impl/partitionGate.js.map +1 -0
  146. package/dist/react-native/impl/partitionKeyToIdMapper.d.ts +6 -0
  147. package/dist/react-native/impl/partitionKeyToIdMapper.d.ts.map +1 -0
  148. package/dist/react-native/impl/partitionKeyToIdMapper.js +111 -0
  149. package/dist/react-native/impl/partitionKeyToIdMapper.js.map +1 -0
  150. package/dist/react-native/inMemoryCheckpointStore.d.ts +44 -0
  151. package/dist/react-native/inMemoryCheckpointStore.d.ts.map +1 -0
  152. package/dist/react-native/inMemoryCheckpointStore.js +94 -0
  153. package/dist/react-native/inMemoryCheckpointStore.js.map +1 -0
  154. package/dist/react-native/index.d.ts +21 -0
  155. package/dist/react-native/index.d.ts.map +1 -0
  156. package/dist/react-native/index.js +12 -0
  157. package/dist/react-native/index.js.map +1 -0
  158. package/dist/react-native/loadBalancerStrategies/balancedStrategy.d.ts +30 -0
  159. package/dist/react-native/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -0
  160. package/dist/react-native/loadBalancerStrategies/balancedStrategy.js +40 -0
  161. package/dist/react-native/loadBalancerStrategies/balancedStrategy.js.map +1 -0
  162. package/dist/react-native/loadBalancerStrategies/greedyStrategy.d.ts +24 -0
  163. package/dist/react-native/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -0
  164. package/dist/react-native/loadBalancerStrategies/greedyStrategy.js +29 -0
  165. package/dist/react-native/loadBalancerStrategies/greedyStrategy.js.map +1 -0
  166. package/dist/react-native/loadBalancerStrategies/loadBalancingStrategy.d.ts +28 -0
  167. package/dist/react-native/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -0
  168. package/dist/react-native/loadBalancerStrategies/loadBalancingStrategy.js +245 -0
  169. package/dist/react-native/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -0
  170. package/dist/react-native/loadBalancerStrategies/unbalancedStrategy.d.ts +20 -0
  171. package/dist/react-native/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -0
  172. package/dist/react-native/loadBalancerStrategies/unbalancedStrategy.js +22 -0
  173. package/dist/react-native/loadBalancerStrategies/unbalancedStrategy.js.map +1 -0
  174. package/dist/react-native/logger.d.ts +37 -0
  175. package/dist/react-native/logger.d.ts.map +1 -0
  176. package/dist/react-native/logger.js +56 -0
  177. package/dist/react-native/logger.js.map +1 -0
  178. package/dist/react-native/managementClient.d.ts +145 -0
  179. package/dist/react-native/managementClient.d.ts.map +1 -0
  180. package/dist/react-native/managementClient.js +305 -0
  181. package/dist/react-native/managementClient.js.map +1 -0
  182. package/dist/react-native/models/private.d.ts +185 -0
  183. package/dist/react-native/models/private.d.ts.map +1 -0
  184. package/dist/react-native/models/private.js +4 -0
  185. package/dist/react-native/models/private.js.map +1 -0
  186. package/dist/react-native/models/public.d.ts +240 -0
  187. package/dist/react-native/models/public.d.ts.map +1 -0
  188. package/dist/react-native/models/public.js +18 -0
  189. package/dist/react-native/models/public.js.map +1 -0
  190. package/dist/react-native/package.json +3 -0
  191. package/dist/react-native/partitionProcessor.d.ts +134 -0
  192. package/dist/react-native/partitionProcessor.d.ts.map +1 -0
  193. package/dist/react-native/partitionProcessor.js +137 -0
  194. package/dist/react-native/partitionProcessor.js.map +1 -0
  195. package/dist/react-native/partitionPump.d.ts +38 -0
  196. package/dist/react-native/partitionPump.d.ts.map +1 -0
  197. package/dist/react-native/partitionPump.js +175 -0
  198. package/dist/react-native/partitionPump.js.map +1 -0
  199. package/dist/react-native/partitionReceiver.d.ts +82 -0
  200. package/dist/react-native/partitionReceiver.d.ts.map +1 -0
  201. package/dist/react-native/partitionReceiver.js +335 -0
  202. package/dist/react-native/partitionReceiver.js.map +1 -0
  203. package/dist/react-native/pumpManager.d.ts +72 -0
  204. package/dist/react-native/pumpManager.d.ts.map +1 -0
  205. package/dist/react-native/pumpManager.js +120 -0
  206. package/dist/react-native/pumpManager.js.map +1 -0
  207. package/dist/react-native/util/connectionStringUtils.d.ts +52 -0
  208. package/dist/react-native/util/connectionStringUtils.d.ts.map +1 -0
  209. package/dist/react-native/util/connectionStringUtils.js +48 -0
  210. package/dist/react-native/util/connectionStringUtils.js.map +1 -0
  211. package/dist/react-native/util/constants.d.ts +25 -0
  212. package/dist/react-native/util/constants.d.ts.map +1 -0
  213. package/dist/react-native/util/constants.js +27 -0
  214. package/dist/react-native/util/constants.js.map +1 -0
  215. package/dist/react-native/util/delayWithoutThrow.d.ts +8 -0
  216. package/dist/react-native/util/delayWithoutThrow.d.ts.map +1 -0
  217. package/dist/react-native/util/delayWithoutThrow.js +17 -0
  218. package/dist/react-native/util/delayWithoutThrow.js.map +1 -0
  219. package/dist/react-native/util/error.d.ts +39 -0
  220. package/dist/react-native/util/error.d.ts.map +1 -0
  221. package/dist/react-native/util/error.js +103 -0
  222. package/dist/react-native/util/error.js.map +1 -0
  223. package/dist/react-native/util/getPromiseParts.d.ts +10 -0
  224. package/dist/react-native/util/getPromiseParts.d.ts.map +1 -0
  225. package/dist/react-native/util/getPromiseParts.js +20 -0
  226. package/dist/react-native/util/getPromiseParts.js.map +1 -0
  227. package/dist/react-native/util/operationOptions.d.ts +16 -0
  228. package/dist/react-native/util/operationOptions.d.ts.map +1 -0
  229. package/dist/react-native/util/operationOptions.js +4 -0
  230. package/dist/react-native/util/operationOptions.js.map +1 -0
  231. package/dist/react-native/util/parseEndpoint.d.ts +11 -0
  232. package/dist/react-native/util/parseEndpoint.d.ts.map +1 -0
  233. package/dist/react-native/util/parseEndpoint.js +17 -0
  234. package/dist/react-native/util/parseEndpoint.js.map +1 -0
  235. package/dist/react-native/util/retries.d.ts +6 -0
  236. package/dist/react-native/util/retries.d.ts.map +1 -0
  237. package/dist/react-native/util/retries.js +13 -0
  238. package/dist/react-native/util/retries.js.map +1 -0
  239. package/dist/react-native/util/runtimeInfo-react-native.d.mts.map +1 -0
  240. package/dist/react-native/util/runtimeInfo-react-native.mjs.map +1 -0
  241. package/dist/react-native/util/runtimeInfo.d.ts +6 -0
  242. package/dist/react-native/util/runtimeInfo.js +20 -0
  243. package/dist/react-native/util/timerLoop.d.ts +26 -0
  244. package/dist/react-native/util/timerLoop.d.ts.map +1 -0
  245. package/dist/react-native/util/timerLoop.js +34 -0
  246. package/dist/react-native/util/timerLoop.js.map +1 -0
  247. package/dist/react-native/util/typeGuards.d.ts +8 -0
  248. package/dist/react-native/util/typeGuards.d.ts.map +1 -0
  249. package/dist/react-native/util/typeGuards.js +12 -0
  250. package/dist/react-native/util/typeGuards.js.map +1 -0
  251. package/dist/react-native/util/utils.d.ts +7 -0
  252. package/dist/react-native/util/utils.d.ts.map +1 -0
  253. package/dist/react-native/util/utils.js +13 -0
  254. package/dist/react-native/util/utils.js.map +1 -0
  255. package/dist/react-native/withAuth.d.ts +25 -0
  256. package/dist/react-native/withAuth.d.ts.map +1 -0
  257. package/dist/react-native/withAuth.js +84 -0
  258. package/dist/react-native/withAuth.js.map +1 -0
  259. package/package.json +16 -11
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventHubConsumerClient.js","sourceRoot":"","sources":["../../src/eventHubConsumerClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,cAAc,EAAE,MAAM,qB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Q,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,eAAe,GAAG,QAA2B,CAAC;IAEpD,OAAO,CACL,OAAO,eAAe,CAAC,cAAc,KAAK,UAAU;QACpD,OAAO,eAAe,CAAC,eAAe,KAAK,UAAU;QACrD,OAAO,eAAe,CAAC,aAAa,KAAK,UAAU;QACnD,OAAO,eAAe,CAAC,gBAAgB,KAAK,UAAU,CACvD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,2BAA2B,CAClC,QAAyC;IAEzC,OAAO,OAAQ,QAAsC,CAAC,aAAa,KAAK,UAAU,CAAC;AACrF,CAAC;AAED,SAAS,aAAa,CACpB,OAAqC,EACrC,wBAAiC;IAEjC,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,UAAU,CAAC;IAC5B,CAAC;IAED,IAAI,wBAAwB,EAAE,CAAC;QAC7B,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CheckpointStore, FullEventProcessorOptions } from \"./eventProcessor.js\";\nimport { EventProcessor } from \"./eventProcessor.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport { createConnectionContext } from \"./connectionContext.js\";\nimport type {\n EventHubConsumerClientOptions,\n GetEventHubPropertiesOptions,\n GetPartitionIdsOptions,\n GetPartitionPropertiesOptions,\n LoadBalancingOptions,\n} from \"./models/public.js\";\nimport type { EventHubProperties, PartitionProperties } from \"./managementClient.js\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport type {\n SubscribeOptions,\n Subscription,\n SubscriptionEventHandlers,\n} from \"./eventHubConsumerClientModels.js\";\nimport { BalancedLoadBalancingStrategy } from \"./loadBalancerStrategies/balancedStrategy.js\";\nimport { Constants } from \"@azure/core-amqp\";\nimport { GreedyLoadBalancingStrategy } from \"./loadBalancerStrategies/greedyStrategy.js\";\nimport { InMemoryCheckpointStore } from \"./inMemoryCheckpointStore.js\";\nimport type { LoadBalancingStrategy } from \"./loadBalancerStrategies/loadBalancingStrategy.js\";\nimport { PartitionGate } from \"./impl/partitionGate.js\";\nimport { UnbalancedLoadBalancingStrategy } from \"./loadBalancerStrategies/unbalancedStrategy.js\";\nimport { isCredential } from \"./util/typeGuards.js\";\nimport { logger } from \"./logger.js\";\nimport { validateEventPositions } from \"./eventPosition.js\";\nimport { getRandomName } from \"./util/utils.js\";\n\nconst defaultConsumerClientOptions: Required<\n Pick<FullEventProcessorOptions, \"maxWaitTimeInSeconds\" | \"maxBatchSize\">\n> = {\n // to support our current \"process single event only\" workflow we'll also purposefully\n // only request a single event at a time.\n maxBatchSize: 1,\n maxWaitTimeInSeconds: 60,\n};\n\n/**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n *\n * There are multiple ways to create an `EventHubConsumerClient`\n * - Use the connection string from the SAS policy created for your Event Hub instance.\n * - Use the connection string from the SAS policy created for your Event Hub namespace,\n * and the name of the Event Hub instance\n * - Use the full namespace like `<yournamespace>.servicebus.windows.net`, and a credentials object.\n *\n * Optionally, you can also pass:\n * - An options bag to configure the retry policy or proxy settings.\n * - A checkpoint store that is used by the client to read checkpoints to determine the position from where it should\n * resume receiving events when your application gets restarted. The checkpoint store is also used by the client\n * to load balance multiple instances of your application.\n */\nexport class EventHubConsumerClient {\n /**\n * Describes the amqp connection context for the client.\n */\n private _context: ConnectionContext;\n /**\n * The options passed by the user when creating the EventHubClient instance.\n */\n private _clientOptions: EventHubConsumerClientOptions;\n private _partitionGate = new PartitionGate();\n\n /**\n * The Subscriptions that were spawned by calling `subscribe()`.\n * Subscriptions that have been stopped by the user will not\n * be present in this set.\n */\n private _subscriptions = new Set<Subscription>();\n\n /**\n * The name of the default consumer group in the Event Hubs service.\n */\n static defaultConsumerGroupName: string = Constants.defaultConsumerGroup;\n\n private _checkpointStore: CheckpointStore;\n private _userChoseCheckpointStore: boolean;\n\n /**\n * Options for configuring load balancing.\n */\n private readonly _loadBalancingOptions: Required<LoadBalancingOptions>;\n\n /**\n * @readonly\n * The name of the Event Hub instance for which this client is created.\n */\n get eventHubName(): string {\n return this._context.config.entityPath;\n }\n\n /**\n * @readonly\n * The fully qualified namespace of the Event Hub instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n get fullyQualifiedNamespace(): string {\n return this._context.config.host;\n }\n\n /**\n * The name used to identify this EventHubConsumerClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public readonly identifier: string;\n\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n connectionString: string,\n options?: EventHubConsumerClientOptions,\n ); // #1\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param checkpointStore - A checkpoint store that is used by the client to read checkpoints to determine\n * the position from where it should resume receiving events when your application gets restarted.\n * It is also used by the client to load balance multiple instances of your application.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n connectionString: string,\n checkpointStore: CheckpointStore,\n options?: EventHubConsumerClientOptions,\n ); // #1.1\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n connectionString: string,\n eventHubName: string,\n options?: EventHubConsumerClientOptions,\n ); // #2\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param checkpointStore - A checkpoint store that is used by the client to read checkpoints to determine\n * the position from where it should resume receiving events when your application gets restarted.\n * It is also used by the client to load balance multiple instances of your application.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n connectionString: string,\n eventHubName: string,\n checkpointStore: CheckpointStore,\n options?: EventHubConsumerClientOptions,\n ); // #2.1\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See &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 consumerGroup: string,\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options?: EventHubConsumerClientOptions,\n ); // #3\n /**\n * The `EventHubConsumerClient` class is used to consume events from an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See &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 checkpointStore - A checkpoint store that is used by the client to read checkpoints to determine\n * the position from where it should resume receiving events when your application gets restarted.\n * It is also used by the client to load balance multiple instances of your application.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n consumerGroup: string,\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n checkpointStore: CheckpointStore,\n options?: EventHubConsumerClientOptions,\n ); // #3.1\n constructor(\n private _consumerGroup: string,\n connectionStringOrFullyQualifiedNamespace2: string,\n checkpointStoreOrEventHubNameOrOptions3?:\n | CheckpointStore\n | EventHubConsumerClientOptions\n | string,\n checkpointStoreOrCredentialOrOptions4?:\n | CheckpointStore\n | EventHubConsumerClientOptions\n | TokenCredential\n | NamedKeyCredential\n | SASCredential,\n checkpointStoreOrOptions5?: CheckpointStore | EventHubConsumerClientOptions,\n options6?: EventHubConsumerClientOptions,\n ) {\n if (isCredential(checkpointStoreOrCredentialOrOptions4)) {\n // #3 or 3.1\n logger.info(\"Creating EventHubConsumerClient with TokenCredential.\");\n\n if (isCheckpointStore(checkpointStoreOrOptions5)) {\n // 3.1\n this._checkpointStore = checkpointStoreOrOptions5;\n this._userChoseCheckpointStore = true;\n this._clientOptions = options6 || {};\n } else {\n this._checkpointStore = new InMemoryCheckpointStore();\n this._userChoseCheckpointStore = false;\n this._clientOptions = checkpointStoreOrOptions5 || {};\n }\n\n this._context = createConnectionContext(\n connectionStringOrFullyQualifiedNamespace2,\n checkpointStoreOrEventHubNameOrOptions3 as string,\n checkpointStoreOrCredentialOrOptions4,\n this._clientOptions,\n );\n } else if (typeof checkpointStoreOrEventHubNameOrOptions3 === \"string\") {\n // #2 or 2.1\n logger.info(\"Creating EventHubConsumerClient with connection string and event hub name.\");\n\n if (isCheckpointStore(checkpointStoreOrCredentialOrOptions4)) {\n // 2.1\n this._checkpointStore = checkpointStoreOrCredentialOrOptions4;\n this._userChoseCheckpointStore = true;\n this._clientOptions = (checkpointStoreOrOptions5 as EventHubConsumerClientOptions) || {};\n } else {\n // 2\n this._checkpointStore = new InMemoryCheckpointStore();\n this._userChoseCheckpointStore = false;\n this._clientOptions = checkpointStoreOrCredentialOrOptions4 || {};\n }\n\n this._context = createConnectionContext(\n connectionStringOrFullyQualifiedNamespace2,\n checkpointStoreOrEventHubNameOrOptions3,\n this._clientOptions,\n );\n } else {\n // #1 or 1.1\n logger.info(\"Creating EventHubConsumerClient with connection string.\");\n\n if (isCheckpointStore(checkpointStoreOrEventHubNameOrOptions3)) {\n // 1.1\n this._checkpointStore = checkpointStoreOrEventHubNameOrOptions3;\n this._userChoseCheckpointStore = true;\n this._clientOptions =\n (checkpointStoreOrCredentialOrOptions4 as EventHubConsumerClientOptions) || {};\n } else {\n // 1\n this._checkpointStore = new InMemoryCheckpointStore();\n this._userChoseCheckpointStore = false;\n this._clientOptions =\n (checkpointStoreOrEventHubNameOrOptions3 as EventHubConsumerClientOptions) || {};\n }\n\n this._context = createConnectionContext(\n connectionStringOrFullyQualifiedNamespace2,\n this._clientOptions,\n );\n }\n this.identifier = this._clientOptions.identifier ?? getRandomName();\n this._loadBalancingOptions = {\n // default options\n strategy: \"balanced\",\n updateIntervalInMs: 10000,\n partitionOwnershipExpirationIntervalInMs: 60000,\n // options supplied by user\n ...this._clientOptions?.loadBalancingOptions,\n };\n }\n\n /**\n * Closes the AMQP connection to the Event Hub instance,\n * returning a promise that will be resolved when disconnection is completed.\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n async close(): Promise<void> {\n // Stop all the actively running subscriptions.\n const activeSubscriptions = Array.from(this._subscriptions);\n await Promise.all(\n activeSubscriptions.map((subscription) => {\n return subscription.close();\n }),\n );\n // Close the connection via the connection context.\n return this._context.close();\n }\n\n /**\n * Provides the id for each partition associated with the Event Hub.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with an Array of strings representing the id for\n * each partition associated with the Event Hub.\n * @throws Error if the underlying connection has been closed, create a new EventHubConsumerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n async getPartitionIds(options: GetPartitionIdsOptions = {}): Promise<Array<string>> {\n const eventHubProperties = await this._context.managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n return eventHubProperties.partitionIds;\n }\n\n /**\n * Provides information about the state of the specified partition.\n * @param partitionId - The id of the partition for which information is required.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the state of the partition .\n * @throws Error if the underlying connection has been closed, create a new EventHubConsumerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionProperties(\n partitionId: string,\n options: GetPartitionPropertiesOptions = {},\n ): Promise<PartitionProperties> {\n return this._context.managementSession!.getPartitionProperties(partitionId, {\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n\n /**\n * Provides the Event Hub runtime information.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the Event Hub instance.\n * @throws Error if the underlying connection has been closed, create a new EventHubConsumerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise<EventHubProperties> {\n return this._context.managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n\n /**\n * Subscribe to events from all partitions.\n *\n * If checkpoint store is provided to the `EventHubConsumerClient` and there are multiple\n * instances of your application, then each instance will subscribe to a subset of the\n * partitions such that the load is balanced amongst them.\n *\n * Call close() on the returned object to stop receiving events.\n *\n * Example usage:\n * ```ts snippet:EventHubConsumerClient_Subscribe\n * import { EventHubConsumerClient, earliestEventPosition } from \"@azure/event-hubs\";\n *\n * const client = new EventHubConsumerClient(\"my-consumer-group\", \"connectionString\", \"eventHubName\");\n *\n * const subscription = client.subscribe(\n * {\n * processEvents: async (events, context) => {\n * console.log(\"Received event count: \", events.length);\n * },\n * processError: async (err, context) => {\n * console.log(\"Error: \", err);\n * },\n * },\n * { startPosition: earliestEventPosition },\n * );\n * ```\n *\n * @param handlers - Handlers for the lifecycle of the subscription - subscription initialization\n * per partition, receiving events, handling errors and the closing\n * of a subscription per partition.\n * @param options - Configures the way events are received.\n * Most common are `maxBatchSize` and `maxWaitTimeInSeconds` that control the flow of\n * events to the handler provided to receive events as well as the start position. For example,\n * `{ maxBatchSize: 20, maxWaitTimeInSeconds: 120, startPosition: { sequenceNumber: 123 } }`\n */\n subscribe(handlers: SubscriptionEventHandlers, options?: SubscribeOptions): Subscription; // #1\n /**\n * Subscribe to events from a single partition.\n * Call close() on the returned object to stop receiving events.\n *\n * Example usage:\n * ```ts snippet:EventHubConsumerClient_SubscribeSinglePartition\n * import { EventHubConsumerClient, earliestEventPosition } from \"@azure/event-hubs\";\n *\n * const client = new EventHubConsumerClient(\"my-consumer-group\", \"connectionString\", \"eventHubName\");\n *\n * const partitionIds = await client.getPartitionIds();\n *\n * const subscription = client.subscribe(\n * partitionIds[0],\n * {\n * processEvents: async (events, context) => {\n * console.log(\"Received event count: \", events.length);\n * },\n * processError: async (err, context) => {\n * console.log(\"Error: \", err);\n * },\n * },\n * { startPosition: earliestEventPosition },\n * );\n * ```\n *\n * @param partitionId - The id of the partition to subscribe to.\n * @param handlers - Handlers for the lifecycle of the subscription - subscription initialization\n * of the partition, receiving events, handling errors and the closing\n * of a subscription to the partition.\n * @param options - Configures the way events are received.\n * Most common are `maxBatchSize` and `maxWaitTimeInSeconds` that control the flow of\n * events to the handler provided to receive events as well as the start position. For example,\n * `{ maxBatchSize: 20, maxWaitTimeInSeconds: 120, startPosition: { sequenceNumber: 123 } }`\n */\n\n subscribe(\n partitionId: string,\n handlers: SubscriptionEventHandlers,\n options?: SubscribeOptions,\n ): Subscription; // #2\n subscribe(\n handlersOrPartitionId1?: SubscriptionEventHandlers | string,\n optionsOrHandlers2?: SubscribeOptions | SubscriptionEventHandlers,\n possibleOptions3?: SubscribeOptions,\n ): Subscription {\n let eventProcessor: EventProcessor;\n let targetedPartitionId: string;\n\n if (isSubscriptionEventHandlers(handlersOrPartitionId1)) {\n // #1: subscribe overload - read from all partitions\n const options = optionsOrHandlers2 as SubscribeOptions | undefined;\n if (options && options.startPosition) {\n validateEventPositions(options.startPosition);\n }\n ({ targetedPartitionId, eventProcessor } = this.createEventProcessorForAllPartitions(\n handlersOrPartitionId1,\n options,\n ));\n } else if (isSubscriptionEventHandlers(optionsOrHandlers2)) {\n // #2: subscribe overload (read from specific partition IDs), don't coordinate\n const options = possibleOptions3 as SubscribeOptions | undefined;\n if (options && options.startPosition) {\n validateEventPositions(options.startPosition);\n }\n ({ targetedPartitionId, eventProcessor } = this.createEventProcessorForSinglePartition(\n // cast to string as downstream code expects partitionId to be string, but JS users could have given us anything.\n // we don't validate the user input and instead rely on service throwing errors if any\n String(handlersOrPartitionId1),\n optionsOrHandlers2,\n possibleOptions3,\n ));\n } else {\n throw new TypeError(\"Unhandled subscribe() overload\");\n }\n\n eventProcessor.start();\n\n const subscription = {\n get isRunning() {\n return eventProcessor.isRunning();\n },\n close: () => {\n this._partitionGate.remove(targetedPartitionId);\n this._subscriptions.delete(subscription);\n return eventProcessor.stop();\n },\n };\n this._subscriptions.add(subscription);\n return subscription;\n }\n\n /**\n * Gets the LoadBalancing strategy that should be used based on what the user provided.\n */\n private _getLoadBalancingStrategy(): LoadBalancingStrategy {\n if (!this._userChoseCheckpointStore) {\n // The default behavior when a checkpointstore isn't provided\n // is to always grab all the partitions.\n return new UnbalancedLoadBalancingStrategy();\n }\n\n const partitionOwnershipExpirationIntervalInMs =\n this._loadBalancingOptions.partitionOwnershipExpirationIntervalInMs;\n if (this._loadBalancingOptions?.strategy === \"greedy\") {\n return new GreedyLoadBalancingStrategy(partitionOwnershipExpirationIntervalInMs);\n }\n\n // The default behavior when a checkpointstore is provided is\n // to grab one partition at a time.\n return new BalancedLoadBalancingStrategy(partitionOwnershipExpirationIntervalInMs);\n }\n\n private createEventProcessorForAllPartitions(\n subscriptionEventHandlers: SubscriptionEventHandlers,\n options?: SubscribeOptions,\n ): { targetedPartitionId: string; eventProcessor: EventProcessor } {\n this._partitionGate.add(\"all\");\n\n if (this._userChoseCheckpointStore) {\n logger.verbose(\n \"EventHubConsumerClient subscribing to all partitions, using a checkpoint store.\",\n );\n } else {\n logger.verbose(\"EventHubConsumerClient subscribing to all partitions, no checkpoint store.\");\n }\n\n const loadBalancingStrategy = this._getLoadBalancingStrategy();\n const eventProcessor = this._createEventProcessor(\n this._context,\n subscriptionEventHandlers,\n this._checkpointStore,\n {\n ...defaultConsumerClientOptions,\n ...(options as SubscribeOptions),\n ownerLevel: getOwnerLevel(options, this._userChoseCheckpointStore),\n // make it so all the event processors process work with the same overarching owner ID\n // this allows the EventHubConsumer to unify all the work for any processors that it spawns\n ownerId: this.identifier,\n retryOptions: this._clientOptions.retryOptions,\n loadBalancingStrategy,\n loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs,\n },\n );\n\n return { targetedPartitionId: \"all\", eventProcessor };\n }\n\n private createEventProcessorForSinglePartition(\n partitionId: string,\n eventHandlers: SubscriptionEventHandlers,\n options?: SubscribeOptions,\n ): { targetedPartitionId: string; eventProcessor: EventProcessor } {\n this._partitionGate.add(partitionId);\n\n const subscribeOptions = options as SubscribeOptions | undefined;\n\n if (this._userChoseCheckpointStore) {\n logger.verbose(\n `EventHubConsumerClient subscribing to specific partition (${partitionId}), using a checkpoint store.`,\n );\n } else {\n logger.verbose(\n `EventHubConsumerClient subscribing to specific partition (${partitionId}), no checkpoint store.`,\n );\n }\n\n const eventProcessor = this._createEventProcessor(\n this._context,\n eventHandlers,\n this._checkpointStore,\n {\n ...defaultConsumerClientOptions,\n ...options,\n processingTarget: partitionId,\n ownerLevel: getOwnerLevel(subscribeOptions, this._userChoseCheckpointStore),\n retryOptions: this._clientOptions.retryOptions,\n loadBalancingStrategy: new UnbalancedLoadBalancingStrategy(),\n loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs ?? 10000,\n },\n );\n\n return { targetedPartitionId: partitionId, eventProcessor };\n }\n\n private _createEventProcessor(\n connectionContext: ConnectionContext,\n subscriptionEventHandlers: SubscriptionEventHandlers,\n checkpointStore: CheckpointStore,\n options: FullEventProcessorOptions,\n ): EventProcessor {\n return new EventProcessor(\n this._consumerGroup,\n connectionContext,\n subscriptionEventHandlers,\n checkpointStore,\n options,\n );\n }\n}\n\n/**\n * @internal\n */\nexport function isCheckpointStore(possible: CheckpointStore | any): possible is CheckpointStore {\n if (!possible) {\n return false;\n }\n\n const checkpointStore = possible as CheckpointStore;\n\n return (\n typeof checkpointStore.claimOwnership === \"function\" &&\n typeof checkpointStore.listCheckpoints === \"function\" &&\n typeof checkpointStore.listOwnership === \"function\" &&\n typeof checkpointStore.updateCheckpoint === \"function\"\n );\n}\n\n/**\n * @internal\n */\nfunction isSubscriptionEventHandlers(\n possible: any | SubscriptionEventHandlers,\n): possible is SubscriptionEventHandlers {\n return typeof (possible as SubscriptionEventHandlers).processEvents === \"function\";\n}\n\nfunction getOwnerLevel(\n options: SubscribeOptions | undefined,\n userChoseCheckpointStore: boolean,\n): number | undefined {\n if (options && options.ownerLevel) {\n return options.ownerLevel;\n }\n\n if (userChoseCheckpointStore) {\n return 0;\n } else {\n return undefined;\n }\n}\n"]}
@@ -0,0 +1,218 @@
1
+ import type { CloseReason } from "./models/public.js";
2
+ import type { EventPosition } from "./eventPosition.js";
3
+ import type { LastEnqueuedEventProperties } from "./partitionReceiver.js";
4
+ import type { MessagingError } from "@azure/core-amqp";
5
+ import type { OperationTracingOptions } from "@azure/core-tracing";
6
+ import type { ReceivedEventData } from "./eventData.js";
7
+ /**
8
+ * @internal
9
+ */
10
+ export interface BasicPartitionProperties {
11
+ /**
12
+ * The fully qualified Event Hubs namespace. This is likely to be similar to
13
+ * <yournamespace>.servicebus.windows.net
14
+ */
15
+ fullyQualifiedNamespace: string;
16
+ /**
17
+ * The event hub name.
18
+ */
19
+ eventHubName: string;
20
+ /**
21
+ * The consumer group name.
22
+ */
23
+ consumerGroup: string;
24
+ /**
25
+ * The identifier of the Event Hub partition.
26
+ */
27
+ partitionId: string;
28
+ }
29
+ /**
30
+ * Interface that describes the context passed to each of the functions that are a part
31
+ * of the `SubscriptionEventHandlers`. When implementing any of these functions, use
32
+ * the context object to get information about the partition as well as the
33
+ * ability to checkpoint.
34
+ */
35
+ export interface PartitionContext {
36
+ /**
37
+ * The fully qualified Event Hubs namespace. This is likely to be similar to
38
+ * <yournamespace>.servicebus.windows.net
39
+ */
40
+ readonly fullyQualifiedNamespace: string;
41
+ /**
42
+ * The event hub name.
43
+ */
44
+ readonly eventHubName: string;
45
+ /**
46
+ * The consumer group name.
47
+ */
48
+ readonly consumerGroup: string;
49
+ /**
50
+ * The identifier of the Event Hub partition.
51
+ */
52
+ readonly partitionId: string;
53
+ /**
54
+ * Information on the last enqueued event in the partition that is being processed.
55
+ * This property is only updated if the `trackLastEnqueuedEventProperties` option is set to true
56
+ * when creating an instance of EventProcessor.
57
+ * @readonly
58
+ */
59
+ readonly lastEnqueuedEventProperties?: LastEnqueuedEventProperties;
60
+ /**
61
+ * Updates the checkpoint using the event data.
62
+ *
63
+ * A checkpoint is meant to represent the last successfully processed event by the user from a particular
64
+ * partition of a consumer group in an Event Hub instance.
65
+ *
66
+ * @param eventData - The event that you want to update the checkpoint with.
67
+ */
68
+ updateCheckpoint(eventData: ReceivedEventData): Promise<void>;
69
+ }
70
+ /**
71
+ * Signature of the user provided function invoked by `EventHubConsumerClient` when a set of events is received.
72
+ */
73
+ export type ProcessEventsHandler = (events: ReceivedEventData[], context: PartitionContext) => Promise<void>;
74
+ /**
75
+ * Signature of the user provided function invoked by `EventHubConsumerClient` for errors that occur when
76
+ * receiving events or when executing any of the user provided functions passed to the `subscribe()` method.
77
+ */
78
+ export type ProcessErrorHandler = (error: Error | MessagingError, context: PartitionContext) => Promise<void>;
79
+ /**
80
+ * Signature of the user provided function invoked by `EventHubConsumerClient` just before starting to receive
81
+ * events from a partition.
82
+ */
83
+ export type ProcessInitializeHandler = (context: PartitionContext) => Promise<void>;
84
+ /**
85
+ * Signature of the user provided function invoked by `EventHubConsumerClient` just after stopping to receive
86
+ * events from a partition.
87
+ */
88
+ export type ProcessCloseHandler = (reason: CloseReason, context: PartitionContext) => Promise<void>;
89
+ /**
90
+ * Interface that describes the functions to be implemented by the user which are invoked by
91
+ * the `EventHubConsumerClient` when the `subscribe()` method is called to receive events
92
+ * from Event Hub.
93
+ */
94
+ export interface SubscriptionEventHandlers {
95
+ /**
96
+ * The function invoked by `EventHubConsumerClient` when a set of events is received. The
97
+ * `PartitionContext` passed to this function can be used to determine which partition is being read from.
98
+ *
99
+ * The `updateCheckpoint()` method on the context can be used to update checkpoints in the `CheckpointStore`
100
+ * (if one was provided to the client). Use this in frequent intervals to mark events that have been processed
101
+ * so that the client can restart from such checkpoints in the event of a restart or error recovery.
102
+ *
103
+ * Note: It is possible for received events to be an empty array.
104
+ * This can happen if there are no new events to receive
105
+ * in the `maxWaitTimeInSeconds`, which is defaulted to 60 seconds.
106
+ * The `maxWaitTimeInSeconds` can be changed by setting
107
+ * it in the `options` passed to `subscribe()`.
108
+ */
109
+ processEvents: ProcessEventsHandler;
110
+ /**
111
+ * The function invoked by `EventHubConsumerClient` for errors that occur when receiving events
112
+ * or when executing any of the user provided functions passed to the `subscribe()` method.
113
+ *
114
+ * The `PartitionContext` passed to this function will indicate the partition that was being processed
115
+ * when the error was thrown. In cases where an error is thrown outside of processing events from a
116
+ * partition(e.g. failure to perform load balancing), the `partitionId` on the context will be an empty string.
117
+ *
118
+ * After the client completes executing this function, the `partitionClose` function is invoked.
119
+ */
120
+ processError: ProcessErrorHandler;
121
+ /**
122
+ * The function invoked by `EventHubConsumerClient` each time the subscription is about to begin
123
+ * reading from a partition. The `PartitionContext` passed to this function can be used to determine
124
+ * which partition is about to be read from.
125
+ *
126
+ * The client will start receiving events for the partition only after completing the execution of
127
+ * this function (if provided). Therefore, use this function to carry out any setup work including
128
+ * async tasks.
129
+ */
130
+ processInitialize?: ProcessInitializeHandler;
131
+ /**
132
+ * The function invoked by `EventHubConsumerClient` each time the subscription stops reading events from
133
+ * a partition. The information on this partition will be available on the `PartitionContext` passed to the
134
+ * function `processClose`.
135
+ *
136
+ * If the `CloseReason` passed to this function is `OwnershipLost`, then another subscription has taken over
137
+ * reading from the same partition using the same consumer group. This is expected if you have multiple
138
+ * instances of your application running and have passed the `CheckpointStore` to the client to load balance.
139
+ *
140
+ * If the `CloseReason` is `Shutdown`, this indicates that either `subscription.close()` was called, or an
141
+ * error occured. Unless the subscription was explicitly closed via `subscription.close()`, the subscription
142
+ * will attempt to resume reading events from the last checkpoint for the partition.
143
+ */
144
+ processClose?: ProcessCloseHandler;
145
+ }
146
+ /**
147
+ * Options to configure the `subscribe` method on the `EventHubConsumerClient`.
148
+ * For example, `{ maxBatchSize: 20, maxWaitTimeInSeconds: 120, startPosition: { sequenceNumber: 123 } }`
149
+ */
150
+ export interface SubscribeOptions {
151
+ /**
152
+ * The number of events to request per batch
153
+ */
154
+ maxBatchSize?: number;
155
+ /**
156
+ * The maximum amount of time to wait to build up the requested message count before
157
+ * passing the data to user code for processing. If not provided, it defaults to 60 seconds.
158
+ */
159
+ maxWaitTimeInSeconds?: number;
160
+ /**
161
+ * The event position in a partition to start receiving events from if no checkpoint is found.
162
+ * Pass a map of partition id to position if you would like to use different starting
163
+ * position for each partition.
164
+ */
165
+ startPosition?: EventPosition | {
166
+ [partitionId: string]: EventPosition;
167
+ };
168
+ /**
169
+ * Indicates whether or not the consumer should request information on the last enqueued event on its
170
+ * associated partition, and track that information as events are received.
171
+
172
+ * When information about the partition's last enqueued event is being tracked, each event received
173
+ * from the Event Hubs service will carry metadata about the partition that it otherwise would not. This results in a small amount of
174
+ * additional network bandwidth consumption that is generally a favorable trade-off when considered
175
+ * against periodically making requests for partition properties using the Event Hub client.
176
+ */
177
+ trackLastEnqueuedEventProperties?: boolean;
178
+ /**
179
+ * The owner level to use as this subscription subscribes to partitions.
180
+ */
181
+ ownerLevel?: number;
182
+ /**
183
+ * Options for configuring tracing.
184
+ */
185
+ tracingOptions?: OperationTracingOptions;
186
+ /**
187
+ * Option to disable the client from running JSON.parse() on the message body when receiving the message.
188
+ * Not applicable if the message was sent with AMQP body type value or sequence. Use this option when you
189
+ * prefer to work directly with the bytes present in the message body than have the client attempt to parse it.
190
+ */
191
+ skipParsingBodyAsJson?: boolean;
192
+ /**
193
+ * The count of events requested eagerly and queued without regard to whether a read was requested.
194
+ */
195
+ prefetchCount?: number;
196
+ }
197
+ /**
198
+ * Interface that describes the object returned by the `subscribe()` method on the `EventHubConsumerClient`.
199
+ */
200
+ export interface Subscription {
201
+ /**
202
+ * Stops the subscription from receiving more messages.
203
+ *
204
+ * If a checkpoint store has been configured this will also mark this subscription's
205
+ * partitions as abandoned, freeing them up to be read by other consumers.
206
+ *
207
+ * @returns Promise<void>
208
+ * @throws Error if the underlying connection encounters an error while closing.
209
+ */
210
+ close(): Promise<void>;
211
+ /**
212
+ * Indicates whether the receiver is running.
213
+ * `true` - is running; `false` otherwise.
214
+ * @readonly
215
+ */
216
+ isRunning: boolean;
217
+ }
218
+ //# sourceMappingURL=eventHubConsumerClientModels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventHubConsumerClientModels.d.ts","sourceRoot":"","sources":["../../src/eventHubConsumerClientModels.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAA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CAAA;KAAE,CAAC;IACzE;;;;;;;;OAQG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,uBAAuB,CAAC;IACzC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;OAQG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=eventHubConsumerClientModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventHubConsumerClientModels.js","sourceRoot":"","sources":["../../src/eventHubConsumerClientModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CloseReason } from \"./models/public.js\";\nimport type { EventPosition } from \"./eventPosition.js\";\nimport type { LastEnqueuedEventProperties } from \"./partitionReceiver.js\";\nimport type { MessagingError } from \"@azure/core-amqp\";\nimport type { OperationTracingOptions } from \"@azure/core-tracing\";\nimport type { ReceivedEventData } from \"./eventData.js\";\n\n/**\n * @internal\n */\nexport interface BasicPartitionProperties {\n /**\n * The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n */\n fullyQualifiedNamespace: string;\n /**\n * The event hub name.\n */\n eventHubName: string;\n /**\n * The consumer group name.\n */\n consumerGroup: string;\n /**\n * The identifier of the Event Hub partition.\n */\n partitionId: string;\n}\n\n/**\n * Interface that describes the context passed to each of the functions that are a part\n * of the `SubscriptionEventHandlers`. When implementing any of these functions, use\n * the context object to get information about the partition as well as the\n * ability to checkpoint.\n */\nexport interface PartitionContext {\n /**\n * The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n */\n readonly fullyQualifiedNamespace: string;\n /**\n * The event hub name.\n */\n readonly eventHubName: string;\n /**\n * The consumer group name.\n */\n readonly consumerGroup: string;\n /**\n * The identifier of the Event Hub partition.\n */\n readonly partitionId: string;\n /**\n * Information on the last enqueued event in the partition that is being processed.\n * This property is only updated if the `trackLastEnqueuedEventProperties` option is set to true\n * when creating an instance of EventProcessor.\n * @readonly\n */\n readonly lastEnqueuedEventProperties?: LastEnqueuedEventProperties;\n /**\n * Updates the checkpoint using the event data.\n *\n * A checkpoint is meant to represent the last successfully processed event by the user from a particular\n * partition of a consumer group in an Event Hub instance.\n *\n * @param eventData - The event that you want to update the checkpoint with.\n */\n updateCheckpoint(eventData: ReceivedEventData): Promise<void>;\n}\n\n/**\n * Signature of the user provided function invoked by `EventHubConsumerClient` when a set of events is received.\n */\nexport type ProcessEventsHandler = (\n events: ReceivedEventData[],\n context: PartitionContext,\n) => Promise<void>;\n\n/**\n * Signature of the user provided function invoked by `EventHubConsumerClient` for errors that occur when\n * receiving events or when executing any of the user provided functions passed to the `subscribe()` method.\n */\nexport type ProcessErrorHandler = (\n error: Error | MessagingError,\n context: PartitionContext,\n) => Promise<void>;\n\n/**\n * Signature of the user provided function invoked by `EventHubConsumerClient` just before starting to receive\n * events from a partition.\n */\nexport type ProcessInitializeHandler = (context: PartitionContext) => Promise<void>;\n\n/**\n * Signature of the user provided function invoked by `EventHubConsumerClient` just after stopping to receive\n * events from a partition.\n */\nexport type ProcessCloseHandler = (reason: CloseReason, context: PartitionContext) => Promise<void>;\n\n/**\n * Interface that describes the functions to be implemented by the user which are invoked by\n * the `EventHubConsumerClient` when the `subscribe()` method is called to receive events\n * from Event Hub.\n */\nexport interface SubscriptionEventHandlers {\n /**\n * The function invoked by `EventHubConsumerClient` when a set of events is received. The\n * `PartitionContext` passed to this function can be used to determine which partition is being read from.\n *\n * The `updateCheckpoint()` method on the context can be used to update checkpoints in the `CheckpointStore`\n * (if one was provided to the client). Use this in frequent intervals to mark events that have been processed\n * so that the client can restart from such checkpoints in the event of a restart or error recovery.\n *\n * Note: It is possible for received events to be an empty array.\n * This can happen if there are no new events to receive\n * in the `maxWaitTimeInSeconds`, which is defaulted to 60 seconds.\n * The `maxWaitTimeInSeconds` can be changed by setting\n * it in the `options` passed to `subscribe()`.\n */\n processEvents: ProcessEventsHandler;\n /**\n * The function invoked by `EventHubConsumerClient` for errors that occur when receiving events\n * or when executing any of the user provided functions passed to the `subscribe()` method.\n *\n * The `PartitionContext` passed to this function will indicate the partition that was being processed\n * when the error was thrown. In cases where an error is thrown outside of processing events from a\n * partition(e.g. failure to perform load balancing), the `partitionId` on the context will be an empty string.\n *\n * After the client completes executing this function, the `partitionClose` function is invoked.\n */\n processError: ProcessErrorHandler;\n /**\n * The function invoked by `EventHubConsumerClient` each time the subscription is about to begin\n * reading from a partition. The `PartitionContext` passed to this function can be used to determine\n * which partition is about to be read from.\n *\n * The client will start receiving events for the partition only after completing the execution of\n * this function (if provided). Therefore, use this function to carry out any setup work including\n * async tasks.\n */\n processInitialize?: ProcessInitializeHandler;\n /**\n * The function invoked by `EventHubConsumerClient` each time the subscription stops reading events from\n * a partition. The information on this partition will be available on the `PartitionContext` passed to the\n * function `processClose`.\n *\n * If the `CloseReason` passed to this function is `OwnershipLost`, then another subscription has taken over\n * reading from the same partition using the same consumer group. This is expected if you have multiple\n * instances of your application running and have passed the `CheckpointStore` to the client to load balance.\n *\n * If the `CloseReason` is `Shutdown`, this indicates that either `subscription.close()` was called, or an\n * error occured. Unless the subscription was explicitly closed via `subscription.close()`, the subscription\n * will attempt to resume reading events from the last checkpoint for the partition.\n */\n processClose?: ProcessCloseHandler;\n}\n\n/**\n * Options to configure the `subscribe` method on the `EventHubConsumerClient`.\n * For example, `{ maxBatchSize: 20, maxWaitTimeInSeconds: 120, startPosition: { sequenceNumber: 123 } }`\n */\nexport interface SubscribeOptions {\n /**\n * The number of events to request per batch\n */\n maxBatchSize?: number;\n /**\n * The maximum amount of time to wait to build up the requested message count before\n * passing the data to user code for processing. If not provided, it defaults to 60 seconds.\n */\n maxWaitTimeInSeconds?: number;\n /**\n * The event position in a partition to start receiving events from if no checkpoint is found.\n * Pass a map of partition id to position if you would like to use different starting\n * position for each partition.\n */\n startPosition?: EventPosition | { [partitionId: string]: EventPosition };\n /**\n * Indicates whether or not the consumer should request information on the last enqueued event on its\n * associated partition, and track that information as events are received.\n\n * When information about the partition's last enqueued event is being tracked, each event received\n * from the Event Hubs service will carry metadata about the partition that it otherwise would not. This results in a small amount of\n * additional network bandwidth consumption that is generally a favorable trade-off when considered\n * against periodically making requests for partition properties using the Event Hub client.\n */\n trackLastEnqueuedEventProperties?: boolean;\n /**\n * The owner level to use as this subscription subscribes to partitions.\n */\n ownerLevel?: number;\n /**\n * Options for configuring tracing.\n */\n tracingOptions?: OperationTracingOptions;\n /**\n * Option to disable the client from running JSON.parse() on the message body when receiving the message.\n * Not applicable if the message was sent with AMQP body type value or sequence. Use this option when you\n * prefer to work directly with the bytes present in the message body than have the client attempt to parse it.\n */\n skipParsingBodyAsJson?: boolean;\n /**\n * The count of events requested eagerly and queued without regard to whether a read was requested.\n */\n prefetchCount?: number;\n}\n\n/**\n * Interface that describes the object returned by the `subscribe()` method on the `EventHubConsumerClient`.\n */\nexport interface Subscription {\n /**\n * Stops the subscription from receiving more messages.\n *\n * If a checkpoint store has been configured this will also mark this subscription's\n * partitions as abandoned, freeing them up to be read by other consumers.\n *\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n close(): Promise<void>;\n /**\n * Indicates whether the receiver is running.\n * `true` - is running; `false` otherwise.\n * @readonly\n */\n isRunning: boolean;\n}\n"]}
@@ -0,0 +1,299 @@
1
+ import type { CreateBatchOptions, EventHubClientOptions, GetEventHubPropertiesOptions, GetPartitionIdsOptions, GetPartitionPropertiesOptions, SendBatchOptions } from "./models/public.js";
2
+ import type { EventDataBatch } from "./eventDataBatch.js";
3
+ import type { EventHubProperties, PartitionProperties } from "./managementClient.js";
4
+ import type { NamedKeyCredential, SASCredential, TokenCredential } from "@azure/core-auth";
5
+ import type { AmqpAnnotatedMessage } from "@azure/core-amqp";
6
+ import type { EventData } from "./eventData.js";
7
+ import type { OperationOptions } from "./util/operationOptions.js";
8
+ /**
9
+ * The `EventHubProducerClient` class is used to send events to an Event Hub.
10
+ *
11
+ * There are multiple ways to create an `EventHubProducerClient`
12
+ * - Use the connection string from the SAS policy created for your Event Hub instance.
13
+ * - Use the connection string from the SAS policy created for your Event Hub namespace,
14
+ * and the name of the Event Hub instance
15
+ * - Use the full namespace like `<yournamespace>.servicebus.windows.net`, and a credentials object.
16
+ *
17
+ * Optionally, you can also pass an options bag to configure the retry policy or proxy settings.
18
+ *
19
+ */
20
+ export declare class EventHubProducerClient {
21
+ /**
22
+ * Describes the amqp connection context for the client.
23
+ */
24
+ private _context;
25
+ /**
26
+ * The options passed by the user when creating the EventHubClient instance.
27
+ */
28
+ private _clientOptions;
29
+ /**
30
+ * Map of partitionId to senders
31
+ */
32
+ private _sendersMap;
33
+ /**
34
+ * Indicates whether or not the EventHubProducerClient should enable idempotent publishing to Event Hub partitions.
35
+ * If enabled, the producer will only be able to publish directly to partitions;
36
+ * it will not be able to publish to the Event Hubs gateway for automatic partition routing
37
+ * nor will it be able to use a partition key.
38
+ * Default: false
39
+ */
40
+ private _enableIdempotentRetries?;
41
+ /**
42
+ * The set of options that can be specified to influence publishing behavior specific to the configured Event Hub partition.
43
+ * These options are not necessary in the majority of scenarios and are intended for use with specialized scenarios,
44
+ * such as when recovering the state used for idempotent publishing.
45
+ */
46
+ private _partitionOptions?;
47
+ /**
48
+ * @readonly
49
+ * The name of the Event Hub instance for which this client is created.
50
+ */
51
+ get eventHubName(): string;
52
+ /**
53
+ * @readonly
54
+ * The fully qualified namespace of the Event Hub instance for which this client is created.
55
+ * This is likely to be similar to <yournamespace>.servicebus.windows.net.
56
+ */
57
+ get fullyQualifiedNamespace(): string;
58
+ /**
59
+ * The name used to identify this EventHubProducerClient.
60
+ * If not specified or empty, a random unique one will be generated.
61
+ */
62
+ readonly identifier: string;
63
+ /**
64
+ * The `EventHubProducerClient` class is used to send events to an Event Hub.
65
+ * Use the `options` parmeter to configure retry policy or proxy settings.
66
+ * @param connectionString - The connection string to use for connecting to the Event Hub instance.
67
+ * It is expected that the shared key properties and the Event Hub path are contained in this connection string.
68
+ * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.
69
+ * @param options - A set of options to apply when configuring the client.
70
+ * - `retryOptions` : Configures the retry policy for all the operations on the client.
71
+ * For example, `{ "maxRetries": 4 }` or `{ "maxRetries": 4, "retryDelayInMs": 30000 }`.
72
+ * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.
73
+ * - `userAgent` : A string to append to the built in user agent string that is passed to the service.
74
+ */
75
+ constructor(connectionString: string, options?: EventHubClientOptions);
76
+ /**
77
+ * The `EventHubProducerClient` class is used to send events to an Event Hub.
78
+ * Use the `options` parmeter to configure retry policy or proxy settings.
79
+ * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.
80
+ * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,
81
+ * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.
82
+ * @param eventHubName - The name of the specific Event Hub to connect the client to.
83
+ * @param options - A set of options to apply when configuring the client.
84
+ * - `retryOptions` : Configures the retry policy for all the operations on the client.
85
+ * For example, `{ "maxRetries": 4 }` or `{ "maxRetries": 4, "retryDelayInMs": 30000 }`.
86
+ * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.
87
+ * - `userAgent` : A string to append to the built in user agent string that is passed to the service.
88
+ */
89
+ constructor(connectionString: string, eventHubName: string, options?: EventHubClientOptions);
90
+ /**
91
+ * The `EventHubProducerClient` class is used to send events to an Event Hub.
92
+ * Use the `options` parmeter to configure retry policy or proxy settings.
93
+ * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to
94
+ * <yournamespace>.servicebus.windows.net
95
+ * @param eventHubName - The name of the specific Event Hub to connect the client to.
96
+ * @param credential - An credential object used by the client to get the token to authenticate the connection
97
+ * with the Azure Event Hubs service.
98
+ * See &commat;azure/identity for creating credentials that support AAD auth.
99
+ * Use the `AzureNamedKeyCredential` from &commat;azure/core-auth if you want to pass in a `SharedAccessKeyName`
100
+ * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively
101
+ * in `AzureNamedKeyCredential`.
102
+ * Use the `AzureSASCredential` from &commat;azure/core-auth if you want to pass in a `SharedAccessSignature`
103
+ * without using a connection string. This field maps to `signature` in `AzureSASCredential`.
104
+ * @param options - A set of options to apply when configuring the client.
105
+ * - `retryOptions` : Configures the retry policy for all the operations on the client.
106
+ * For example, `{ "maxRetries": 4 }` or `{ "maxRetries": 4, "retryDelayInMs": 30000 }`.
107
+ * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.
108
+ * - `userAgent` : A string to append to the built in user agent string that is passed to the service.
109
+ */
110
+ constructor(fullyQualifiedNamespace: string, eventHubName: string, credential: TokenCredential | NamedKeyCredential | SASCredential, options?: EventHubClientOptions);
111
+ /**
112
+ * Creates an instance of `EventDataBatch` to which one can add events until the maximum supported size is reached.
113
+ * The batch can be passed to the {@link sendBatch} method of the `EventHubProducerClient` to be sent to Azure Event Hubs.
114
+ *
115
+ * Events with different values for partitionKey or partitionId will need to be put into different batches.
116
+ * To simplify such batch management across partitions or to have the client automatically batch events
117
+ * and send them in specific intervals, use `EventHubBufferedProducerClient` instead.
118
+ *
119
+ * The below example assumes you have an array of events at hand to be batched safely.
120
+ * If you have events coming in one by one, `EventHubBufferedProducerClient` is recommended instead
121
+ * for effecient management of batches.
122
+ *
123
+ * Example usage:
124
+ * ```ts snippet:EventHubProducerClient_CreateBatch
125
+ * import { EventHubProducerClient } from "@azure/event-hubs";
126
+ *
127
+ * const client = new EventHubProducerClient("my-connection-string", "my-event-hub");
128
+ *
129
+ * const messages = [
130
+ * { body: "my-event-body1" },
131
+ * { body: "my-event-body2" },
132
+ * { body: "my-event-body3" },
133
+ * { body: "my-event-body4" },
134
+ * { body: "my-event-body5" },
135
+ * ];
136
+ *
137
+ * let batch = await client.createBatch();
138
+ * for (let i = 0; i < messages.length; i++) {
139
+ * if (!batch.tryAdd(messages[i])) {
140
+ * await client.sendBatch(batch);
141
+ * batch = await client.createBatch();
142
+ * if (!batch.tryAdd(messages[i])) {
143
+ * throw new Error("Message too big to fit");
144
+ * }
145
+ * if (i === messages.length - 1) {
146
+ * await client.sendBatch(batch);
147
+ * }
148
+ * }
149
+ * }
150
+ * ```
151
+ *
152
+ * @param options - Configures the behavior of the batch.
153
+ * - `partitionKey` : A value that is hashed and used by the Azure Event Hubs service to determine the partition to which
154
+ * the events need to be sent.
155
+ * - `partitionId` : Id of the partition to which the batch of events need to be sent.
156
+ * - `maxSizeInBytes`: The upper limit for the size of batch. The `tryAdd` function will return `false` after this limit is reached.
157
+ * - `abortSignal` : A signal the request to cancel the operation.
158
+ * @returns Promise<EventDataBatch>
159
+ * @throws Error if both `partitionId` and `partitionKey` are set in the options.
160
+ * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.
161
+ * @throws AbortError if the operation is cancelled via the abortSignal in the options.
162
+ */
163
+ createBatch(options?: CreateBatchOptions): Promise<EventDataBatch>;
164
+ /**
165
+ * Get the information about the state of publishing for a partition as observed by the `EventHubProducerClient`.
166
+ * This data can always be read, but will only be populated with information relevant to the active features
167
+ * for the producer client.
168
+ *
169
+ * @param partitionId - Id of the partition from which to retrieve publishing properties.
170
+ * @param options - The set of options to apply to the operation call.
171
+ * - `abortSignal` : A signal the request to cancel the send operation.
172
+ * @returns Promise<void>
173
+ * @throws AbortError if the operation is cancelled via the abortSignal.
174
+ */
175
+ private getPartitionPublishingProperties;
176
+ /**
177
+ * Sends an array of events as a batch to the associated Event Hub.
178
+ *
179
+ * Azure Event Hubs has a limit on the size of the batch that can be sent which if exceeded
180
+ * will result in an error with code `MessageTooLargeError`.
181
+ * To safely send within batch size limits, use `EventHubProducerClient.createBatch()` or
182
+ * `EventHubBufferedProducerClient` instead.
183
+ *
184
+ * Example usage:
185
+ * ```ts snippet:EventHubProducerClient_SendBatch
186
+ * import { EventHubProducerClient } from "@azure/event-hubs";
187
+ *
188
+ * const client = new EventHubProducerClient("my-connection-string", "my-event-hub");
189
+ *
190
+ * const messages = [
191
+ * { body: "my-event-body1" },
192
+ * { body: "my-event-body2" },
193
+ * { body: "my-event-body3" },
194
+ * { body: "my-event-body4" },
195
+ * { body: "my-event-body5" },
196
+ * ];
197
+ *
198
+ * await client.sendBatch(messages);
199
+ * ```
200
+ *
201
+ * @param batch - An array of {@link EventData} or `AmqpAnnotatedMessage`.
202
+ * @param options - A set of options that can be specified to influence the way in which
203
+ * events are sent to the associated Event Hub.
204
+ * - `abortSignal` : A signal the request to cancel the send operation.
205
+ * - `partitionId` : The partition this batch will be sent to. If set, `partitionKey` can not be set.
206
+ * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.
207
+ *
208
+ * @returns Promise<void>
209
+ * @throws MessageTooLargeError if all the events in the input array cannot be fit into a batch.
210
+ * @throws AbortError if the operation is cancelled via the abortSignal.
211
+ * @throws MessagingError if an error is encountered while sending a message.
212
+ * @throws Error if the underlying connection or sender has been closed.
213
+ */
214
+ sendBatch(batch: EventData[] | AmqpAnnotatedMessage[], options?: SendBatchOptions): Promise<void>;
215
+ /**
216
+ * Sends a batch of events created using `EventHubProducerClient.createBatch()` to the associated Event Hub.
217
+ *
218
+ * Events with different values for partitionKey or partitionId will need to be put into different batches.
219
+ * To simplify such batch management across partitions or to have the client automatically batch events
220
+ * and send them in specific intervals, use `EventHubBufferedProducerClient` instead.
221
+ *
222
+ * The below example assumes you have an array of events at hand to be batched safely.
223
+ * If you have events coming in one by one, `EventHubBufferedProducerClient` is recommended instead
224
+ * for effecient management of batches.
225
+ *
226
+ * Example usage:
227
+ * ```ts snippet:EventHubProducerClient_SendBatchPartitioned
228
+ * import { EventHubProducerClient } from "@azure/event-hubs";
229
+ *
230
+ * const client = new EventHubProducerClient("my-connection-string", "my-event-hub");
231
+ *
232
+ * const messages = [
233
+ * { body: "my-event-body1" },
234
+ * { body: "my-event-body2" },
235
+ * { body: "my-event-body3" },
236
+ * { body: "my-event-body4" },
237
+ * { body: "my-event-body5" },
238
+ * ];
239
+ *
240
+ * let batch = await client.createBatch();
241
+ * for (let i = 0; i < messages.length; i++) {
242
+ * if (!batch.tryAdd(messages[i])) {
243
+ * await client.sendBatch(batch);
244
+ * batch = await client.createBatch();
245
+ * if (!batch.tryAdd(messages[i])) {
246
+ * throw new Error("Message too big to fit");
247
+ * }
248
+ * if (i === messages.length - 1) {
249
+ * await client.sendBatch(batch);
250
+ * }
251
+ * }
252
+ * }
253
+ * ```
254
+ * @param batch - A batch of events that you can create using the {@link createBatch} method.
255
+ * @param options - A set of options that can be specified to influence the way in which
256
+ * events are sent to the associated Event Hub.
257
+ * - `abortSignal` : A signal the request to cancel the send operation.
258
+ *
259
+ * @returns Promise<void>
260
+ * @throws AbortError if the operation is cancelled via the abortSignal.
261
+ * @throws MessagingError if an error is encountered while sending a message.
262
+ * @throws Error if the underlying connection or sender has been closed.
263
+ */
264
+ sendBatch(batch: EventDataBatch, options?: OperationOptions): Promise<void>;
265
+ /**
266
+ * Closes the AMQP connection to the Event Hub instance,
267
+ * returning a promise that will be resolved when disconnection is completed.
268
+ * @returns Promise<void>
269
+ * @throws Error if the underlying connection encounters an error while closing.
270
+ */
271
+ close(): Promise<void>;
272
+ /**
273
+ * Provides the Event Hub runtime information.
274
+ * @param options - The set of options to apply to the operation call.
275
+ * @returns A promise that resolves with information about the Event Hub instance.
276
+ * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.
277
+ * @throws AbortError if the operation is cancelled via the abortSignal.
278
+ */
279
+ getEventHubProperties(options?: GetEventHubPropertiesOptions): Promise<EventHubProperties>;
280
+ /**
281
+ * Provides the id for each partition associated with the Event Hub.
282
+ * @param options - The set of options to apply to the operation call.
283
+ * @returns A promise that resolves with an Array of strings representing the id for
284
+ * each partition associated with the Event Hub.
285
+ * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.
286
+ * @throws AbortError if the operation is cancelled via the abortSignal.
287
+ */
288
+ getPartitionIds(options?: GetPartitionIdsOptions): Promise<Array<string>>;
289
+ /**
290
+ * Provides information about the state of the specified partition.
291
+ * @param partitionId - The id of the partition for which information is required.
292
+ * @param options - The set of options to apply to the operation call.
293
+ * @returns A promise that resolves with information about the state of the partition .
294
+ * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.
295
+ * @throws AbortError if the operation is cancelled via the abortSignal.
296
+ */
297
+ getPartitionProperties(partitionId: string, options?: GetPartitionPropertiesOptions): Promise<PartitionProperties>;
298
+ }
299
+ //# sourceMappingURL=eventHubProducerClient.d.ts.map