@azure/event-hubs 5.13.0-beta.2 → 6.0.0-alpha.20250128.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (616) hide show
  1. package/README.md +32 -31
  2. package/dist/browser/batchingPartitionChannel.d.ts +94 -0
  3. package/dist/browser/batchingPartitionChannel.d.ts.map +1 -0
  4. package/{dist-esm/src → dist/browser}/batchingPartitionChannel.js +4 -4
  5. package/dist/browser/batchingPartitionChannel.js.map +1 -0
  6. package/dist/browser/connectionContext.d.ts +108 -0
  7. package/dist/browser/connectionContext.d.ts.map +1 -0
  8. package/{dist-esm/src → dist/browser}/connectionContext.js +9 -11
  9. package/dist/browser/connectionContext.js.map +1 -0
  10. package/dist/browser/dataTransformer.d.ts +53 -0
  11. package/dist/browser/dataTransformer.d.ts.map +1 -0
  12. package/{dist-esm/src → dist/browser}/dataTransformer.js +2 -2
  13. package/dist/browser/dataTransformer.js.map +1 -0
  14. package/dist/browser/diagnostics/instrumentEventData.d.ts +28 -0
  15. package/dist/browser/diagnostics/instrumentEventData.d.ts.map +1 -0
  16. package/{dist-esm/src → dist/browser}/diagnostics/instrumentEventData.js +3 -3
  17. package/dist/browser/diagnostics/instrumentEventData.js.map +1 -0
  18. package/dist/browser/diagnostics/tracing.d.ts +19 -0
  19. package/dist/browser/diagnostics/tracing.d.ts.map +1 -0
  20. package/{dist-esm/src → dist/browser}/diagnostics/tracing.js +2 -2
  21. package/dist/browser/diagnostics/tracing.js.map +1 -0
  22. package/dist/browser/eventData.d.ts +295 -0
  23. package/dist/browser/eventData.d.ts.map +1 -0
  24. package/{dist-esm/src → dist/browser}/eventData.js +39 -5
  25. package/dist/browser/eventData.js.map +1 -0
  26. package/dist/browser/eventDataAdapter.d.ts +69 -0
  27. package/dist/browser/eventDataAdapter.d.ts.map +1 -0
  28. package/{dist-esm/src → dist/browser}/eventDataAdapter.js +1 -1
  29. package/dist/browser/eventDataAdapter.js.map +1 -0
  30. package/dist/browser/eventDataBatch.d.ts +225 -0
  31. package/dist/browser/eventDataBatch.d.ts.map +1 -0
  32. package/{dist-esm/src → dist/browser}/eventDataBatch.js +7 -4
  33. package/dist/browser/eventDataBatch.js.map +1 -0
  34. package/dist/browser/eventHubBufferedProducerClient.d.ts +323 -0
  35. package/dist/browser/eventHubBufferedProducerClient.d.ts.map +1 -0
  36. package/{dist-esm/src → dist/browser}/eventHubBufferedProducerClient.js +10 -9
  37. package/dist/browser/eventHubBufferedProducerClient.js.map +1 -0
  38. package/dist/browser/eventHubConsumerClient.d.ts +277 -0
  39. package/dist/browser/eventHubConsumerClient.d.ts.map +1 -0
  40. package/{dist-esm/src → dist/browser}/eventHubConsumerClient.js +12 -12
  41. package/dist/browser/eventHubConsumerClient.js.map +1 -0
  42. package/dist/browser/eventHubConsumerClientModels.d.ts +218 -0
  43. package/dist/browser/eventHubConsumerClientModels.d.ts.map +1 -0
  44. package/dist/browser/eventHubConsumerClientModels.js +4 -0
  45. package/dist/browser/eventHubConsumerClientModels.js.map +1 -0
  46. package/dist/browser/eventHubProducerClient.d.ts +266 -0
  47. package/dist/browser/eventHubProducerClient.d.ts.map +1 -0
  48. package/{dist-esm/src → dist/browser}/eventHubProducerClient.js +12 -10
  49. package/dist/browser/eventHubProducerClient.js.map +1 -0
  50. package/dist/browser/eventHubSender.d.ts +227 -0
  51. package/dist/browser/eventHubSender.d.ts.map +1 -0
  52. package/{dist-esm/src → dist/browser}/eventHubSender.js +12 -12
  53. package/dist/browser/eventHubSender.js.map +1 -0
  54. package/dist/browser/eventPosition.d.ts +73 -0
  55. package/dist/browser/eventPosition.d.ts.map +1 -0
  56. package/{dist-esm/src → dist/browser}/eventPosition.js +2 -2
  57. package/dist/browser/eventPosition.js.map +1 -0
  58. package/dist/browser/eventProcessor.d.ts +232 -0
  59. package/dist/browser/eventProcessor.d.ts.map +1 -0
  60. package/{dist-esm/src → dist/browser}/eventProcessor.js +18 -18
  61. package/dist/browser/eventProcessor.js.map +1 -0
  62. package/dist/browser/eventhubConnectionConfig.d.ts +96 -0
  63. package/dist/browser/eventhubConnectionConfig.d.ts.map +1 -0
  64. package/{dist-esm/src → dist/browser}/eventhubConnectionConfig.js +2 -2
  65. package/dist/browser/eventhubConnectionConfig.js.map +1 -0
  66. package/dist/browser/impl/awaitableQueue.d.ts +25 -0
  67. package/dist/browser/impl/awaitableQueue.d.ts.map +1 -0
  68. package/{dist-esm/src → dist/browser}/impl/awaitableQueue.js +1 -1
  69. package/dist/browser/impl/awaitableQueue.js.map +1 -0
  70. package/dist/browser/impl/partitionAssigner.d.ts +29 -0
  71. package/dist/browser/impl/partitionAssigner.d.ts.map +1 -0
  72. package/{dist-esm/src → dist/browser}/impl/partitionAssigner.js +2 -2
  73. package/dist/browser/impl/partitionAssigner.js.map +1 -0
  74. package/dist/browser/impl/partitionGate.d.ts +27 -0
  75. package/dist/browser/impl/partitionGate.d.ts.map +1 -0
  76. package/{dist-esm/src → dist/browser}/impl/partitionGate.js +1 -1
  77. package/{dist-esm/src → dist/browser}/impl/partitionGate.js.map +1 -1
  78. package/dist/browser/impl/partitionKeyToIdMapper.d.ts +6 -0
  79. package/dist/browser/impl/partitionKeyToIdMapper.d.ts.map +1 -0
  80. package/{dist-esm/src → dist/browser}/impl/partitionKeyToIdMapper.js +1 -1
  81. package/{dist-esm/src → dist/browser}/impl/partitionKeyToIdMapper.js.map +1 -1
  82. package/dist/browser/inMemoryCheckpointStore.d.ts +44 -0
  83. package/dist/browser/inMemoryCheckpointStore.d.ts.map +1 -0
  84. package/{dist-esm/src → dist/browser}/inMemoryCheckpointStore.js +3 -3
  85. package/dist/browser/inMemoryCheckpointStore.js.map +1 -0
  86. package/dist/browser/index.d.ts +21 -0
  87. package/dist/browser/index.d.ts.map +1 -0
  88. package/{dist-esm/src → dist/browser}/index.js +9 -9
  89. package/dist/browser/index.js.map +1 -0
  90. package/dist/browser/loadBalancerStrategies/balancedStrategy.d.ts +30 -0
  91. package/dist/browser/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -0
  92. package/{dist-esm/src → dist/browser}/loadBalancerStrategies/balancedStrategy.js +2 -2
  93. package/dist/browser/loadBalancerStrategies/balancedStrategy.js.map +1 -0
  94. package/dist/browser/loadBalancerStrategies/greedyStrategy.d.ts +24 -0
  95. package/dist/browser/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -0
  96. package/{dist-esm/src → dist/browser}/loadBalancerStrategies/greedyStrategy.js +2 -2
  97. package/dist/browser/loadBalancerStrategies/greedyStrategy.js.map +1 -0
  98. package/dist/browser/loadBalancerStrategies/loadBalancingStrategy.d.ts +28 -0
  99. package/dist/browser/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -0
  100. package/{dist-esm/src → dist/browser}/loadBalancerStrategies/loadBalancingStrategy.js +2 -2
  101. package/dist/browser/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -0
  102. package/dist/browser/loadBalancerStrategies/unbalancedStrategy.d.ts +20 -0
  103. package/dist/browser/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -0
  104. package/{dist-esm/src → dist/browser}/loadBalancerStrategies/unbalancedStrategy.js +1 -1
  105. package/dist/browser/loadBalancerStrategies/unbalancedStrategy.js.map +1 -0
  106. package/dist/browser/logger.d.ts +37 -0
  107. package/dist/browser/logger.d.ts.map +1 -0
  108. package/{dist-esm/src → dist/browser}/logger.js +1 -1
  109. package/dist/browser/logger.js.map +1 -0
  110. package/dist/browser/managementClient.d.ts +145 -0
  111. package/dist/browser/managementClient.d.ts.map +1 -0
  112. package/{dist-esm/src → dist/browser}/managementClient.js +8 -8
  113. package/dist/browser/managementClient.js.map +1 -0
  114. package/dist/browser/models/private.d.ts +185 -0
  115. package/dist/browser/models/private.d.ts.map +1 -0
  116. package/dist/browser/models/private.js +4 -0
  117. package/dist/browser/models/private.js.map +1 -0
  118. package/dist/browser/models/public.d.ts +240 -0
  119. package/dist/browser/models/public.d.ts.map +1 -0
  120. package/{dist-esm/src → dist/browser}/models/public.js +1 -1
  121. package/dist/browser/models/public.js.map +1 -0
  122. package/dist/browser/package.json +3 -0
  123. package/dist/browser/partitionProcessor.d.ts +134 -0
  124. package/dist/browser/partitionProcessor.d.ts.map +1 -0
  125. package/{dist-esm/src → dist/browser}/partitionProcessor.js +2 -2
  126. package/dist/browser/partitionProcessor.js.map +1 -0
  127. package/dist/browser/partitionPump.d.ts +38 -0
  128. package/dist/browser/partitionPump.d.ts.map +1 -0
  129. package/{dist-esm/src → dist/browser}/partitionPump.js +6 -7
  130. package/dist/browser/partitionPump.js.map +1 -0
  131. package/dist/browser/partitionReceiver.d.ts +82 -0
  132. package/dist/browser/partitionReceiver.d.ts.map +1 -0
  133. package/{dist-esm/src → dist/browser}/partitionReceiver.js +14 -12
  134. package/dist/browser/partitionReceiver.js.map +1 -0
  135. package/dist/browser/pumpManager.d.ts +72 -0
  136. package/dist/browser/pumpManager.d.ts.map +1 -0
  137. package/{dist-esm/src → dist/browser}/pumpManager.js +4 -4
  138. package/dist/browser/pumpManager.js.map +1 -0
  139. package/dist/browser/util/connectionStringUtils.d.ts +52 -0
  140. package/dist/browser/util/connectionStringUtils.d.ts.map +1 -0
  141. package/{dist-esm/src → dist/browser}/util/connectionStringUtils.js +1 -1
  142. package/{dist-esm/src → dist/browser}/util/connectionStringUtils.js.map +1 -1
  143. package/dist/browser/util/constants.d.ts +25 -0
  144. package/dist/browser/util/constants.d.ts.map +1 -0
  145. package/{dist-esm/src → dist/browser}/util/constants.js +4 -2
  146. package/dist/browser/util/constants.js.map +1 -0
  147. package/dist/browser/util/delayWithoutThrow.d.ts +8 -0
  148. package/dist/browser/util/delayWithoutThrow.d.ts.map +1 -0
  149. package/{dist-esm/src → dist/browser}/util/delayWithoutThrow.js +1 -1
  150. package/dist/browser/util/delayWithoutThrow.js.map +1 -0
  151. package/dist/browser/util/error.d.ts +39 -0
  152. package/dist/browser/util/error.d.ts.map +1 -0
  153. package/{dist-esm/src → dist/browser}/util/error.js +2 -2
  154. package/dist/browser/util/error.js.map +1 -0
  155. package/dist/browser/util/getPromiseParts.d.ts +10 -0
  156. package/dist/browser/util/getPromiseParts.d.ts.map +1 -0
  157. package/{dist-esm/src → dist/browser}/util/getPromiseParts.js +1 -1
  158. package/{dist-esm/src → dist/browser}/util/getPromiseParts.js.map +1 -1
  159. package/dist/browser/util/operationOptions.d.ts +16 -0
  160. package/dist/browser/util/operationOptions.d.ts.map +1 -0
  161. package/dist/browser/util/operationOptions.js +4 -0
  162. package/dist/browser/util/operationOptions.js.map +1 -0
  163. package/dist/browser/util/parseEndpoint.d.ts +11 -0
  164. package/dist/browser/util/parseEndpoint.d.ts.map +1 -0
  165. package/{dist-esm/src → dist/browser}/util/parseEndpoint.js +1 -1
  166. package/{dist-esm/src → dist/browser}/util/parseEndpoint.js.map +1 -1
  167. package/dist/browser/util/retries.d.ts +6 -0
  168. package/dist/browser/util/retries.d.ts.map +1 -0
  169. package/{dist-esm/src → dist/browser}/util/retries.js +1 -1
  170. package/dist/browser/util/retries.js.map +1 -0
  171. package/dist/browser/util/runtimeInfo-browser.d.mts.map +1 -0
  172. package/dist/browser/util/runtimeInfo-browser.mjs.map +1 -0
  173. package/dist/browser/util/runtimeInfo.d.ts +6 -0
  174. package/{dist-esm/src/util/runtimeInfo.browser.js → dist/browser/util/runtimeInfo.js} +2 -2
  175. package/dist/browser/util/timerLoop.d.ts +26 -0
  176. package/dist/browser/util/timerLoop.d.ts.map +1 -0
  177. package/{dist-esm/src → dist/browser}/util/timerLoop.js +1 -1
  178. package/{dist-esm/src → dist/browser}/util/timerLoop.js.map +1 -1
  179. package/dist/browser/util/typeGuards.d.ts +8 -0
  180. package/dist/browser/util/typeGuards.d.ts.map +1 -0
  181. package/{dist-esm/src → dist/browser}/util/typeGuards.js +2 -2
  182. package/dist/browser/util/typeGuards.js.map +1 -0
  183. package/dist/browser/util/utils.d.ts +7 -0
  184. package/dist/browser/util/utils.d.ts.map +1 -0
  185. package/{dist-esm/src → dist/browser}/util/utils.js +1 -1
  186. package/{dist-esm/src → dist/browser}/util/utils.js.map +1 -1
  187. package/dist/browser/withAuth.d.ts +25 -0
  188. package/dist/browser/withAuth.d.ts.map +1 -0
  189. package/{dist-esm/src → dist/browser}/withAuth.js +4 -4
  190. package/dist/browser/withAuth.js.map +1 -0
  191. package/dist/commonjs/batchingPartitionChannel.d.ts +94 -0
  192. package/dist/commonjs/batchingPartitionChannel.d.ts.map +1 -0
  193. package/dist/commonjs/batchingPartitionChannel.js +252 -0
  194. package/dist/commonjs/batchingPartitionChannel.js.map +1 -0
  195. package/dist/commonjs/connectionContext.d.ts +108 -0
  196. package/dist/commonjs/connectionContext.d.ts.map +1 -0
  197. package/dist/commonjs/connectionContext.js +322 -0
  198. package/dist/commonjs/connectionContext.js.map +1 -0
  199. package/dist/commonjs/dataTransformer.d.ts +53 -0
  200. package/dist/commonjs/dataTransformer.d.ts.map +1 -0
  201. package/dist/commonjs/dataTransformer.js +138 -0
  202. package/dist/commonjs/dataTransformer.js.map +1 -0
  203. package/dist/commonjs/diagnostics/instrumentEventData.d.ts +28 -0
  204. package/dist/commonjs/diagnostics/instrumentEventData.d.ts.map +1 -0
  205. package/dist/commonjs/diagnostics/instrumentEventData.js +73 -0
  206. package/dist/commonjs/diagnostics/instrumentEventData.js.map +1 -0
  207. package/dist/commonjs/diagnostics/tracing.d.ts +19 -0
  208. package/dist/commonjs/diagnostics/tracing.d.ts.map +1 -0
  209. package/dist/commonjs/diagnostics/tracing.js +44 -0
  210. package/dist/commonjs/diagnostics/tracing.js.map +1 -0
  211. package/dist/commonjs/eventData.d.ts +295 -0
  212. package/dist/commonjs/eventData.d.ts.map +1 -0
  213. package/dist/commonjs/eventData.js +253 -0
  214. package/dist/commonjs/eventData.js.map +1 -0
  215. package/dist/commonjs/eventDataAdapter.d.ts +69 -0
  216. package/dist/commonjs/eventDataAdapter.d.ts.map +1 -0
  217. package/dist/commonjs/eventDataAdapter.js +38 -0
  218. package/dist/commonjs/eventDataAdapter.js.map +1 -0
  219. package/dist/commonjs/eventDataBatch.d.ts +225 -0
  220. package/dist/commonjs/eventDataBatch.d.ts.map +1 -0
  221. package/dist/commonjs/eventDataBatch.js +254 -0
  222. package/dist/commonjs/eventDataBatch.js.map +1 -0
  223. package/dist/commonjs/eventHubBufferedProducerClient.d.ts +323 -0
  224. package/dist/commonjs/eventHubBufferedProducerClient.d.ts.map +1 -0
  225. package/dist/commonjs/eventHubBufferedProducerClient.js +289 -0
  226. package/dist/commonjs/eventHubBufferedProducerClient.js.map +1 -0
  227. package/dist/commonjs/eventHubConsumerClient.d.ts +277 -0
  228. package/dist/commonjs/eventHubConsumerClient.d.ts.map +1 -0
  229. package/dist/commonjs/eventHubConsumerClient.js +298 -0
  230. package/dist/commonjs/eventHubConsumerClient.js.map +1 -0
  231. package/dist/commonjs/eventHubConsumerClientModels.d.ts +218 -0
  232. package/dist/commonjs/eventHubConsumerClientModels.d.ts.map +1 -0
  233. package/dist/commonjs/eventHubConsumerClientModels.js +5 -0
  234. package/dist/commonjs/eventHubConsumerClientModels.js.map +1 -0
  235. package/dist/commonjs/eventHubProducerClient.d.ts +266 -0
  236. package/dist/commonjs/eventHubProducerClient.d.ts.map +1 -0
  237. package/dist/commonjs/eventHubProducerClient.js +319 -0
  238. package/dist/commonjs/eventHubProducerClient.js.map +1 -0
  239. package/dist/commonjs/eventHubSender.d.ts +227 -0
  240. package/dist/commonjs/eventHubSender.d.ts.map +1 -0
  241. package/dist/commonjs/eventHubSender.js +547 -0
  242. package/dist/commonjs/eventHubSender.js.map +1 -0
  243. package/dist/commonjs/eventPosition.d.ts +73 -0
  244. package/dist/commonjs/eventPosition.d.ts.map +1 -0
  245. package/dist/commonjs/eventPosition.js +128 -0
  246. package/dist/commonjs/eventPosition.js.map +1 -0
  247. package/dist/commonjs/eventProcessor.d.ts +232 -0
  248. package/dist/commonjs/eventProcessor.d.ts.map +1 -0
  249. package/dist/commonjs/eventProcessor.js +371 -0
  250. package/dist/commonjs/eventProcessor.js.map +1 -0
  251. package/dist/commonjs/eventhubConnectionConfig.d.ts +96 -0
  252. package/dist/commonjs/eventhubConnectionConfig.d.ts.map +1 -0
  253. package/dist/commonjs/eventhubConnectionConfig.js +101 -0
  254. package/dist/commonjs/eventhubConnectionConfig.js.map +1 -0
  255. package/dist/commonjs/impl/awaitableQueue.d.ts +25 -0
  256. package/dist/commonjs/impl/awaitableQueue.d.ts.map +1 -0
  257. package/dist/commonjs/impl/awaitableQueue.js +51 -0
  258. package/dist/commonjs/impl/awaitableQueue.js.map +1 -0
  259. package/dist/commonjs/impl/partitionAssigner.d.ts +29 -0
  260. package/dist/commonjs/impl/partitionAssigner.d.ts.map +1 -0
  261. package/dist/commonjs/impl/partitionAssigner.js +58 -0
  262. package/dist/commonjs/impl/partitionAssigner.js.map +1 -0
  263. package/dist/commonjs/impl/partitionGate.d.ts +27 -0
  264. package/dist/commonjs/impl/partitionGate.d.ts.map +1 -0
  265. package/dist/commonjs/impl/partitionGate.js +44 -0
  266. package/dist/commonjs/impl/partitionGate.js.map +1 -0
  267. package/dist/commonjs/impl/partitionKeyToIdMapper.d.ts +6 -0
  268. package/dist/commonjs/impl/partitionKeyToIdMapper.d.ts.map +1 -0
  269. package/dist/commonjs/impl/partitionKeyToIdMapper.js +115 -0
  270. package/dist/commonjs/impl/partitionKeyToIdMapper.js.map +1 -0
  271. package/dist/commonjs/inMemoryCheckpointStore.d.ts +44 -0
  272. package/dist/commonjs/inMemoryCheckpointStore.d.ts.map +1 -0
  273. package/dist/commonjs/inMemoryCheckpointStore.js +96 -0
  274. package/dist/commonjs/inMemoryCheckpointStore.js.map +1 -0
  275. package/dist/commonjs/index.d.ts +21 -0
  276. package/dist/commonjs/index.d.ts.map +1 -0
  277. package/dist/commonjs/index.js +26 -0
  278. package/dist/commonjs/index.js.map +1 -0
  279. package/dist/commonjs/loadBalancerStrategies/balancedStrategy.d.ts +30 -0
  280. package/dist/commonjs/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -0
  281. package/dist/commonjs/loadBalancerStrategies/balancedStrategy.js +43 -0
  282. package/dist/commonjs/loadBalancerStrategies/balancedStrategy.js.map +1 -0
  283. package/dist/commonjs/loadBalancerStrategies/greedyStrategy.d.ts +24 -0
  284. package/dist/commonjs/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -0
  285. package/dist/commonjs/loadBalancerStrategies/greedyStrategy.js +32 -0
  286. package/dist/commonjs/loadBalancerStrategies/greedyStrategy.js.map +1 -0
  287. package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.d.ts +28 -0
  288. package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -0
  289. package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.js +248 -0
  290. package/dist/commonjs/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -0
  291. package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.d.ts +20 -0
  292. package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -0
  293. package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.js +26 -0
  294. package/dist/commonjs/loadBalancerStrategies/unbalancedStrategy.js.map +1 -0
  295. package/dist/commonjs/logger.d.ts +37 -0
  296. package/dist/commonjs/logger.d.ts.map +1 -0
  297. package/dist/commonjs/logger.js +65 -0
  298. package/dist/commonjs/logger.js.map +1 -0
  299. package/dist/commonjs/managementClient.d.ts +145 -0
  300. package/dist/commonjs/managementClient.d.ts.map +1 -0
  301. package/dist/commonjs/managementClient.js +275 -0
  302. package/dist/commonjs/managementClient.js.map +1 -0
  303. package/dist/commonjs/models/private.d.ts +185 -0
  304. package/dist/commonjs/models/private.d.ts.map +1 -0
  305. package/dist/commonjs/models/private.js +5 -0
  306. package/dist/commonjs/models/private.js.map +1 -0
  307. package/dist/commonjs/models/public.d.ts +240 -0
  308. package/dist/commonjs/models/public.d.ts.map +1 -0
  309. package/dist/commonjs/models/public.js +21 -0
  310. package/dist/commonjs/models/public.js.map +1 -0
  311. package/dist/commonjs/package.json +3 -0
  312. package/dist/commonjs/partitionProcessor.d.ts +134 -0
  313. package/dist/commonjs/partitionProcessor.d.ts.map +1 -0
  314. package/dist/commonjs/partitionProcessor.js +138 -0
  315. package/dist/commonjs/partitionProcessor.js.map +1 -0
  316. package/dist/commonjs/partitionPump.d.ts +38 -0
  317. package/dist/commonjs/partitionPump.d.ts.map +1 -0
  318. package/dist/commonjs/partitionPump.js +171 -0
  319. package/dist/commonjs/partitionPump.js.map +1 -0
  320. package/dist/commonjs/partitionReceiver.d.ts +82 -0
  321. package/dist/commonjs/partitionReceiver.d.ts.map +1 -0
  322. package/dist/commonjs/partitionReceiver.js +335 -0
  323. package/dist/commonjs/partitionReceiver.js.map +1 -0
  324. package/dist/commonjs/pumpManager.d.ts +72 -0
  325. package/dist/commonjs/pumpManager.d.ts.map +1 -0
  326. package/dist/commonjs/pumpManager.js +122 -0
  327. package/dist/commonjs/pumpManager.js.map +1 -0
  328. package/{types/latest → dist/commonjs}/tsdoc-metadata.json +1 -1
  329. package/dist/commonjs/util/connectionStringUtils.d.ts +52 -0
  330. package/dist/commonjs/util/connectionStringUtils.d.ts.map +1 -0
  331. package/dist/commonjs/util/connectionStringUtils.js +51 -0
  332. package/dist/commonjs/util/connectionStringUtils.js.map +1 -0
  333. package/dist/commonjs/util/constants.d.ts +25 -0
  334. package/dist/commonjs/util/constants.d.ts.map +1 -0
  335. package/dist/commonjs/util/constants.js +30 -0
  336. package/dist/commonjs/util/constants.js.map +1 -0
  337. package/dist/commonjs/util/delayWithoutThrow.d.ts +8 -0
  338. package/dist/commonjs/util/delayWithoutThrow.d.ts.map +1 -0
  339. package/dist/commonjs/util/delayWithoutThrow.js +20 -0
  340. package/dist/commonjs/util/delayWithoutThrow.js.map +1 -0
  341. package/dist/commonjs/util/error.d.ts +39 -0
  342. package/dist/commonjs/util/error.d.ts.map +1 -0
  343. package/dist/commonjs/util/error.js +110 -0
  344. package/dist/commonjs/util/error.js.map +1 -0
  345. package/dist/commonjs/util/getPromiseParts.d.ts +10 -0
  346. package/dist/commonjs/util/getPromiseParts.d.ts.map +1 -0
  347. package/dist/commonjs/util/getPromiseParts.js +23 -0
  348. package/dist/commonjs/util/getPromiseParts.js.map +1 -0
  349. package/dist/commonjs/util/operationOptions.d.ts +16 -0
  350. package/dist/commonjs/util/operationOptions.d.ts.map +1 -0
  351. package/dist/commonjs/util/operationOptions.js +5 -0
  352. package/dist/commonjs/util/operationOptions.js.map +1 -0
  353. package/dist/commonjs/util/parseEndpoint.d.ts +11 -0
  354. package/dist/commonjs/util/parseEndpoint.d.ts.map +1 -0
  355. package/dist/commonjs/util/parseEndpoint.js +20 -0
  356. package/dist/commonjs/util/parseEndpoint.js.map +1 -0
  357. package/dist/commonjs/util/retries.d.ts +6 -0
  358. package/dist/commonjs/util/retries.d.ts.map +1 -0
  359. package/dist/commonjs/util/retries.js +16 -0
  360. package/dist/commonjs/util/retries.js.map +1 -0
  361. package/dist/commonjs/util/runtimeInfo.d.ts +6 -0
  362. package/dist/commonjs/util/runtimeInfo.d.ts.map +1 -0
  363. package/dist/commonjs/util/runtimeInfo.js +15 -0
  364. package/dist/commonjs/util/runtimeInfo.js.map +1 -0
  365. package/dist/commonjs/util/timerLoop.d.ts +26 -0
  366. package/dist/commonjs/util/timerLoop.d.ts.map +1 -0
  367. package/dist/commonjs/util/timerLoop.js +30 -0
  368. package/dist/commonjs/util/timerLoop.js.map +1 -0
  369. package/dist/commonjs/util/typeGuards.d.ts +8 -0
  370. package/dist/commonjs/util/typeGuards.d.ts.map +1 -0
  371. package/dist/commonjs/util/typeGuards.js +15 -0
  372. package/dist/commonjs/util/typeGuards.js.map +1 -0
  373. package/dist/commonjs/util/utils.d.ts +7 -0
  374. package/dist/commonjs/util/utils.d.ts.map +1 -0
  375. package/dist/commonjs/util/utils.js +16 -0
  376. package/dist/commonjs/util/utils.js.map +1 -0
  377. package/dist/commonjs/withAuth.d.ts +25 -0
  378. package/dist/commonjs/withAuth.d.ts.map +1 -0
  379. package/dist/commonjs/withAuth.js +88 -0
  380. package/dist/commonjs/withAuth.js.map +1 -0
  381. package/dist/esm/batchingPartitionChannel.d.ts +94 -0
  382. package/dist/esm/batchingPartitionChannel.d.ts.map +1 -0
  383. package/dist/esm/batchingPartitionChannel.js +248 -0
  384. package/dist/esm/batchingPartitionChannel.js.map +1 -0
  385. package/dist/esm/connectionContext.d.ts +108 -0
  386. package/dist/esm/connectionContext.d.ts.map +1 -0
  387. package/dist/esm/connectionContext.js +318 -0
  388. package/dist/esm/connectionContext.js.map +1 -0
  389. package/dist/esm/dataTransformer.d.ts +53 -0
  390. package/dist/esm/dataTransformer.d.ts.map +1 -0
  391. package/dist/esm/dataTransformer.js +133 -0
  392. package/dist/esm/dataTransformer.js.map +1 -0
  393. package/dist/esm/diagnostics/instrumentEventData.d.ts +28 -0
  394. package/dist/esm/diagnostics/instrumentEventData.d.ts.map +1 -0
  395. package/dist/esm/diagnostics/instrumentEventData.js +68 -0
  396. package/dist/esm/diagnostics/instrumentEventData.js.map +1 -0
  397. package/dist/esm/diagnostics/tracing.d.ts +19 -0
  398. package/dist/esm/diagnostics/tracing.d.ts.map +1 -0
  399. package/dist/esm/diagnostics/tracing.js +40 -0
  400. package/dist/esm/diagnostics/tracing.js.map +1 -0
  401. package/dist/esm/eventData.d.ts +295 -0
  402. package/dist/esm/eventData.d.ts.map +1 -0
  403. package/dist/esm/eventData.js +245 -0
  404. package/dist/esm/eventData.js.map +1 -0
  405. package/dist/esm/eventDataAdapter.d.ts +69 -0
  406. package/dist/esm/eventDataAdapter.d.ts.map +1 -0
  407. package/dist/esm/eventDataAdapter.js +35 -0
  408. package/dist/esm/eventDataAdapter.js.map +1 -0
  409. package/dist/esm/eventDataBatch.d.ts +225 -0
  410. package/dist/esm/eventDataBatch.d.ts.map +1 -0
  411. package/dist/esm/eventDataBatch.js +249 -0
  412. package/dist/esm/eventDataBatch.js.map +1 -0
  413. package/dist/esm/eventHubBufferedProducerClient.d.ts +323 -0
  414. package/dist/esm/eventHubBufferedProducerClient.d.ts.map +1 -0
  415. package/dist/esm/eventHubBufferedProducerClient.js +285 -0
  416. package/dist/esm/eventHubBufferedProducerClient.js.map +1 -0
  417. package/dist/esm/eventHubConsumerClient.d.ts +277 -0
  418. package/dist/esm/eventHubConsumerClient.d.ts.map +1 -0
  419. package/dist/esm/eventHubConsumerClient.js +293 -0
  420. package/dist/esm/eventHubConsumerClient.js.map +1 -0
  421. package/dist/esm/eventHubConsumerClientModels.d.ts +218 -0
  422. package/dist/esm/eventHubConsumerClientModels.d.ts.map +1 -0
  423. package/dist/esm/eventHubConsumerClientModels.js +4 -0
  424. package/dist/esm/eventHubConsumerClientModels.js.map +1 -0
  425. package/dist/esm/eventHubProducerClient.d.ts +266 -0
  426. package/dist/esm/eventHubProducerClient.d.ts.map +1 -0
  427. package/dist/esm/eventHubProducerClient.js +315 -0
  428. package/dist/esm/eventHubProducerClient.js.map +1 -0
  429. package/dist/esm/eventHubSender.d.ts +227 -0
  430. package/dist/esm/eventHubSender.d.ts.map +1 -0
  431. package/dist/esm/eventHubSender.js +541 -0
  432. package/dist/esm/eventHubSender.js.map +1 -0
  433. package/dist/esm/eventPosition.d.ts +73 -0
  434. package/dist/esm/eventPosition.d.ts.map +1 -0
  435. package/dist/esm/eventPosition.js +121 -0
  436. package/dist/esm/eventPosition.js.map +1 -0
  437. package/dist/esm/eventProcessor.d.ts +232 -0
  438. package/dist/esm/eventProcessor.d.ts.map +1 -0
  439. package/dist/esm/eventProcessor.js +367 -0
  440. package/dist/esm/eventProcessor.js.map +1 -0
  441. package/dist/esm/eventhubConnectionConfig.d.ts +96 -0
  442. package/dist/esm/eventhubConnectionConfig.d.ts.map +1 -0
  443. package/dist/esm/eventhubConnectionConfig.js +98 -0
  444. package/dist/esm/eventhubConnectionConfig.js.map +1 -0
  445. package/dist/esm/impl/awaitableQueue.d.ts +25 -0
  446. package/dist/esm/impl/awaitableQueue.d.ts.map +1 -0
  447. package/dist/esm/impl/awaitableQueue.js +47 -0
  448. package/dist/esm/impl/awaitableQueue.js.map +1 -0
  449. package/dist/esm/impl/partitionAssigner.d.ts +29 -0
  450. package/dist/esm/impl/partitionAssigner.d.ts.map +1 -0
  451. package/dist/esm/impl/partitionAssigner.js +54 -0
  452. package/dist/esm/impl/partitionAssigner.js.map +1 -0
  453. package/dist/esm/impl/partitionGate.d.ts +27 -0
  454. package/dist/esm/impl/partitionGate.d.ts.map +1 -0
  455. package/dist/esm/impl/partitionGate.js +40 -0
  456. package/dist/esm/impl/partitionGate.js.map +1 -0
  457. package/dist/esm/impl/partitionKeyToIdMapper.d.ts +6 -0
  458. package/dist/esm/impl/partitionKeyToIdMapper.d.ts.map +1 -0
  459. package/dist/esm/impl/partitionKeyToIdMapper.js +111 -0
  460. package/dist/esm/impl/partitionKeyToIdMapper.js.map +1 -0
  461. package/dist/esm/inMemoryCheckpointStore.d.ts +44 -0
  462. package/dist/esm/inMemoryCheckpointStore.d.ts.map +1 -0
  463. package/dist/esm/inMemoryCheckpointStore.js +92 -0
  464. package/dist/esm/inMemoryCheckpointStore.js.map +1 -0
  465. package/dist/esm/index.d.ts +21 -0
  466. package/dist/esm/index.d.ts.map +1 -0
  467. package/dist/esm/index.js +12 -0
  468. package/dist/esm/index.js.map +1 -0
  469. package/dist/esm/loadBalancerStrategies/balancedStrategy.d.ts +30 -0
  470. package/dist/esm/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -0
  471. package/dist/esm/loadBalancerStrategies/balancedStrategy.js +39 -0
  472. package/dist/esm/loadBalancerStrategies/balancedStrategy.js.map +1 -0
  473. package/dist/esm/loadBalancerStrategies/greedyStrategy.d.ts +24 -0
  474. package/dist/esm/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -0
  475. package/dist/esm/loadBalancerStrategies/greedyStrategy.js +28 -0
  476. package/dist/esm/loadBalancerStrategies/greedyStrategy.js.map +1 -0
  477. package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.d.ts +28 -0
  478. package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -0
  479. package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.js +245 -0
  480. package/dist/esm/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -0
  481. package/dist/esm/loadBalancerStrategies/unbalancedStrategy.d.ts +20 -0
  482. package/dist/esm/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -0
  483. package/dist/esm/loadBalancerStrategies/unbalancedStrategy.js +22 -0
  484. package/dist/esm/loadBalancerStrategies/unbalancedStrategy.js.map +1 -0
  485. package/dist/esm/logger.d.ts +37 -0
  486. package/dist/esm/logger.d.ts.map +1 -0
  487. package/dist/esm/logger.js +56 -0
  488. package/dist/esm/logger.js.map +1 -0
  489. package/dist/esm/managementClient.d.ts +145 -0
  490. package/dist/esm/managementClient.d.ts.map +1 -0
  491. package/dist/esm/managementClient.js +271 -0
  492. package/dist/esm/managementClient.js.map +1 -0
  493. package/dist/esm/models/private.d.ts +185 -0
  494. package/dist/esm/models/private.d.ts.map +1 -0
  495. package/dist/esm/models/private.js +4 -0
  496. package/dist/esm/models/private.js.map +1 -0
  497. package/dist/esm/models/public.d.ts +240 -0
  498. package/dist/esm/models/public.d.ts.map +1 -0
  499. package/dist/esm/models/public.js +18 -0
  500. package/dist/esm/models/public.js.map +1 -0
  501. package/dist/esm/package.json +3 -0
  502. package/dist/esm/partitionProcessor.d.ts +134 -0
  503. package/dist/esm/partitionProcessor.d.ts.map +1 -0
  504. package/dist/esm/partitionProcessor.js +134 -0
  505. package/dist/esm/partitionProcessor.js.map +1 -0
  506. package/dist/esm/partitionPump.d.ts +38 -0
  507. package/dist/esm/partitionPump.d.ts.map +1 -0
  508. package/dist/esm/partitionPump.js +166 -0
  509. package/dist/esm/partitionPump.js.map +1 -0
  510. package/dist/esm/partitionReceiver.d.ts +82 -0
  511. package/dist/esm/partitionReceiver.d.ts.map +1 -0
  512. package/dist/esm/partitionReceiver.js +330 -0
  513. package/dist/esm/partitionReceiver.js.map +1 -0
  514. package/dist/esm/pumpManager.d.ts +72 -0
  515. package/dist/esm/pumpManager.d.ts.map +1 -0
  516. package/dist/esm/pumpManager.js +118 -0
  517. package/dist/esm/pumpManager.js.map +1 -0
  518. package/dist/esm/util/connectionStringUtils.d.ts +52 -0
  519. package/dist/esm/util/connectionStringUtils.d.ts.map +1 -0
  520. package/dist/esm/util/connectionStringUtils.js +48 -0
  521. package/dist/esm/util/connectionStringUtils.js.map +1 -0
  522. package/dist/esm/util/constants.d.ts +25 -0
  523. package/dist/esm/util/constants.d.ts.map +1 -0
  524. package/dist/esm/util/constants.js +27 -0
  525. package/dist/esm/util/constants.js.map +1 -0
  526. package/dist/esm/util/delayWithoutThrow.d.ts +8 -0
  527. package/dist/esm/util/delayWithoutThrow.d.ts.map +1 -0
  528. package/dist/esm/util/delayWithoutThrow.js +17 -0
  529. package/dist/esm/util/delayWithoutThrow.js.map +1 -0
  530. package/dist/esm/util/error.d.ts +39 -0
  531. package/dist/esm/util/error.d.ts.map +1 -0
  532. package/dist/esm/util/error.js +103 -0
  533. package/dist/esm/util/error.js.map +1 -0
  534. package/dist/esm/util/getPromiseParts.d.ts +10 -0
  535. package/dist/esm/util/getPromiseParts.d.ts.map +1 -0
  536. package/dist/esm/util/getPromiseParts.js +20 -0
  537. package/dist/esm/util/getPromiseParts.js.map +1 -0
  538. package/dist/esm/util/operationOptions.d.ts +16 -0
  539. package/dist/esm/util/operationOptions.d.ts.map +1 -0
  540. package/dist/esm/util/operationOptions.js +4 -0
  541. package/dist/esm/util/operationOptions.js.map +1 -0
  542. package/dist/esm/util/parseEndpoint.d.ts +11 -0
  543. package/dist/esm/util/parseEndpoint.d.ts.map +1 -0
  544. package/dist/esm/util/parseEndpoint.js +17 -0
  545. package/dist/esm/util/parseEndpoint.js.map +1 -0
  546. package/dist/esm/util/retries.d.ts +6 -0
  547. package/dist/esm/util/retries.d.ts.map +1 -0
  548. package/dist/esm/util/retries.js +13 -0
  549. package/dist/esm/util/retries.js.map +1 -0
  550. package/dist/esm/util/runtimeInfo.d.ts +6 -0
  551. package/dist/esm/util/runtimeInfo.d.ts.map +1 -0
  552. package/{dist-esm/src → dist/esm}/util/runtimeInfo.js +1 -1
  553. package/{dist-esm/src → dist/esm}/util/runtimeInfo.js.map +1 -1
  554. package/dist/esm/util/timerLoop.d.ts +26 -0
  555. package/dist/esm/util/timerLoop.d.ts.map +1 -0
  556. package/dist/esm/util/timerLoop.js +27 -0
  557. package/dist/esm/util/timerLoop.js.map +1 -0
  558. package/dist/esm/util/typeGuards.d.ts +8 -0
  559. package/dist/esm/util/typeGuards.d.ts.map +1 -0
  560. package/dist/esm/util/typeGuards.js +12 -0
  561. package/dist/esm/util/typeGuards.js.map +1 -0
  562. package/dist/esm/util/utils.d.ts +7 -0
  563. package/dist/esm/util/utils.d.ts.map +1 -0
  564. package/dist/esm/util/utils.js +13 -0
  565. package/dist/esm/util/utils.js.map +1 -0
  566. package/dist/esm/withAuth.d.ts +25 -0
  567. package/dist/esm/withAuth.d.ts.map +1 -0
  568. package/dist/esm/withAuth.js +84 -0
  569. package/dist/esm/withAuth.js.map +1 -0
  570. package/package.json +85 -80
  571. package/dist/index.js +0 -5372
  572. package/dist/index.js.map +0 -1
  573. package/dist-esm/src/batchingPartitionChannel.js.map +0 -1
  574. package/dist-esm/src/connectionContext.js.map +0 -1
  575. package/dist-esm/src/dataTransformer.js.map +0 -1
  576. package/dist-esm/src/diagnostics/instrumentEventData.js.map +0 -1
  577. package/dist-esm/src/diagnostics/tracing.js.map +0 -1
  578. package/dist-esm/src/eventData.js.map +0 -1
  579. package/dist-esm/src/eventDataAdapter.js.map +0 -1
  580. package/dist-esm/src/eventDataBatch.js.map +0 -1
  581. package/dist-esm/src/eventHubBufferedProducerClient.js.map +0 -1
  582. package/dist-esm/src/eventHubConsumerClient.js.map +0 -1
  583. package/dist-esm/src/eventHubConsumerClientModels.js +0 -4
  584. package/dist-esm/src/eventHubConsumerClientModels.js.map +0 -1
  585. package/dist-esm/src/eventHubProducerClient.js.map +0 -1
  586. package/dist-esm/src/eventHubSender.js.map +0 -1
  587. package/dist-esm/src/eventPosition.js.map +0 -1
  588. package/dist-esm/src/eventProcessor.js.map +0 -1
  589. package/dist-esm/src/eventhubConnectionConfig.js.map +0 -1
  590. package/dist-esm/src/impl/awaitableQueue.js.map +0 -1
  591. package/dist-esm/src/impl/partitionAssigner.js.map +0 -1
  592. package/dist-esm/src/inMemoryCheckpointStore.js.map +0 -1
  593. package/dist-esm/src/index.js.map +0 -1
  594. package/dist-esm/src/loadBalancerStrategies/balancedStrategy.js.map +0 -1
  595. package/dist-esm/src/loadBalancerStrategies/greedyStrategy.js.map +0 -1
  596. package/dist-esm/src/loadBalancerStrategies/loadBalancingStrategy.js.map +0 -1
  597. package/dist-esm/src/loadBalancerStrategies/unbalancedStrategy.js.map +0 -1
  598. package/dist-esm/src/logger.js.map +0 -1
  599. package/dist-esm/src/managementClient.js.map +0 -1
  600. package/dist-esm/src/models/private.js +0 -4
  601. package/dist-esm/src/models/private.js.map +0 -1
  602. package/dist-esm/src/models/public.js.map +0 -1
  603. package/dist-esm/src/partitionProcessor.js.map +0 -1
  604. package/dist-esm/src/partitionPump.js.map +0 -1
  605. package/dist-esm/src/partitionReceiver.js.map +0 -1
  606. package/dist-esm/src/pumpManager.js.map +0 -1
  607. package/dist-esm/src/util/constants.js.map +0 -1
  608. package/dist-esm/src/util/delayWithoutThrow.js.map +0 -1
  609. package/dist-esm/src/util/error.js.map +0 -1
  610. package/dist-esm/src/util/operationOptions.js +0 -4
  611. package/dist-esm/src/util/operationOptions.js.map +0 -1
  612. package/dist-esm/src/util/retries.js.map +0 -1
  613. package/dist-esm/src/util/runtimeInfo.browser.js.map +0 -1
  614. package/dist-esm/src/util/typeGuards.js.map +0 -1
  615. package/dist-esm/src/withAuth.js.map +0 -1
  616. package/types/latest/event-hubs.d.ts +0 -1877
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventHubSender.js","sourceRoot":"","sources":["../../src/eventHubSender.ts"],"names":[],"mappings":"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AE,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,iFAAiF;QACjF,8DAA8D;QAC9D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,KAAK,CAAC,wBAAwB,GAAG,KAAK,CAAC,8BAA8B,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,iCAAiC,CACxC,MAAuE;IAEvE,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,yBAAyB;IAC3B,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AmqpError,\n AwaitableSender,\n AwaitableSenderOptions,\n EventContext,\n OnAmqpEvent,\n Message as RheaMessage,\n message,\n types,\n} from \"rhea-promise\";\nimport {\n Constants,\n ErrorNameConditionMapper,\n RetryConfig,\n RetryOperationType,\n RetryOptions,\n defaultCancellableLock,\n delay,\n retry,\n translate,\n} from \"@azure/core-amqp\";\nimport {\n EventData,\n EventDataInternal,\n populateIdempotentMessageAnnotations,\n toRheaMessage,\n} from \"./eventData\";\nimport { EventDataBatch, EventDataBatchImpl, isEventDataBatch } from \"./eventDataBatch\";\nimport {\n logErrorStackTrace,\n createSimpleLogger,\n logger,\n SimpleLogger,\n createSenderLogPrefix,\n} from \"./logger\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { ConnectionContext } from \"./connectionContext\";\nimport { EventHubProducerOptions, IdempotentLinkProperties } from \"./models/private\";\nimport { SendOptions } from \"./models/public\";\nimport { PartitionPublishingOptions, PartitionPublishingProperties } from \"./models/private\";\nimport { getRetryAttemptTimeoutInMs } from \"./util/retries\";\nimport {\n idempotentProducerAmqpPropertyNames,\n PENDING_PUBLISH_SEQ_NUM_SYMBOL,\n} from \"./util/constants\";\nimport { isDefined } from \"@azure/core-util\";\nimport { translateError } from \"./util/error\";\nimport { TimerLoop } from \"./util/timerLoop\";\nimport { withAuth } from \"./withAuth\";\nimport { getRandomName } from \"./util/utils\";\n\n/**\n * @internal\n */\nexport interface EventHubSenderOptions {\n /**\n * Indicates whether or not the sender should enable idempotent publishing to Event Hub partitions.\n */\n enableIdempotentProducer: boolean;\n /**\n * The EventHub partition id to which the sender wants to send the event data.\n */\n partitionId?: string;\n /**\n * The set of options that can be specified to influence publishing behavior\n * specific to a partition.\n */\n partitionPublishingOptions?: PartitionPublishingOptions;\n}\n\n/**\n * Describes the EventHubSender that will send event data to EventHub.\n * @internal\n */\nexport class EventHubSender {\n /**\n * The unique lock name per connection that is used to acquire the\n * lock for establishing a sender link by an entity on that connection.\n */\n private readonly senderLock: string = getRandomName(\"sender\");\n /**\n * The handler function to handle errors that happen on the\n * underlying sender.\n */\n private readonly _onAmqpError: OnAmqpEvent;\n /**\n * The handler function to handle \"sender_close\" event\n * that happens on the underlying sender.\n */\n private readonly _onAmqpClose: OnAmqpEvent;\n /**\n * The message handler that will be set as the handler on\n * the underlying rhea sender's session for the \"session_error\" event.\n */\n private _onSessionError: OnAmqpEvent;\n /**\n * The message handler that will be set as the handler on\n * the underlying rhea sender's session for the \"session_close\" event.\n */\n private _onSessionClose: OnAmqpEvent;\n /**\n * The AMQP sender link.\n */\n private _sender?: AwaitableSender;\n /**\n * The partition ID.\n */\n private readonly partitionId?: string;\n /**\n * Indicates whether the sender is configured for idempotent publishing.\n */\n private _isIdempotentProducer: boolean;\n /**\n * Indicates whether the sender has an in-flight send while idempotent\n * publishing is enabled.\n */\n private _hasPendingSend?: boolean;\n /**\n * A local copy of the PartitionPublishingProperties that can be mutated to\n * keep track of the lastSequenceNumber used.\n */\n private _localPublishingProperties?: PartitionPublishingProperties;\n /**\n * The user-provided set of options that can be specified to influence\n * publishing behavior specific to a partition.\n */\n private _userProvidedPublishingOptions?: PartitionPublishingOptions;\n /**\n * Indicates whether the link is in the process of connecting\n * (establishing) itself. Default value: `false`.\n */\n private isConnecting: boolean = false;\n /**\n * The unique name for the entity (mostly a guid).\n */\n private readonly name: string;\n /**\n * The address in the following form:\n * - `\"<hubName>\"`\n * - `\"<hubName>/Partitions/<partitionId>\"`.\n */\n private readonly address: string;\n /**\n * The token audience in the following form:\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>/Partitions/<partitionId>\"`.\n */\n private readonly audience: string;\n /**\n * Provides relevant information about the amqp connection,\n * cbs and $management sessions, token provider, sender and receivers.\n */\n private readonly _context: ConnectionContext;\n /**\n * The auth loop.\n */\n private authLoop?: TimerLoop;\n /**\n * The logger.\n */\n private readonly logger: SimpleLogger;\n\n /** The client identifier */\n private _id: string;\n\n /**\n * Creates a new EventHubSender instance.\n * @param context - The connection context.\n * @param options - Options used to configure the EventHubSender.\n */\n constructor(\n context: ConnectionContext,\n senderId: string,\n { partitionId, enableIdempotentProducer, partitionPublishingOptions }: EventHubSenderOptions,\n ) {\n this.address = context.config.getSenderAddress(partitionId);\n this.name = this.address;\n this._id = senderId;\n this.audience = context.config.getSenderAudience(partitionId);\n this._context = context;\n this.partitionId = partitionId;\n this._isIdempotentProducer = enableIdempotentProducer;\n this._userProvidedPublishingOptions = partitionPublishingOptions;\n const logPrefix = createSenderLogPrefix(this.name, this._context.connectionId);\n this.logger = createSimpleLogger(logger, logPrefix);\n\n this._onAmqpError = (eventContext: EventContext) => {\n const senderError = eventContext.sender && eventContext.sender.error;\n this.logger.verbose(\n \"'sender_error' event occurred. The associated error is: %O\",\n senderError,\n );\n // TODO: Consider rejecting promise in trySendBatch() or createBatch()\n };\n\n this._onSessionError = (eventContext: EventContext) => {\n const sessionError = eventContext.session && eventContext.session.error;\n this.logger.verbose(\n \"'session_error' event occurred. The associated error is: %O\",\n sessionError,\n );\n // TODO: Consider rejecting promise in trySendBatch() or createBatch()\n };\n\n this._onAmqpClose = async (eventContext: EventContext) => {\n const sender = this._sender || eventContext.sender!;\n this.logger.verbose(\n \"'sender_close' event occurred. Value for isItselfClosed on the receiver is: '%s' \" +\n \"Value for isConnecting on the session is: '%s'.\",\n sender?.isItselfClosed().toString(),\n this.isConnecting,\n );\n if (sender && !this.isConnecting) {\n // Call close to clean up timers & other resources\n await sender.close().catch((err) => {\n this.logger.verbose(\"error when closing after 'sender_close' event: %O\", err);\n });\n }\n };\n\n this._onSessionClose = async (eventContext: EventContext) => {\n const sender = this._sender || eventContext.sender!;\n this.logger.verbose(\n \"'session_close' event occurred. Value for isSessionItselfClosed on the session is: '%s' \" +\n \"Value for isConnecting on the session is: '%s'.\",\n sender?.isSessionItselfClosed().toString(),\n this.isConnecting,\n );\n if (sender && !this.isConnecting) {\n // Call close to clean up timers & other resources\n await sender.close().catch((err) => {\n this.logger.verbose(\"error when closing after 'session_close' event: %O\", err);\n });\n }\n };\n }\n\n /**\n * Deletes the sender from the context. Clears the token renewal timer. Closes the sender link.\n */\n async close(): Promise<void> {\n try {\n if (this._sender) {\n this.logger.info(\"closing\");\n const senderLink = this._sender;\n this._deleteFromCache();\n await senderLink.close();\n this.authLoop?.stop();\n this.logger.verbose(\"closed.\");\n }\n } catch (err: any) {\n const msg = `an error occurred while closing: ${err?.name}: ${err?.message}`;\n this.logger.warning(msg);\n logErrorStackTrace(err);\n throw err;\n }\n }\n\n /**\n * Determines whether the AMQP sender link is open. If open then returns true else returns false.\n * @returns boolean\n */\n isOpen(): boolean {\n const result = Boolean(this._sender && this._sender.isOpen());\n this.logger.verbose(\"is open? -> %s\", result);\n return result;\n }\n /**\n * Returns maximum message size on the AMQP sender link.\n * @param abortSignal - An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation.\n * For example, use the &commat;azure/abort-controller to create an `AbortSignal`.\n * @returns Promise<number>\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n async getMaxMessageSize(\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n } = {},\n ): Promise<number> {\n const sender = await this._getLink(options);\n\n return sender.maxMessageSize;\n }\n\n /**\n * Get the information about the state of publishing for a partition as observed by the `EventHubSender`.\n * This data can always be read, but will only be populated with information relevant to the active features\n * for the producer client.\n */\n async getPartitionPublishingProperties(\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n } = {},\n ): Promise<PartitionPublishingProperties> {\n if (this._localPublishingProperties) {\n // Send a copy of the properties so it can't be mutated downstream.\n return { ...this._localPublishingProperties };\n }\n\n const properties: PartitionPublishingProperties = {\n isIdempotentPublishingEnabled: this._isIdempotentProducer,\n partitionId: this.partitionId ?? \"\",\n };\n\n if (this._isIdempotentProducer) {\n this._sender = await this._getLink(options);\n // await this._createLinkIfNotOpen(options);\n if (!this._sender) {\n // createLinkIfNotOpen should throw if `this._sender` can't be created, but just in case it gets\n // deleted while setting up token refreshing, make sure it exists.\n throw new Error(\n `Failed to retrieve partition publishing properties for partition \"${this.partitionId}\".`,\n );\n }\n\n const {\n [idempotentProducerAmqpPropertyNames.epoch]: ownerLevel,\n [idempotentProducerAmqpPropertyNames.producerId]: producerGroupId,\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: lastPublishedSequenceNumber,\n } = this._sender.properties ?? {};\n\n properties.ownerLevel = parseInt(ownerLevel, 10);\n properties.producerGroupId = parseInt(producerGroupId, 10);\n properties.lastPublishedSequenceNumber = parseInt(lastPublishedSequenceNumber, 10);\n }\n\n this._localPublishingProperties = properties;\n\n // Send a copy of the properties so it can't be mutated downstream.\n return { ...properties };\n }\n\n /**\n * Send a batch of EventData to the EventHub. The \"message_annotations\",\n * \"application_properties\" and \"properties\" of the first message will be set as that\n * of the envelope (batch message).\n * @param events - An array of EventData objects to be sent in a Batch message.\n * @param options - Options to control the way the events are batched along with request options\n */\n async send(\n events: EventData[] | EventDataBatch,\n options?: SendOptions &\n EventHubProducerOptions & { tracingProperties?: Array<EventData[\"properties\"]> },\n ): Promise<void> {\n try {\n this.logger.info(\"trying to send EventData[].\");\n if (this._isIdempotentProducer && this._hasPendingSend) {\n throw new Error(\n `There can only be 1 \"sendBatch\" call in-flight per partition while \"enableIdempotentRetries\" is set to true.`,\n );\n }\n\n const eventCount = isEventDataBatch(events) ? events.count : events.length;\n if (eventCount === 0) {\n this.logger.info(`no events were passed to sendBatch.`);\n return;\n }\n\n if (this._isIdempotentProducer) {\n this._hasPendingSend = true;\n }\n\n this.logger.info(\"sending encoded batch message.\");\n await this._trySendBatch(events, options);\n if (this._isIdempotentProducer) {\n commitIdempotentSequenceNumbers(events);\n if (this._localPublishingProperties) {\n const { lastPublishedSequenceNumber = 0 } = this._localPublishingProperties;\n // Increment the lastPublishedSequenceNumber based on the number of events published.\n this._localPublishingProperties.lastPublishedSequenceNumber =\n lastPublishedSequenceNumber + eventCount;\n }\n }\n return;\n } catch (err: any) {\n rollbackIdempotentSequenceNumbers(events);\n this.logger.warning(\n `an error occurred while sending the batch message ${err?.name}: ${err?.message}`,\n );\n logErrorStackTrace(err);\n throw err;\n } finally {\n if (this._isIdempotentProducer) {\n this._hasPendingSend = false;\n }\n }\n }\n\n /**\n * @param sender - The rhea sender that contains the idempotent producer properties.\n */\n private _populateLocalPublishingProperties(sender: AwaitableSender): void {\n const {\n [idempotentProducerAmqpPropertyNames.epoch]: ownerLevel,\n [idempotentProducerAmqpPropertyNames.producerId]: producerGroupId,\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: lastPublishedSequenceNumber,\n } = sender.properties ?? {};\n\n this._localPublishingProperties = {\n isIdempotentPublishingEnabled: this._isIdempotentProducer,\n partitionId: this.partitionId ?? \"\",\n lastPublishedSequenceNumber,\n ownerLevel,\n producerGroupId,\n };\n }\n\n private _deleteFromCache(): void {\n this._sender = undefined;\n delete this._context.senders[this.name];\n this.logger.verbose(\"deleted from the client cache.\");\n }\n\n private _createSenderOptions(): AwaitableSenderOptions {\n const srOptions: AwaitableSenderOptions = {\n name: this.name,\n source: this._id,\n target: {\n address: this.address,\n },\n onError: this._onAmqpError,\n onClose: this._onAmqpClose,\n onSessionError: this._onSessionError,\n onSessionClose: this._onSessionClose,\n };\n\n srOptions.desired_capabilities = [Constants.geoReplication];\n if (this._isIdempotentProducer) {\n srOptions.desired_capabilities.push(idempotentProducerAmqpPropertyNames.capability);\n const idempotentProperties = generateIdempotentLinkProperties(\n this._userProvidedPublishingOptions,\n this._localPublishingProperties,\n );\n srOptions.properties = idempotentProperties;\n }\n this.logger.verbose(\"being created with options: %O\", srOptions);\n return srOptions;\n }\n\n /**\n * Tries to send the message to EventHub if there is enough credit to send them\n * and the circular buffer has available space to settle the message after sending them.\n *\n * We have implemented a synchronous send over here in the sense that we shall be waiting\n * for the message to be accepted or rejected and accordingly resolve or reject the promise.\n * @param rheaMessage - The message to be sent to EventHub.\n * @returns Promise<void>\n */\n private async _trySendBatch(\n events: EventData[] | EventDataBatch,\n options: SendOptions &\n EventHubProducerOptions & {\n /**\n * Tracing properties that are associated with EventData.\n */\n tracingProperties?: Array<EventData[\"properties\"]>;\n } = {},\n ): Promise<void> {\n const abortSignal: AbortSignalLike | undefined = options.abortSignal;\n const retryOptions = options.retryOptions || {};\n const timeoutInMs = getRetryAttemptTimeoutInMs(retryOptions);\n retryOptions.timeoutInMs = timeoutInMs;\n\n const sendEventPromise = async (): Promise<void> => {\n const initStartTime = Date.now();\n // TODO: (jeremymeng) A or B\n // variant A:\n const sender = await this._getLink(options);\n // variant B\n // await this._createLinkIfNotOpen(options);\n const publishingProps = await this.getPartitionPublishingProperties(options);\n const timeTakenByInit = Date.now() - initStartTime;\n\n this.logger.verbose(\n \"credit: %d available: %d\",\n sender.credit,\n sender.session.outgoing.available(),\n );\n\n let waitTimeForSendable = 1000;\n if (!sender.sendable() && timeoutInMs - timeTakenByInit > waitTimeForSendable) {\n this.logger.verbose(\"waiting for 1 second for sender to become sendable\");\n\n await delay(waitTimeForSendable);\n\n this.logger.verbose(\n \"after waiting for a second, credit: %d available: %d\",\n sender.credit,\n sender.session?.outgoing?.available(),\n );\n } else {\n waitTimeForSendable = 0;\n }\n\n if (!sender.sendable()) {\n // let us retry to send the message after some time.\n const msg = `cannot send the message right now. Please try later.`;\n this.logger.warning(msg);\n const amqpError: AmqpError = {\n condition: ErrorNameConditionMapper.SenderBusyError,\n description: msg,\n };\n throw translate(amqpError);\n }\n\n if (timeoutInMs <= timeTakenByInit + waitTimeForSendable) {\n const desc: string =\n `was not able to send the message right now, due ` + `to operation timeout.`;\n this.logger.warning(desc);\n const e: AmqpError = {\n condition: ErrorNameConditionMapper.ServiceUnavailableError,\n description: desc,\n };\n throw translate(e);\n }\n\n try {\n const encodedMessage = transformEventsForSend(events, publishingProps, options);\n const delivery = await sender.send(encodedMessage, {\n format: 0x80013700,\n timeoutInSeconds: (timeoutInMs - timeTakenByInit - waitTimeForSendable) / 1000,\n abortSignal,\n });\n this.logger.info(\"sent message with delivery id: %d\", delivery.id);\n } catch (err: any) {\n const error = err.innerError || err;\n const translatedError = translateError(error);\n throw translatedError;\n }\n };\n\n const config: RetryConfig<void> = {\n operation: sendEventPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.sendMessage,\n abortSignal: abortSignal,\n retryOptions: retryOptions,\n };\n\n try {\n await retry<void>(config);\n } catch (err: any) {\n const translatedError = translate(err);\n this.logger.warning(\n \"an error occurred while sending the message %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n private async _getLink(\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n } = {},\n ): Promise<AwaitableSender> {\n if (this.isOpen() && this._sender) {\n return this._sender;\n }\n const retryOptions = options.retryOptions || {};\n const timeoutInMs = getRetryAttemptTimeoutInMs(retryOptions);\n retryOptions.timeoutInMs = timeoutInMs;\n const senderOptions = this._createSenderOptions();\n\n const startTime = Date.now();\n const createLinkPromise = async (): Promise<AwaitableSender> => {\n return defaultCancellableLock.acquire(\n this.senderLock,\n () => {\n const taskStartTime = Date.now();\n const taskTimeoutInMs = timeoutInMs - (taskStartTime - startTime);\n return this._init({\n ...senderOptions,\n abortSignal: options.abortSignal,\n timeoutInMs: taskTimeoutInMs,\n });\n },\n { abortSignal: options.abortSignal, timeoutInMs: timeoutInMs },\n );\n };\n\n const config: RetryConfig<AwaitableSender> = {\n operation: createLinkPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.senderLink,\n abortSignal: options.abortSignal,\n retryOptions: retryOptions,\n };\n\n try {\n return await retry<AwaitableSender>(config);\n } catch (err: any) {\n const translatedError = translate(err);\n this.logger.warning(\n \"an error occurred while creating: %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n /**\n * Initializes the sender session on the connection.\n * Should only be called from _createLinkIfNotOpen\n */\n private async _init(\n options: AwaitableSenderOptions & {\n abortSignal: AbortSignalLike | undefined;\n timeoutInMs: number;\n },\n ): Promise<AwaitableSender> {\n const createSender = async () => {\n this.logger.verbose(\"trying to be created...\");\n\n const sender = await this._context.connection.createAwaitableSender(options);\n this._sender = sender;\n this._populateLocalPublishingProperties(this._sender);\n this.isConnecting = false;\n this.logger.verbose(\"created with options: %O\", options);\n\n // It is possible for someone to close the sender and then start it again.\n // Thus make sure that the sender is present in the client cache.\n if (!this._context.senders[this.name]) this._context.senders[this.name] = this;\n };\n try {\n if (!this.isOpen() || !this._sender) {\n await this._context.readyToOpenLink();\n this.authLoop = await withAuth(\n createSender,\n this._context,\n this.audience,\n options.timeoutInMs,\n this.logger,\n { abortSignal: options.abortSignal },\n );\n // it is guaranteed to be defined at this point, otherwise, an error would\n // have been thrown.\n return this._sender!;\n } else {\n this.logger.verbose(\"is open -> %s. Hence not reconnecting.\", this.isOpen());\n return this._sender;\n }\n } catch (err) {\n const translatedError = translate(err);\n this.logger.warning(\n \"an error occurred while being created: %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n /**\n * Creates a new sender to the given event hub, and optionally to a given partition if it is\n * not present in the context or returns the one present in the context.\n * @hidden\n * @param options - Options used to configure the EventHubSender.\n */\n static create(\n context: ConnectionContext,\n senderId: string,\n options: EventHubSenderOptions,\n ): EventHubSender {\n const ehSender: EventHubSender = new EventHubSender(context, senderId, options);\n if (!context.senders[ehSender.name]) {\n context.senders[ehSender.name] = ehSender;\n }\n return context.senders[ehSender.name];\n }\n}\n\n/**\n * Generates the link properties for an indemopotent sender given\n * based on the user-provided and locally-cached publishing options.\n *\n * Note: The set of idempotent properties a user specifies at EventHubProducerClient instantiation-time\n * is slightly different than what the service returns and the EventHubSender keeps track of locally.\n *\n * The difference is that the user specifies the `startingSequenceNumber`, whereas the local options\n * (those returned by getPartitionPublishingProperties) specifies `lastPublishedSequenceNumber`.\n *\n * These _can_ be the same, but the user is technically free to set any `startingSequenceNumber` they want.\n * @internal\n */\nexport function generateIdempotentLinkProperties(\n userProvidedPublishingOptions: PartitionPublishingOptions | undefined,\n localPublishingOptions: PartitionPublishingProperties | undefined,\n): IdempotentLinkProperties | Record<string, never> {\n let ownerLevel: number | undefined;\n let producerGroupId: number | undefined;\n let sequenceNumber: number | undefined;\n\n // Prefer local publishing options since this is the up-to-date state of the sender.\n // Only use user-provided publishing options the first time we create the link.\n if (localPublishingOptions) {\n ownerLevel = localPublishingOptions.ownerLevel;\n producerGroupId = localPublishingOptions.producerGroupId;\n sequenceNumber = localPublishingOptions.lastPublishedSequenceNumber;\n } else if (userProvidedPublishingOptions) {\n ownerLevel = userProvidedPublishingOptions.ownerLevel;\n producerGroupId = userProvidedPublishingOptions.producerGroupId;\n sequenceNumber = userProvidedPublishingOptions.startingSequenceNumber;\n } else {\n // If we don't have any properties at all, send an empty object.\n // This will cause the service to generate a new producer-id for our client.\n return {};\n }\n\n // The service requires that if ANY_ of these properties are defined,\n // they _ALL_ have to be defined.\n // If we don't have one of the required values, use `null` and the\n // service will provide it.\n const idempotentLinkProperties: IdempotentLinkProperties = {\n [idempotentProducerAmqpPropertyNames.epoch]: isDefined(ownerLevel)\n ? types.wrap_short(ownerLevel)\n : null,\n [idempotentProducerAmqpPropertyNames.producerId]: isDefined(producerGroupId)\n ? types.wrap_long(producerGroupId)\n : null,\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: isDefined(sequenceNumber)\n ? types.wrap_int(sequenceNumber)\n : null,\n };\n\n return idempotentLinkProperties;\n}\n\n/**\n * Encodes a list or batch of events into a single binary message that can be sent to the service.\n *\n * Prior to encoding, any special properties not specified by the user, such as tracing or idempotent\n * properties, are assigned to the list or batch of events as needed.\n *\n * @internal\n * @param events - Events to transform for sending to the service.\n * @param publishingProps - Describes the current publishing state for the partition.\n * @param options - Options used to configure this function.\n */\nexport function transformEventsForSend(\n events: EventData[] | EventDataBatch,\n publishingProps: PartitionPublishingProperties,\n options: SendOptions & {\n /**\n * A list containing the `Diagnostic-Id` tracing property that is associated with each EventData.\n * The index of tracingProperties corresponds to the same index in `events` when `events` is EventData[].\n */\n tracingProperties?: Array<EventData[\"properties\"]>;\n } = {},\n): Buffer {\n if (isEventDataBatch(events)) {\n return (events as EventDataBatchImpl)._generateMessage(publishingProps);\n } else {\n const eventCount = events.length;\n // convert events to rhea messages\n const rheaMessages: RheaMessage[] = [];\n const tracingProperties = options.tracingProperties ?? [];\n for (let i = 0; i < eventCount; i++) {\n const originalEvent = events[i];\n const tracingProperty = tracingProperties[i];\n // Create a copy of the user's event so we can add the tracing property.\n const event: EventData = {\n ...originalEvent,\n properties: { ...originalEvent.properties, ...tracingProperty },\n };\n const rheaMessage = toRheaMessage(event, options.partitionKey);\n\n // populate idempotent message annotations\n const { lastPublishedSequenceNumber = 0 } = publishingProps;\n const startingSequenceNumber = lastPublishedSequenceNumber + 1;\n const pendingPublishSequenceNumber = startingSequenceNumber + i;\n populateIdempotentMessageAnnotations(rheaMessage, {\n ...publishingProps,\n publishSequenceNumber: pendingPublishSequenceNumber,\n });\n\n if (publishingProps.isIdempotentPublishingEnabled) {\n // Set pending seq number on user's event.\n (originalEvent as EventDataInternal)[PENDING_PUBLISH_SEQ_NUM_SYMBOL] =\n pendingPublishSequenceNumber;\n }\n\n rheaMessages.push(rheaMessage);\n }\n\n // Encode every amqp message and then convert every encoded message to amqp data section\n const batchMessage: RheaMessage = {\n body: message.data_sections(rheaMessages.map(message.encode)),\n };\n\n // Set message_annotations of the first message as\n // that of the envelope (batch message).\n if (rheaMessages[0].message_annotations) {\n batchMessage.message_annotations = { ...rheaMessages[0].message_annotations };\n }\n\n // Finally encode the envelope (batch message).\n return message.encode(batchMessage);\n }\n}\n\n/**\n * Commits the pending publish sequence number events.\n * EventDataBatch exposes this as `startingPublishSequenceNumber`,\n * EventData not in a batch exposes this as `publishedSequenceNumber`.\n */\nfunction commitIdempotentSequenceNumbers(\n events: Omit<EventDataInternal, \"getRawAmqpMessage\">[] | EventDataBatch,\n): void {\n if (isEventDataBatch(events)) {\n (events as EventDataBatchImpl)._commitPublish();\n } else {\n // For each event, set the `publishedSequenceNumber` equal to the sequence number\n // we set when we attempted to send the events to the service.\n for (const event of events) {\n event._publishedSequenceNumber = event[PENDING_PUBLISH_SEQ_NUM_SYMBOL];\n delete event[PENDING_PUBLISH_SEQ_NUM_SYMBOL];\n }\n }\n}\n\n/**\n * Rolls back any pending publish sequence number in the events.\n */\nfunction rollbackIdempotentSequenceNumbers(\n events: Omit<EventDataInternal, \"getRawAmqpMessage\">[] | EventDataBatch,\n): void {\n if (isEventDataBatch(events)) {\n /* No action required. */\n } else {\n for (const event of events) {\n delete event[PENDING_PUBLISH_SEQ_NUM_SYMBOL];\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventPosition.js","sourceRoot":"","sources":["../../src/eventPosition.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,wBAAwB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,CAAC;IAED,IAAI,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACxE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACxF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,iBAAiB,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,qBAAqB,CAAC,QAAuB;IACpD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO;IACT,CAAC;IACD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,qBAAqB,GAAG,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACjE,MAAM,iBAAiB,GAAG,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEzD,IACE,CAAC,aAAa,IAAI,qBAAqB,CAAC;QACxC,CAAC,aAAa,IAAI,iBAAiB,CAAC;QACpC,CAAC,iBAAiB,IAAI,qBAAqB,CAAC,EAC5C,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,yGAAyG,CAC1G,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,aAAa,IAAI,CAAC,iBAAiB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACnE,MAAM,IAAI,SAAS,CACjB,2HAA2H,CAC5H,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Constants, ErrorNameConditionMapper, translate } from \"@azure/core-amqp\";\nimport { isDefined, objectHasProperty } from \"@azure/core-util\";\n\n/**\n * Represents the position of an event in an Event Hub partition, typically used when calling the `subscribe()`\n * method on an `EventHubConsumerClient` to specify the position in the partition to begin receiving events from.\n *\n * To get an EventPosition representing the start or end of the stream, use the constants\n * `earliestEventPosition` and `latestEventPosition` respectively.\n *\n */\nexport interface EventPosition {\n /**\n * The offset of the event identified by this position.\n * Expected to be undefined if the position is just created from a sequence number or an enqueued time.\n *\n * The offset is the relative position for an event in the context of the partition.\n * The offset should not be considered a stable value.\n * The same offset may refer to a different event as events reach the age limit for\n * retention and are no longer visible within the partition.\n */\n offset?: string | \"@latest\";\n /**\n * Indicates if the specified offset is inclusive of the event which it identifies.\n * This information is only relevent if the event position was identified by an offset or sequence number.\n * Default value: `false`.\n */\n isInclusive?: boolean;\n /**\n * The enqueued time in UTC of the event identified by this position.\n * When provided as a number this value is the number of milliseconds since the Unix Epoch.\n * Expected to be undefined if the position is just created from a sequence number or an offset.\n */\n enqueuedOn?: Date | number;\n\n /**\n * The sequence number of the event identified by this position.\n * Expected to be undefined if the position is just created from an offset or enqueued time.\n */\n sequenceNumber?: number;\n}\n\n/**\n * @internal\n * Gets the expression to be set as the filter clause when creating the receiver\n * @returns filterExpression\n */\nexport function getEventPositionFilter(eventPosition: EventPosition): string {\n let result;\n // order of preference\n if (isDefined(eventPosition.offset)) {\n result = eventPosition.isInclusive\n ? `${Constants.offsetAnnotation} >= '${eventPosition.offset}'`\n : `${Constants.offsetAnnotation} > '${eventPosition.offset}'`;\n } else if (isDefined(eventPosition.sequenceNumber)) {\n result = eventPosition.isInclusive\n ? `${Constants.sequenceNumberAnnotation} >= '${eventPosition.sequenceNumber}'`\n : `${Constants.sequenceNumberAnnotation} > '${eventPosition.sequenceNumber}'`;\n } else if (isDefined(eventPosition.enqueuedOn)) {\n const time =\n eventPosition.enqueuedOn instanceof Date\n ? eventPosition.enqueuedOn.getTime()\n : eventPosition.enqueuedOn;\n result = `${Constants.enqueuedTimeAnnotation} > '${time}'`;\n }\n\n if (!result) {\n throw translate({\n condition: ErrorNameConditionMapper.ArgumentError,\n description: \"No starting position was set in the EventPosition.\",\n });\n }\n return result;\n}\n\n/**\n * @internal\n */\nexport function isLatestPosition(eventPosition: EventPosition): boolean {\n if (eventPosition.offset === \"@latest\") {\n return true;\n }\n\n return false;\n}\n\n/**\n * Gets the `EventPosition` corresponding to the location of the the first event present in the partition.\n * Pass this position to the `EventHubConsumerClient.subscribe()` method to begin receiving events from the\n * first event in the partition which has not expired due to the retention policy.\n */\nexport const earliestEventPosition: EventPosition = {\n offset: \"-1:-1\",\n};\n\n/**\n * Gets the `EventPosition` corresponding to the end of the partition.\n * Pass this position to the `EventHubConsumerClient.subscribe()` method to begin receiving events from the\n * event that is enqueued right after the method call.\n * @returns EventPosition\n */\nexport const latestEventPosition: EventPosition = {\n offset: \"@latest\",\n};\n\n/**\n * @internal\n */\nexport function validateEventPositions(\n position: EventPosition | { [partitionId: string]: EventPosition },\n): void {\n if (!isDefined(position)) {\n return;\n }\n\n const keys = Object.keys(position);\n\n if (!keys.length) {\n throw new TypeError(\n \"Invalid value for EventPosition found. Pass an object with either of offset, sequenceNumber or enqueuedOn properties set.\",\n );\n }\n\n if (isEventPosition(position)) {\n validateEventPosition(position);\n return;\n }\n\n const positions = position as { [partitionId: string]: EventPosition };\n for (let i = 0; i < keys.length; i++) {\n if (Object.prototype.hasOwnProperty.call(positions, keys[i])) {\n validateEventPosition(positions[keys[i]]);\n }\n }\n}\n\n/**\n * Determines whether a position is an EventPosition.\n * Does not validate that the position is allowed.\n * @internal\n */\nexport function isEventPosition(position: unknown): position is EventPosition {\n if (!position) {\n return false;\n }\n\n if (objectHasProperty(position, \"offset\") && isDefined(position.offset)) {\n return true;\n }\n\n if (objectHasProperty(position, \"sequenceNumber\") && isDefined(position.sequenceNumber)) {\n return true;\n }\n\n if (objectHasProperty(position, \"enqueuedOn\") && isDefined(position.enqueuedOn)) {\n return true;\n }\n\n return false;\n}\n\nfunction validateEventPosition(position: EventPosition): void {\n if (!isDefined(position)) {\n return;\n }\n const offsetPresent = isDefined(position.offset);\n const sequenceNumberPresent = isDefined(position.sequenceNumber);\n const enqueuedOnPresent = isDefined(position.enqueuedOn);\n\n if (\n (offsetPresent && sequenceNumberPresent) ||\n (offsetPresent && enqueuedOnPresent) ||\n (enqueuedOnPresent && sequenceNumberPresent)\n ) {\n throw new TypeError(\n \"Invalid value for EventPosition found. Set only one of offset, sequenceNumber or enqueuedOn properties.\",\n );\n }\n\n if (!offsetPresent && !enqueuedOnPresent && !sequenceNumberPresent) {\n throw new TypeError(\n \"Invalid value for EventPosition found. Pass an object with either of offset, sequenceNumber or enqueuedOn properties set.\",\n );\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventProcessor.js","sourceRoot":"","sources":["../../src/eventProcessor.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAc,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAiB,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAe,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAqJ7C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAsBzB;;;;;;;;;;;OAWG;IACH,YACU,cAAsB,EACtB,QAA2B,EAC3B,0BAAqD,EACrD,gBAAiC,EACzC,OAAkC;QAJ1B,mBAAc,GAAd,cAAc,CAAQ;QACtB,aAAQ,GAAR,QAAQ,CAAmB;Q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BAAqB;KACtB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortController, AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport { Checkpoint, PartitionProcessor } from \"./partitionProcessor\";\nimport { EventPosition, isEventPosition, latestEventPosition } from \"./eventPosition\";\nimport { PumpManager, PumpManagerImpl } from \"./pumpManager\";\nimport { logErrorStackTrace, logger } from \"./logger\";\nimport { CloseReason } from \"./models/public\";\nimport { CommonEventProcessorOptions } from \"./models/private\";\nimport { ConnectionContext } from \"./connectionContext\";\nimport { LoadBalancingStrategy } from \"./loadBalancerStrategies/loadBalancingStrategy\";\nimport { OperationOptions } from \"./util/operationOptions\";\nimport { SubscriptionEventHandlers } from \"./eventHubConsumerClientModels\";\nimport { delayWithoutThrow } from \"./util/delayWithoutThrow\";\nimport { getRandomName } from \"./util/utils\";\n\n/**\n * An interface representing the details on which instance of a `EventProcessor` owns processing\n * of a given partition from a consumer group of an Event Hub instance.\n *\n * **Note**: This is used internally by the `EventProcessor` and user never has to create it directly.\n */\nexport interface PartitionOwnership {\n /**\n * The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n */\n fullyQualifiedNamespace: string;\n /**\n * The event hub name\n */\n eventHubName: string;\n /**\n * The consumer group name\n */\n consumerGroup: string;\n /**\n * The identifier of the Event Hub partition.\n */\n partitionId: string;\n /**\n * The unique identifier of the event processor.\n */\n ownerId: string;\n /**\n * The last modified time.\n */\n lastModifiedTimeInMs?: number;\n /**\n * The unique identifier for the operation.\n */\n etag?: string;\n}\n\n/**\n * A checkpoint store stores and retrieves partition ownership information and checkpoint details\n * for each partition in a given consumer group of an event hub instance.\n *\n * Users are not meant to implement an `CheckpointStore`.\n * Users are expected to choose existing implementations of this interface, instantiate it, and pass\n * it to the `EventHubConsumerClient` class constructor when instantiating a client.\n * Users are not expected to use any of the methods on a checkpoint store, these are used internally by\n * the client.\n *\n * Implementations of `CheckpointStore` can be found on npm by searching for packages with the prefix &commat;azure/eventhub-checkpointstore-.\n */\nexport interface CheckpointStore {\n /**\n * Called to get the list of all existing partition ownership from the underlying data store. Could return empty\n * results if there are is no existing ownership information.\n *\n * @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net.\n * @param eventHubName - The event hub name.\n * @param consumerGroup - The consumer group name.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n * @returns A list of partition ownership details of all the partitions that have/had an owner.\n */\n listOwnership(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n options?: OperationOptions,\n ): Promise<PartitionOwnership[]>;\n /**\n * Called to claim ownership of a list of partitions. This will return the list of partitions that were owned\n * successfully.\n *\n * @param partitionOwnership - The list of partition ownership this instance is claiming to own.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n * @returns A list of partitions this instance successfully claimed ownership.\n */\n claimOwnership(\n partitionOwnership: PartitionOwnership[],\n options?: OperationOptions,\n ): Promise<PartitionOwnership[]>;\n\n /**\n * Updates the checkpoint in the data store for a partition.\n *\n * @param checkpoint - The checkpoint.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n */\n updateCheckpoint(checkpoint: Checkpoint, options?: OperationOptions): Promise<void>;\n\n /**\n * Lists all the checkpoints in a data store for a given namespace, eventhub and consumer group.\n *\n * @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net.\n * @param eventHubName - The event hub name.\n * @param consumerGroup - The consumer group name.\n * @param options - A set of options that can be specified to influence the behavior of this method.\n * - `abortSignal`: A signal used to request operation cancellation.\n * - `tracingOptions`: Options for configuring tracing.\n * @returns A list of checkpoints for a given namespace, eventhub, and consumer group.\n */\n listCheckpoints(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n options?: OperationOptions,\n ): Promise<Checkpoint[]>;\n}\n\n/**\n * A set of options to pass to the constructor of `EventProcessor`.\n * You can specify\n * - `maxBatchSize`: The max size of the batch of events passed each time to user code for processing.\n * - `maxWaitTimeInSeconds`: The maximum amount of time to wait to build up the requested message count before\n * passing the data to user code for processing. If not provided, it defaults to 60 seconds.\n *\n * Example usage with default values:\n * ```ts\n * {\n * maxBatchSize: 1,\n * maxWaitTimeInSeconds: 60,\n * }\n * ```\n * @internal\n */\nexport interface FullEventProcessorOptions extends CommonEventProcessorOptions {\n /**\n * An optional pump manager to use, rather than instantiating one internally\n * @internal\n */\n pumpManager?: PumpManager;\n /**\n * The amount of time between load balancing attempts.\n */\n loopIntervalInMs: number;\n /**\n * A specific partition to target.\n */\n processingTarget?: string;\n}\n\n/**\n * Event Processor based applications consist of one or more instances of EventProcessor which have been\n * configured to consume events from the same Event Hub and consumer group. They balance the\n * workload across different instances by distributing the partitions to be processed among themselves.\n * They also allow the user to track progress when events are processed using checkpoints.\n *\n * A checkpoint is meant to represent the last successfully processed event by the user from a particular\n * partition of a consumer group in an Event Hub instance.\n *\n * @internal\n */\nexport class EventProcessor {\n private _processorOptions: FullEventProcessorOptions;\n private _pumpManager: PumpManager;\n private _id: string;\n private _isRunning: boolean = false;\n private _loopTask?: PromiseLike<void>;\n private _abortController?: AbortController;\n /**\n * A specific partition to target.\n */\n private _processingTarget?: string;\n /**\n * Determines which partitions to claim as part of load balancing.\n */\n private _loadBalancingStrategy: LoadBalancingStrategy;\n /**\n * The amount of time between load balancing attempts.\n */\n private _loopIntervalInMs: number;\n private _eventHubName: string;\n private _fullyQualifiedNamespace: string;\n\n /**\n * @param consumerGroup - The name of the consumer group from which you want to process events.\n * @param eventHubClient - An instance of `EventHubClient` that was created for the Event Hub instance.\n * @param PartitionProcessorClass - A user-provided class that extends the `PartitionProcessor` class.\n * This class will be responsible for processing and checkpointing events.\n * @param checkpointStore - An instance of `CheckpointStore`. See &commat;azure/eventhubs-checkpointstore-blob for an implementation.\n * For production, choose an implementation that will store checkpoints and partition ownership details to a durable store.\n * @param options - A set of options to configure the Event Processor\n * - `maxBatchSize` : The max size of the batch of events passed each time to user code for processing.\n * - `maxWaitTimeInSeconds` : The maximum amount of time to wait to build up the requested message count before\n * passing the data to user code for processing. If not provided, it defaults to 60 seconds.\n */\n constructor(\n private _consumerGroup: string,\n private _context: ConnectionContext,\n private _subscriptionEventHandlers: SubscriptionEventHandlers,\n private _checkpointStore: CheckpointStore,\n options: FullEventProcessorOptions,\n ) {\n if (options.ownerId) {\n this._id = options.ownerId;\n logger.verbose(`Starting event processor with ID ${this._id}`);\n } else {\n this._id = getRandomName();\n logger.verbose(`Starting event processor with autogenerated ID ${this._id}`);\n }\n\n this._eventHubName = this._context.config.entityPath;\n this._fullyQualifiedNamespace = this._context.config.host;\n this._processorOptions = options;\n this._pumpManager =\n options.pumpManager || new PumpManagerImpl(this._id, this._processorOptions);\n this._processingTarget = options.processingTarget;\n this._loopIntervalInMs = options.loopIntervalInMs;\n this._loadBalancingStrategy = options.loadBalancingStrategy;\n }\n\n /**\n * The unique identifier for the EventProcessor.\n */\n get id(): string {\n return this._id;\n }\n\n private _createPartitionOwnershipRequest(\n partitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIdToClaim: string,\n ): PartitionOwnership {\n const previousPartitionOwnership = partitionOwnershipMap.get(partitionIdToClaim);\n const partitionOwnership: PartitionOwnership = {\n ownerId: this._id,\n partitionId: partitionIdToClaim,\n fullyQualifiedNamespace: this._fullyQualifiedNamespace,\n consumerGroup: this._consumerGroup,\n eventHubName: this._eventHubName,\n etag: previousPartitionOwnership ? previousPartitionOwnership.etag : undefined,\n };\n\n return partitionOwnership;\n }\n\n /*\n * Claim ownership of the given partition if it's available\n */\n private async _claimOwnership(\n ownershipRequest: PartitionOwnership,\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n if (abortSignal.aborted) {\n logger.verbose(\n `[${this._id}] Subscription was closed before claiming ownership of ${ownershipRequest.partitionId}.`,\n );\n return;\n }\n logger.info(\n `[${this._id}] Attempting to claim ownership of partition ${ownershipRequest.partitionId}.`,\n );\n try {\n const claimedOwnerships = await this._checkpointStore.claimOwnership([ownershipRequest]);\n\n // can happen if the partition was claimed out from underneath us - we shouldn't\n // attempt to spin up a processor.\n if (!claimedOwnerships.length) {\n return;\n }\n\n logger.info(\n `[${this._id}] Successfully claimed ownership of partition ${ownershipRequest.partitionId}.`,\n );\n\n await this._startPump(ownershipRequest.partitionId, abortSignal);\n } catch (err: any) {\n logger.warning(\n `[${this._id}] Failed to claim ownership of partition ${ownershipRequest.partitionId}`,\n );\n logErrorStackTrace(err);\n await this._handleSubscriptionError(err);\n }\n }\n\n private async _startPump(partitionId: string, abortSignal: AbortSignalLike): Promise<void> {\n if (abortSignal.aborted) {\n logger.verbose(\n `[${this._id}] The subscription was closed before starting to read from ${partitionId}.`,\n );\n return;\n }\n\n if (this._pumpManager.isReceivingFromPartition(partitionId)) {\n logger.verbose(\n `[${this._id}] There is already an active partitionPump for partition \"${partitionId}\", skipping pump creation.`,\n );\n return;\n }\n\n logger.verbose(\n `[${this._id}] [${partitionId}] Calling user-provided PartitionProcessorFactory.`,\n );\n\n const partitionProcessor = new PartitionProcessor(\n this._subscriptionEventHandlers,\n this._checkpointStore,\n {\n fullyQualifiedNamespace: this._fullyQualifiedNamespace,\n eventHubName: this._eventHubName,\n consumerGroup: this._consumerGroup,\n partitionId: partitionId,\n eventProcessorId: this._id,\n },\n );\n\n const eventPosition = await this._getStartingPosition(partitionId);\n await this._pumpManager.createPump(\n eventPosition,\n this._context,\n partitionProcessor,\n abortSignal,\n );\n\n logger.verbose(`[${this._id}] PartitionPump created successfully.`);\n }\n\n private async _getStartingPosition(partitionIdToClaim: string): Promise<EventPosition> {\n const availableCheckpoints = await this._checkpointStore.listCheckpoints(\n this._fullyQualifiedNamespace,\n this._eventHubName,\n this._consumerGroup,\n );\n\n const validCheckpoints = availableCheckpoints.filter(\n (chk) => chk.partitionId === partitionIdToClaim,\n );\n\n if (validCheckpoints.length > 0) {\n return { offset: validCheckpoints[0].offset };\n }\n\n logger.verbose(\n `No checkpoint found for partition ${partitionIdToClaim}. Looking for fallback.`,\n );\n return getStartPosition(partitionIdToClaim, this._processorOptions.startPosition);\n }\n\n private async _runLoopForSinglePartition(\n partitionId: string,\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n while (!abortSignal.aborted) {\n try {\n await this._startPump(partitionId, abortSignal);\n } catch (err: any) {\n logger.warning(\n `[${this._id}] An error occured within the EventProcessor loop: ${err?.name}: ${err?.message}`,\n );\n logErrorStackTrace(err);\n await this._handleSubscriptionError(err);\n } finally {\n // sleep for some time after which we can attempt to create a pump again.\n logger.verbose(\n `[${this._id}] Pausing the EventProcessor loop for ${this._loopIntervalInMs} ms.`,\n );\n // swallow errors from delay since it's fine for delay to exit early\n await delayWithoutThrow(this._loopIntervalInMs, abortSignal);\n }\n }\n this._isRunning = false;\n }\n\n /**\n * Every loop to this method will result in this EventProcessor owning at most one new partition.\n *\n * The load is considered balanced when no active EventProcessor owns 2 partitions more than any other active\n * EventProcessor. Given that each invocation to this method results in ownership claim of at most one partition,\n * this algorithm converges gradually towards a steady state.\n *\n * When a new partition is claimed, this method is also responsible for starting a partition pump that creates an\n * EventHubConsumer for processing events from that partition.\n */\n private async _runLoopWithLoadBalancing(\n loadBalancingStrategy: LoadBalancingStrategy,\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n let cancelLoopResolver;\n // This provides a mechanism for exiting the loop early\n // if the subscription has had `close` called.\n const cancelLoopPromise = new Promise<void>((resolve) => {\n cancelLoopResolver = resolve;\n if (abortSignal.aborted) {\n resolve();\n return;\n }\n\n abortSignal.addEventListener(\"abort\", resolve);\n });\n\n // Periodically check if any partitions need to be claimed and claim them.\n while (!abortSignal.aborted) {\n const iterationStartTimeInMs = Date.now();\n try {\n const { partitionIds } = await this._context.managementSession!.getEventHubProperties({\n abortSignal: abortSignal,\n });\n await this._performLoadBalancing(loadBalancingStrategy, partitionIds, abortSignal);\n } catch (err: any) {\n logger.warning(\n `[${this._id}] An error occurred within the EventProcessor loop: ${err?.name}: ${err?.message}`,\n );\n logErrorStackTrace(err);\n // Protect against the scenario where the user awaits on subscription.close() from inside processError.\n await Promise.race([this._handleSubscriptionError(err), cancelLoopPromise]);\n } finally {\n // Sleep for some time, then continue the loop.\n const iterationDeltaInMs = Date.now() - iterationStartTimeInMs;\n const delayDurationInMs = Math.max(this._loopIntervalInMs - iterationDeltaInMs, 0);\n logger.verbose(\n `[${this._id}] Pausing the EventProcessor loop for ${delayDurationInMs} ms.`,\n );\n // Swallow the error since it's fine to exit early from the delay.\n await delayWithoutThrow(delayDurationInMs, abortSignal);\n }\n }\n\n if (cancelLoopResolver) {\n abortSignal.removeEventListener(\"abort\", cancelLoopResolver);\n }\n this._isRunning = false;\n }\n\n private async _performLoadBalancing(\n loadBalancingStrategy: LoadBalancingStrategy,\n partitionIds: string[],\n abortSignal: AbortSignalLike,\n ): Promise<void> {\n if (abortSignal.aborted) throw new AbortError(\"The operation was aborted.\");\n\n // Retrieve current partition ownership details from the datastore.\n const partitionOwnership = await this._checkpointStore.listOwnership(\n this._fullyQualifiedNamespace,\n this._eventHubName,\n this._consumerGroup,\n );\n\n if (abortSignal.aborted) throw new AbortError(\"The operation was aborted.\");\n\n const { partitionOwnershipMap, partitionsToClaim } = computePartitionsToClaim({\n id: this._id,\n isReceivingFromPartition: (partitionId: string) =>\n this._pumpManager.isReceivingFromPartition(partitionId),\n loadBalancingStrategy,\n partitionIds,\n partitionOwnership,\n });\n\n for (const partitionToClaim of partitionsToClaim) {\n const partitionOwnershipRequest = this._createPartitionOwnershipRequest(\n partitionOwnershipMap,\n partitionToClaim,\n );\n\n await this._claimOwnership(partitionOwnershipRequest, abortSignal);\n }\n }\n\n /**\n * This is called when there are errors that are not specific to a partition (ex: load balancing)\n */\n private async _handleSubscriptionError(err: Error): Promise<void> {\n // filter out any internal \"expected\" errors\n if (err.name === \"AbortError\") {\n return;\n }\n\n if (this._subscriptionEventHandlers.processError) {\n try {\n await this._subscriptionEventHandlers.processError(err, {\n fullyQualifiedNamespace: this._fullyQualifiedNamespace,\n eventHubName: this._eventHubName,\n consumerGroup: this._consumerGroup,\n partitionId: \"\",\n updateCheckpoint: async () => {\n /* no-op */\n },\n });\n } catch (errorFromUser: any) {\n logger.verbose(\n `[${this._id}] An error was thrown from the user's processError handler: ${errorFromUser}`,\n );\n }\n }\n }\n\n /**\n * Starts the `EventProcessor`. Based on the number of instances of `EventProcessor` that are running for the\n * same consumer group, the partitions are distributed among these instances to process events.\n *\n * For each partition, the user provided `PartitionProcessor` is instantiated.\n *\n * Subsequent calls to start will be ignored if this event processor is already running.\n * Calling `start()` after `stop()` is called will restart this event processor.\n *\n */\n start(): void {\n if (this._isRunning) {\n logger.verbose(`[${this._id}] Attempted to start an already running EventProcessor.`);\n return;\n }\n\n this._isRunning = true;\n this._abortController = new AbortController();\n logger.verbose(`[${this._id}] Starting an EventProcessor.`);\n\n if (this._processingTarget) {\n logger.verbose(`[${this._id}] Single partition target: ${this._processingTarget}`);\n this._loopTask = this._runLoopForSinglePartition(\n this._processingTarget,\n this._abortController.signal,\n );\n } else {\n logger.verbose(`[${this._id}] Multiple partitions, using load balancer`);\n this._loopTask = this._runLoopWithLoadBalancing(\n this._loadBalancingStrategy,\n this._abortController.signal,\n );\n }\n }\n\n isRunning(): boolean {\n return this._isRunning;\n }\n\n /**\n * Stops processing events for all partitions owned by this event processor.\n * All `PartitionProcessor` will be shutdown and any open resources will be closed.\n *\n * Subsequent calls to stop will be ignored if the event processor is not running.\n *\n */\n async stop(): Promise<void> {\n logger.verbose(`[${this._id}] Stopping an EventProcessor.`);\n if (this._abortController) {\n // cancel the event processor loop\n this._abortController.abort();\n }\n\n try {\n // remove all existing pumps\n await this._pumpManager.removeAllPumps(CloseReason.Shutdown);\n\n // waits for the event processor loop to complete\n // will complete immediately if _loopTask is undefined\n if (this._loopTask) {\n await this._loopTask;\n }\n } catch (err: any) {\n logger.verbose(`[${this._id}] An error occured while stopping the EventProcessor: ${err}`);\n } finally {\n logger.verbose(`[${this._id}] EventProcessor stopped.`);\n }\n\n if (this._processingTarget) {\n logger.verbose(`[${this._id}] No partitions owned, skipping abandoning.`);\n } else {\n await this.abandonPartitionOwnerships();\n }\n }\n\n private async abandonPartitionOwnerships(): Promise<PartitionOwnership[]> {\n logger.verbose(`[${this._id}] Abandoning owned partitions`);\n const allOwnerships = await this._checkpointStore.listOwnership(\n this._fullyQualifiedNamespace,\n this._eventHubName,\n this._consumerGroup,\n );\n const ourOwnerships = allOwnerships.filter((ownership) => ownership.ownerId === this._id);\n // unclaim any partitions that we currently own\n for (const ownership of ourOwnerships) {\n ownership.ownerId = \"\";\n }\n return this._checkpointStore.claimOwnership(ourOwnerships);\n }\n}\n\nfunction isAbandoned(ownership: PartitionOwnership): boolean {\n return ownership.ownerId === \"\";\n}\n\nfunction getStartPosition(\n partitionIdToClaim: string,\n startPositions?: EventPosition | { [partitionId: string]: EventPosition },\n): EventPosition {\n if (startPositions == null) {\n return latestEventPosition;\n }\n\n if (isEventPosition(startPositions)) {\n return startPositions;\n }\n\n const startPosition = (startPositions as { [partitionId: string]: EventPosition })[\n partitionIdToClaim\n ];\n\n if (startPosition == null) {\n return latestEventPosition;\n }\n\n return startPosition;\n}\n\nfunction computePartitionsToClaim(inputs: {\n partitionOwnership: PartitionOwnership[];\n id: string;\n isReceivingFromPartition: (id: string) => boolean;\n loadBalancingStrategy: LoadBalancingStrategy;\n partitionIds: string[];\n}): {\n partitionsToClaim: Set<string>;\n partitionOwnershipMap: Map<string, PartitionOwnership>;\n} {\n const { partitionOwnership, id, isReceivingFromPartition, loadBalancingStrategy, partitionIds } =\n inputs;\n\n const partitionOwnershipMap = new Map<string, PartitionOwnership>();\n const nonAbandonedPartitionOwnershipMap = new Map<string, PartitionOwnership>();\n const partitionsToRenew: string[] = [];\n\n // Separate abandoned ownerships from claimed ownerships.\n // We only want to pass active partition ownerships to the\n // load balancer, but we need to hold onto the abandoned\n // partition ownerships because we need the etag to claim them.\n for (const ownership of partitionOwnership) {\n partitionOwnershipMap.set(ownership.partitionId, ownership);\n if (!isAbandoned(ownership)) {\n nonAbandonedPartitionOwnershipMap.set(ownership.partitionId, ownership);\n }\n if (ownership.ownerId === id && isReceivingFromPartition(ownership.partitionId)) {\n partitionsToRenew.push(ownership.partitionId);\n }\n }\n\n // Pass the list of all the partition ids and the collection of claimed partition ownerships\n // to the load balance strategy.\n // The load balancing strategy only needs to know the full list of partitions,\n // and which of those are currently claimed.\n // Since abandoned partitions are no longer claimed, we exclude them.\n const partitionsToClaim = loadBalancingStrategy.getPartitionsToClaim(\n id,\n nonAbandonedPartitionOwnershipMap,\n partitionIds,\n );\n partitionsToClaim.push(...partitionsToRenew);\n\n return {\n partitionsToClaim: new Set(partitionsToClaim),\n partitionOwnershipMap,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventhubConnectionConfig.js","sourceRoot":"","sources":["../../src/eventhubConnectionConfig.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,2BAA2B;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA4DrD;;;;;GAKG;AACH,4GAA4G;AAC5G,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC;;;;;;;;OAQG;IACH,MAAM,CAAC,gBAAwB,EAAE,IAAa;QAC5C,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,IAAI,SAAS,CACjB,qDAAqD,gBAAgB,KAAK;gBACxE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,QAAQ,GAAG,MAAM,CAAC,UAAU,mBAAmB,aAAa,GAAG;gBACzE,cAAc,WAAW,EAAE,CAC5B,CAAC;QACJ,CAAC,CAAC;QAED,MAAmC,CAAC,kBAAkB,GAAG,CACxD,WAA4B,EAC5B,aAAsB,EACtB,EAAE;YACF,IAAI,CAAC,aAAa;gBAAE,aAAa,GAAG,UAAU,CAAC;YAC/C,OAAO,GAAG,MAAM,CAAC,UAAU,mBAAmB,aAAa,eAAe,WAAW,EAAE,CAAC;QAC1F,CAAC,CAAC;QACF,OAAO,MAAkC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,wBAAwB,CAAC,MAAgC,EAAE,qBAA6B;QACtF,6EAA6E;QAC7E,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC;QAClC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC;QAChE,wFAAwF;QACxF,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;QACvB,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,MAAgC;QACvC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable eqeqeq */\n\nimport { ConnectionConfig } from \"@azure/core-amqp\";\nimport { parseEndpoint } from \"./util/parseEndpoint\";\n\n/**\n * Describes the connection config object that is created after parsing an EventHub connection\n * string. It also provides some convenience methods for getting the address and audience for\n * different entities.\n * @internal\n */\nexport interface EventHubConnectionConfig extends ConnectionConfig {\n /**\n * The name/path of the entity (event hub name) to which the\n * connection needs to happen.\n */\n entityPath: string;\n /**\n * Provides the EventHub Sender address in one of the following forms based on the input:\n * - `\"<hubName>\"`\n * - `\"<hubName>/Partitions/<partitionId>\"`\n *\n * @param partitionId - The partitionId in the EventHub to which messages will be sent.\n */\n getSenderAddress(partitionId?: string | number): string;\n /**\n * Provides the EventHub Sender audience in one of the following forms based on the input:\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>/Partitions/<partitionId>\"`\n *\n * @param partitionId - The partitionId in the EventHub to which messages will be sent.\n */\n getSenderAudience(partitionId?: string | number): string;\n /**\n * Provides the EventHub Receiver address:\n * - `\"<hub-name>/ConsumerGroups/<consumer-group-name>/Partitions/<partition-id>\"`\n *\n * @param partitionId - The partitionId in the EventHub from which messages will be received.\n * @param consumergroup - The consumergroup in the EventHub from which the messages will\n * be received. Default: `$default`.\n */\n getReceiverAddress(partitionId: string | number, consumergroup?: string): string;\n /**\n * Provides the EventHub Receiver audience.\n * - `\"sb://<your-namespace>.servicebus.windows.net/<hub-name>/ConsumerGroups/<consumer-group-name>/Partitions/<partition-id>\"`\n *\n * @param partitionId - The partitionId in the EventHub from which messages will be received.\n * @param consumergroup - The consumergroup in the EventHub from which the messages will\n * be received. Default: `$default`.\n */\n getReceiverAudience(partitionId: string | number, consumergroup?: string): string;\n /**\n * Provides the EventHub Management address.\n * - `\"<hub-name>/$management\"`\n */\n getManagementAddress(): string;\n /**\n * Provides the EventHub Management audience.\n * - `\"sb://<your-namespace>.servicebus.windows.net/<hub-name>/$management\"`\n */\n getManagementAudience(): string;\n}\n\n/**\n * Describes the connection config object that is created after parsing an EventHub connection\n * string. It also provides some convenience methods for getting the address and audience for\n * different entities.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- renaming constant would be a breaking change.\nexport const EventHubConnectionConfig = {\n /**\n * Creates the connection config.\n * @param connectionString - The connection string for a given service like\n * EventHub/ServiceBus.\n * @param path - The name/path of the entity (hub name) to which the\n * connection needs to happen. This will override the EntityPath in the connectionString\n * if present.\n * @returns EventHubConnectionConfig\n */\n create(connectionString: string, path?: string): EventHubConnectionConfig {\n const config = ConnectionConfig.create(connectionString, path);\n if (!config.entityPath) {\n throw new TypeError(\n `Either provide \"path\" or the \"connectionString\": \"${connectionString}\", ` +\n `must contain EntityPath=\"<path-to-the-entity>\".`,\n );\n }\n return EventHubConnectionConfig.createFromConnectionConfig(config);\n },\n\n /**\n * Creates an EventHubConnectionConfig from the provided base ConnectionConfig.\n * @param config - The base connection config from which the EventHubConnectionConfig needs to be\n * created.\n * @returns EventHubConnectionConfig\n */\n createFromConnectionConfig(config: ConnectionConfig): EventHubConnectionConfig {\n ConnectionConfig.validate(config, { isEntityPathRequired: true });\n\n (config as EventHubConnectionConfig).getManagementAudience = () => {\n return `${config.endpoint}${config.entityPath}/$management`;\n };\n (config as EventHubConnectionConfig).getManagementAddress = () => {\n return `${config.entityPath}/$management`;\n };\n\n (config as EventHubConnectionConfig).getSenderAudience = (partitionId?: string | number) => {\n if (partitionId != undefined) {\n return `${config.endpoint}${config.entityPath}/Partitions/${partitionId}`;\n } else {\n return `${config.endpoint}${config.entityPath}`;\n }\n };\n\n (config as EventHubConnectionConfig).getSenderAddress = (partitionId?: string | number) => {\n if (partitionId != undefined) {\n return `${config.entityPath}/Partitions/${partitionId}`;\n } else {\n return `${config.entityPath}`;\n }\n };\n\n (config as EventHubConnectionConfig).getReceiverAudience = (\n partitionId: string | number,\n consumergroup?: string,\n ) => {\n if (!consumergroup) consumergroup = \"$default\";\n return (\n `${config.endpoint}${config.entityPath}/ConsumerGroups/${consumergroup}/` +\n `Partitions/${partitionId}`\n );\n };\n\n (config as EventHubConnectionConfig).getReceiverAddress = (\n partitionId: string | number,\n consumergroup?: string,\n ) => {\n if (!consumergroup) consumergroup = \"$default\";\n return `${config.entityPath}/ConsumerGroups/${consumergroup}/Partitions/${partitionId}`;\n };\n return config as EventHubConnectionConfig;\n },\n\n /**\n * Updates the provided EventHubConnectionConfig to use the custom endpoint address.\n * @param config - An existing connection configuration to be updated.\n * @param customEndpointAddress - The custom endpoint address to use.\n */\n setCustomEndpointAddress(config: EventHubConnectionConfig, customEndpointAddress: string): void {\n // The amqpHostname should match the host prior to using the custom endpoint.\n config.amqpHostname = config.host;\n const { hostname, port } = parseEndpoint(customEndpointAddress);\n // Since we specify the port separately, set host to the customEndpointAddress hostname.\n config.host = hostname;\n if (port) {\n config.port = parseInt(port, 10);\n }\n },\n\n /**\n * Validates the properties of connection config.\n * @param config - The connection config to be validated.\n * @returns void\n */\n validate(config: EventHubConnectionConfig): void {\n return ConnectionConfig.validate(config, { isEntityPathRequired: true });\n },\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"awaitableQueue.js","sourceRoot":"","sources":["../../../src/impl/awaitableQueue.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAgB,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IAKzB;QAFiB,eAAU,GAA8B,EAAE,CAAC;QAG1D,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAsB;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QAED,OAAO,sBAAsB,CAAI,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,kCACtE,OAAO,KACV,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAC/C,CAAC;IACL,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,IAAO;QACjB,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,IAAO;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,KAAK,CAAC;QACf,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortOptions, createAbortablePromise } from \"@azure/core-util\";\n\n/**\n * `AwaitableQueue` stores items in the order that they are received.\n *\n * This differs from ordinary Queues in that `shift` returns a Promise for a value.\n * This allows a consumer of the queue to request an item that the queue does not yet have.\n *\n * @internal\n */\nexport class AwaitableQueue<T> {\n private readonly _items: T[];\n\n private readonly _resolvers: Array<(value: T) => void> = [];\n\n constructor() {\n this._items = [];\n }\n\n public size(): number {\n return this._items.length;\n }\n\n /**\n * Returns a Promise that will resolve with the next item in the queue.\n */\n public shift(options?: AbortOptions): Promise<T> {\n const item = this._items.shift();\n if (typeof item !== \"undefined\") {\n return Promise.resolve(item);\n }\n\n return createAbortablePromise<T>((resolve) => this._resolvers.push(resolve), {\n ...options,\n cleanupBeforeAbort: () => this._resolvers.pop(),\n });\n }\n\n /**\n * Appends new item to the queue.\n */\n public push(item: T): void {\n if (!this._resolveNextItem(item)) {\n this._items.push(item);\n }\n }\n\n private _resolveNextItem(item: T) {\n const resolver = this._resolvers.shift();\n if (!resolver) {\n return false;\n }\n\n resolver(item);\n return true;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"partitionAssigner.js","sourceRoot":"","sources":["../../../src/impl/part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,GAAG,CAAC,CAAC;QAEtE,MAAM,kBAAkB,GACtB,sBAAsB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC;QAE1E,IAAI,CAAC,6BAA6B,GAAG,kBAAkB,CAAC;QACxD,OAAO,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAC9C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isDefined } from \"@azure/core-util\";\nimport { mapPartitionKeyToId } from \"./partitionKeyToIdMapper\";\n\n/**\n * @internal\n * Assigns a partition based on the partition ids it knows about and an optional partition id or partition key.\n */\nexport class PartitionAssigner {\n private _partitions: string[] = [];\n\n private _lastRoundRobinPartitionIndex: number = -1;\n\n /**\n * Set the partition ids that can be used when assigning a partition.\n * @param partitionIds - All valid partition ids.\n */\n public setPartitionIds(partitionIds: string[]): void {\n this._partitions = partitionIds;\n }\n\n /**\n * Returns a partitionId from the list of partition ids set via `setPartitionIds`.\n *\n * If a partitionId is specified, then that will be returned directly.\n * If a partitionKey is specified, then a partitionId will be calculated based on the partitionKey.\n * Specifying both partitionId and partitionKey results in an error.\n *\n * If neither partitionId nor partitionKey are specified, then a partitionId will be selected\n * based on a round-robin approach.\n */\n assignPartition({\n partitionId,\n partitionKey,\n }: {\n partitionId?: string;\n partitionKey?: string;\n }): string {\n if (isDefined(partitionId) && isDefined(partitionKey)) {\n throw new Error(\n `The partitionId (${partitionId}) and partitionKey (${partitionKey}) cannot both be specified.`,\n );\n }\n\n if (!this._partitions.length) {\n throw new Error(`Unable to determine partitionIds, can't assign partitionId.`);\n }\n\n if (isDefined(partitionId) && this._partitions.includes(partitionId)) {\n return partitionId;\n }\n\n if (isDefined(partitionKey)) {\n return mapPartitionKeyToId(partitionKey, this._partitions.length).toString();\n }\n\n return this._assignRoundRobinPartition();\n }\n\n private _assignRoundRobinPartition(): string {\n const maxPartitionIndex = this._partitions.length - 1;\n const proposedPartitionIndex = this._lastRoundRobinPartitionIndex + 1;\n\n const nextPartitionIndex =\n proposedPartitionIndex > maxPartitionIndex ? 0 : proposedPartitionIndex;\n\n this._lastRoundRobinPartitionIndex = nextPartitionIndex;\n return this._partitions[nextPartitionIndex];\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"inMemoryCheckpointStore.js","sourceRoot":"","sources":["../../src/inMemoryCheckpointStore.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,uBAAuB;IAApC;QACU,2BAAsB,GAAoC,IAAI,GAAG,EAAE,CAAC;QACpE,0BAAqB,GAAyC,IAAI,GAAG,EAAE,CAAC;IA6GlF,CAAC;IA3GC;;;;;;;;;OASG;IACH,KAAK,CAAC,aAAa,CACjB,wBAAgC,EAChC,aAAqB,EACrB,cAAsB;QAEtB,MAAM,UAAU,GAAG,EAAE,CAAC;QAEtB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,CAAC;YACzD,UAAU,CAAC,IAAI,mBAAM,KAAK,EAAG,CAAC;QAChC,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAAC,kBAAwC;QAC3D,MAAM,iBAAiB,GAAG,EAAE,CAAC;QAE7B,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;YAC3C,IACE,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC;gBACvD,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAE,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAC/E,CAAC;gBACD,MAAM,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AAU,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,uBAA+B,EAC/B,YAAoB,EACpB,aAAqB;QAErB,MAAM,GAAG,GAAG,GAAG,uBAAuB,IAAI,YAAY,IAAI,aAAa,EAAE,CAAC;QAE1E,MAAM,YAAY,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEzD,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,WAAW,GAAG,EAAE,CAAC;QAEvB,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,WAAW,CAAC,IAAI,mBAAM,KAAK,EAAG,CAAC;QACjC,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CheckpointStore, PartitionOwnership } from \"./eventProcessor\";\nimport { Checkpoint } from \"./partitionProcessor\";\nimport { throwTypeErrorIfParameterMissing } from \"./util/error\";\nimport { getRandomName } from \"./util/utils\";\n\n/**\n * The `EventProcessor` relies on a `CheckpointStore` to store checkpoints and handle partition\n * ownerships. `InMemoryCheckpointStore` is simple partition manager that stores checkpoints and\n * partition ownerships in memory of your program.\n *\n * You can use the `InMemoryCheckpointStore` to get started with using the `EventProcessor`.\n * But in production, you should choose an implementation of the `CheckpointStore` interface that will\n * store the checkpoints and partition ownerships to a durable store instead.\n *\n * @internal\n */\nexport class InMemoryCheckpointStore implements CheckpointStore {\n private _partitionOwnershipMap: Map<string, PartitionOwnership> = new Map();\n private _committedCheckpoints: Map<string, Map<string, Checkpoint>> = new Map();\n\n /**\n * Get the list of all existing partition ownership from the underlying data store. Could return empty\n * results if there are is no existing ownership information.\n *\n * @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net.\n * @param eventHubName - The event hub name.\n * @param consumerGroup - The consumer group name.\n * @returns Partition ownership details of all the partitions that have/had an owner..\n */\n async listOwnership(\n _fullyQualifiedNamespace: string,\n _eventHubName: string,\n _consumerGroup: string,\n ): Promise<PartitionOwnership[]> {\n const ownerships = [];\n\n for (const value of this._partitionOwnershipMap.values()) {\n ownerships.push({ ...value });\n }\n\n return ownerships;\n }\n\n /**\n * Claim ownership of a list of partitions. This will return the list of partitions that were owned\n * successfully.\n *\n * @param partitionOwnership - The list of partition ownership this instance is claiming to own.\n * @returns A list partitions this instance successfully claimed ownership.\n */\n async claimOwnership(partitionOwnership: PartitionOwnership[]): Promise<PartitionOwnership[]> {\n const claimedOwnerships = [];\n\n for (const ownership of partitionOwnership) {\n if (\n !this._partitionOwnershipMap.has(ownership.partitionId) ||\n this._partitionOwnershipMap.get(ownership.partitionId)!.etag === ownership.etag\n ) {\n const date = new Date();\n\n const newOwnership = {\n ...ownership,\n etag: getRandomName(),\n lastModifiedTimeInMs: date.getTime(),\n };\n\n this._partitionOwnershipMap.set(newOwnership.partitionId, newOwnership);\n claimedOwnerships.push(newOwnership);\n }\n }\n return claimedOwnerships;\n }\n\n /**\n * Updates the checkpoint in the data store for a partition.\n *\n * @param checkpoint - The checkpoint.\n */\n async updateCheckpoint(checkpoint: Checkpoint): Promise<void> {\n throwTypeErrorIfParameterMissing(\n \"\",\n \"updateCheckpoint\",\n \"sequenceNumber\",\n checkpoint.sequenceNumber,\n );\n throwTypeErrorIfParameterMissing(\"\", \"updateCheckpoint\", \"offset\", checkpoint.offset);\n\n checkpoint = { ...checkpoint };\n\n const partitionOwnership = this._partitionOwnershipMap.get(checkpoint.partitionId);\n if (partitionOwnership) {\n partitionOwnership.etag = getRandomName();\n\n const key = `${checkpoint.fullyQualifiedNamespace}:${checkpoint.eventHubName}:${checkpoint.consumerGroup}`;\n let partitionMap = this._committedCheckpoints.get(key);\n\n if (partitionMap == null) {\n partitionMap = new Map();\n this._committedCheckpoints.set(key, partitionMap);\n }\n\n partitionMap.set(checkpoint.partitionId, checkpoint);\n }\n }\n\n async listCheckpoints(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n ): Promise<Checkpoint[]> {\n const key = `${fullyQualifiedNamespace}:${eventHubName}:${consumerGroup}`;\n\n const partitionMap = this._committedCheckpoints.get(key);\n\n if (partitionMap == null) {\n return [];\n }\n\n const checkpoints = [];\n\n for (const value of partitionMap.values()) {\n checkpoints.push({ ...value });\n }\n\n return checkpoints;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAkBlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAEL,8BAA8B,GAM/B,MAAM,kCAAkC,CAAC;AAW1C,OAAO,EAAiB,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAK5F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAgB,SAAS,EAAoB,MAAM,kBAAkB,CAAC;AAE7F,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,6BAA6B,GAE9B,MAAM,8BAA8B,CAAC;AAEtC,cAAc,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/// <reference lib=\"esnext.asynciterable\" />\n\nexport { EventData, ReceivedEventData } from \"./eventData\";\nexport { WebSocketImpl } from \"rhea-promise\";\nexport { LastEnqueuedEventProperties } from \"./partitionReceiver\";\nexport { OperationOptions } from \"./util/operationOptions\";\nexport {\n EventHubClientOptions,\n EventHubConsumerClientOptions,\n LoadBalancingOptions,\n SendBatchOptions,\n CreateBatchOptions,\n GetPartitionIdsOptions,\n GetPartitionPropertiesOptions,\n GetEventHubPropertiesOptions,\n} from \"./models/public\";\nexport { EventHubConsumerClient } from \"./eventHubConsumerClient\";\nexport { EventHubProducerClient } from \"./eventHubProducerClient\";\nexport {\n BufferedCloseOptions,\n EventHubBufferedProducerClient,\n EventHubBufferedProducerClientOptions,\n EnqueueEventOptions,\n BufferedFlushOptions,\n OnSendEventsErrorContext,\n OnSendEventsSuccessContext,\n} from \"./eventHubBufferedProducerClient\";\nexport {\n SubscribeOptions,\n Subscription,\n SubscriptionEventHandlers,\n PartitionContext,\n ProcessErrorHandler,\n ProcessInitializeHandler,\n ProcessCloseHandler,\n ProcessEventsHandler,\n} from \"./eventHubConsumerClientModels\";\nexport { EventPosition, latestEventPosition, earliestEventPosition } from \"./eventPosition\";\nexport { PartitionProperties, EventHubProperties } from \"./managementClient\";\nexport { EventDataBatch, TryAddOptions } from \"./eventDataBatch\";\nexport { Checkpoint } from \"./partitionProcessor\";\nexport { CheckpointStore, PartitionOwnership } from \"./eventProcessor\";\nexport { CloseReason } from \"./models/public\";\nexport { MessagingError, RetryOptions, RetryMode, WebSocketOptions } from \"@azure/core-amqp\";\nexport { TokenCredential } from \"@azure/core-auth\";\nexport { logger } from \"./logger\";\nexport {\n parseEventHubConnectionString,\n EventHubConnectionStringProperties,\n} from \"./util/connectionStringUtils\";\n\nexport * from \"./eventDataAdapter\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"balancedStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/balancedStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAyB,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGzF;;;;;;;;GAQG;AACH,MAAM,OAAO,6BAA6B;IACxC;;;;OAIG;IACH,YAA6B,yCAAiD;QAAjD,8CAAyC,GAAzC,yCAAyC,CAAQ;IAAG,CAAC;IAElF;;;;;;;OAOG;IACI,oBAAoB,CACzB,UAAkB,EAClB,4BAA6D,EAC7D,YAAsB;QAEtB,MAAM,mBAAmB,GAAG,uBAAuB,CACjD,UAAU,EACV,4BAA4B,EAC5B,YAAY,EACZ,IAAI,CAAC,yCAAyC,CAC/C,CAAC;QAEF,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAChC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC3E,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LoadBalancingStrategy, listAvailablePartitions } from \"./loadBalancingStrategy\";\nimport { PartitionOwnership } from \"../eventProcessor\";\n\n/**\n * The BalancedLoadBalancerStrategy is meant to be used when the user\n * wants to reach a load balanced state with less partition 'thrashing'.\n *\n * Partition thrashing - where a partition changes owners - is minimized\n * by only returning a single partition to claim at a time.\n * This minimizes the number of times a partition should need to be stolen.\n * @internal\n */\nexport class BalancedLoadBalancingStrategy implements LoadBalancingStrategy {\n /**\n * Creates an instance of BalancedLoadBalancingStrategy.\n *\n * @param _partitionOwnershipExpirationIntervalInMs - The length of time a partition claim is valid.\n */\n constructor(private readonly _partitionOwnershipExpirationIntervalInMs: number) {}\n\n /**\n * Implements load balancing by taking into account current ownership and\n * the full set of partitions in the Event Hub.\n * @param ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n public getPartitionsToClaim(\n ourOwnerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[] {\n const claimablePartitions = listAvailablePartitions(\n ourOwnerId,\n claimedPartitionOwnershipMap,\n partitionIds,\n this._partitionOwnershipExpirationIntervalInMs,\n );\n\n if (!claimablePartitions.length) {\n return [];\n }\n\n const randomIndex = Math.floor(Math.random() * claimablePartitions.length);\n return [claimablePartitions[randomIndex]];\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"greedyStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/greedyStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAyB,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGzF;;GAEG;AACH,MAAM,OAAO,2BAA2B;IACtC;;;;OAIG;IACH,YAA6B,yCAAiD;QAAjD,8CAAyC,GAAzC,yCAAyC,CAAQ;IAAG,CAAC;IAElF;;;;;;;OAOG;IACI,oBAAoB,CACzB,UAAkB,EAClB,4BAA6D,EAC7D,YAAsB;QAEtB,OAAO,uBAAuB,CAC5B,UAAU,EACV,4BAA4B,EAC5B,YAAY,EACZ,IAAI,CAAC,yCAAyC,CAC/C,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LoadBalancingStrategy, listAvailablePartitions } from \"./loadBalancingStrategy\";\nimport { PartitionOwnership } from \"../eventProcessor\";\n\n/**\n * @internal\n */\nexport class GreedyLoadBalancingStrategy implements LoadBalancingStrategy {\n /**\n * Creates an instance of GreedyLoadBalancingStrategy.\n *\n * @param _partitionOwnershipExpirationIntervalInMs - The length of time a partition claim is valid.\n */\n constructor(private readonly _partitionOwnershipExpirationIntervalInMs: number) {}\n\n /**\n * Implements load balancing by taking into account current ownership and\n * the new set of partitions to add.\n * @param ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n public getPartitionsToClaim(\n ourOwnerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[] {\n return listAvailablePartitions(\n ourOwnerId,\n claimedPartitionOwnershipMap,\n partitionIds,\n this._partitionOwnershipExpirationIntervalInMs,\n );\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadBalancingStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/loadBalancingStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA+CnC;;;;;;;;;GASG;AACH,SAAS,4BAA4B,CACnC,qBAAsD,EACtD,sBAA8B;IAE9B,MAAM,2BAA2B,GAAoC,IAAI,GAAG,EAAE,CAAC;IAC/E,qBAAqB,CAAC,OAAO,CAAC,CAAC,kBAAsC,EAAE,WAAmB,EAAE,EAAE;QAC5F,6DAA6D;QAC7D,IACE,OAAO,kBAAkB,CAAC,oBAAoB,KAAK,WAAW;YAC9D,kBAAkB,CAAC,oBAAoB,KAAK,IAAI,EAChD,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,yBAAyB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,CAAC,oBAAoB,CAAC;QACvF,IAAI,yBAAyB,GAAG,sBAAsB,IAAI,kBAAkB,CAAC,OAAO,EAAE,CAAC;YACrF,2BAA2B,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,2BAA2B,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,2BAA2B,CAClC,mBAAsD,EACtD,YAAsB;IAEtB,2FAA2F;IAC3F,yBAAyB;IACzB,MAAM,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEzF,+FAA+F;IAC/F,iGAAiG;IACjG,oBAAoB;IACpB,gFAAgF;IAChF,MAAM,wCAAwC,GAAG,YAAY,CA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AAC;IAEF,IAAI,yBAAyB,IAAI,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,MAAM,qBAAqB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,2BAA2B,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAEhG,iDAAiD;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC;QACzE,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAC9E,iBAAiB,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzE,yBAAyB,EAAE,CAAC;IAC9B,CAAC;IAED,IAAI,yBAAyB,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,iEAAiE;IACjE,MAAM,iBAAiB,GAAG,qBAAqB,CAC7C,yBAAyB,EACzB,qBAAqB,EACrB,wCAAwC,EACxC,OAAO,EACP,mBAAmB,CACpB,CAAC;IAEF,OAAO,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACrD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PartitionOwnership } from \"../eventProcessor\";\nimport { logger } from \"../logger\";\n\n/**\n * Determines which partitions to claim as part of load balancing.\n * @internal\n */\nexport interface LoadBalancingStrategy {\n /**\n * Implements load balancing by taking into account current ownership and\n * the full set of partitions in the Event Hub.\n * @param ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n getPartitionsToClaim(\n ownerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[];\n}\n\n/**\n * Counts of the EventProcessors that currently own partitions.\n * @internal\n */\ninterface EventProcessorCounts {\n /**\n * The # of EventProcessors that only own the required # of\n * partitions.\n */\n haveRequiredPartitions: number;\n /**\n * The # of EventProcessors that currently own the required #\n * of partitions + 1 additional (ie, handling the case where\n * the number of partitions is not evenly divisible by the # of\n * EventProcessors).\n */\n haveAdditionalPartition: number;\n /**\n * EventProcessors which have more than the required or even required + 1\n * number of partitions. These will eventually be downsized by other\n * EventProcessors as they acquire their required number of partitions.\n */\n haveTooManyPartitions: number;\n}\n\n/**\n * This method will create a new map of partition id and PartitionOwnership containing only those partitions\n * that are actively owned.\n * All entries in the original map that haven't been modified for a duration of time greater than the allowed\n * inactivity time limit are assumed to be owned by dead event processors.\n * These will not be included in the map returned by this method.\n *\n * @param partitionOwnershipMap - The existing PartitionOwnerships mapped by partition.\n * @param expirationIntervalInMs - The length of time a PartitionOwnership claim is valid.\n */\nfunction getActivePartitionOwnerships(\n partitionOwnershipMap: Map<string, PartitionOwnership>,\n expirationIntervalInMs: number,\n): Map<string, PartitionOwnership> {\n const activePartitionOwnershipMap: Map<string, PartitionOwnership> = new Map();\n partitionOwnershipMap.forEach((partitionOwnership: PartitionOwnership, partitionId: string) => {\n // If lastModifiedtimeInMs is missing, assume it is inactive.\n if (\n typeof partitionOwnership.lastModifiedTimeInMs === \"undefined\" ||\n partitionOwnership.lastModifiedTimeInMs === null\n ) {\n return;\n }\n\n const timeSincePartitionClaimed = Date.now() - partitionOwnership.lastModifiedTimeInMs;\n if (timeSincePartitionClaimed < expirationIntervalInMs && partitionOwnership.ownerId) {\n activePartitionOwnershipMap.set(partitionId, partitionOwnership);\n }\n });\n\n return activePartitionOwnershipMap;\n}\n\n/**\n * Calculates the minimum number of partitions each EventProcessor should own,\n * and the number of EventProcessors that should have an extra partition assigned.\n * @param ownerToOwnershipMap - The current ownerships for partitions.\n * @param partitionIds - The full list of the Event Hub's partition ids.\n * @internal\n */\nfunction calculateBalancedLoadCounts(\n ownerToOwnershipMap: Map<string, PartitionOwnership[]>,\n partitionIds: string[],\n): { minPartitionsPerOwner: number; requiredNumberOfOwnersWithExtraPartition: number } {\n // Calculate the minimum number of partitions every EventProcessor should own when the load\n // is evenly distributed.\n const minPartitionsPerOwner = Math.floor(partitionIds.length / ownerToOwnershipMap.size);\n\n // If the number of partitions in the Event Hub is not evenly divisible by the number of active\n // EventProcesrrors, some EventProcessors may own 1 partition in addition to the minimum when the\n // load is balanced.\n // Calculate the number of EventProcessors that can own an additional partition.\n const requiredNumberOfOwnersWithExtraPartition = partitionIds.length % ownerToOwnershipMap.size;\n\n return {\n minPartitionsPerOwner,\n requiredNumberOfOwnersWithExtraPartition,\n };\n}\n\n/**\n * Counts the EventProcessors and tallies them by type.\n *\n * To be in balance we need to make sure that each EventProcessor is only consuming\n * their fair share.\n *\n * When the partitions are divvied up we will sometimes end up with some EventProcessors\n * that will have 1 more partition than others.\n * This can happen if the number of partitions is not evenly divisible by the number of EventProcessors.\n *\n * So this function largely exists to support isLoadBalanced() and\n * shouldOwnMorePartitions(), both of which depend on knowing if our current list\n * of EventProcessors is actually in the proper state.\n *\n * @param minPartitionsPerOwner - The number of required partitions per EventProcessor.\n * @param ownerToOwnershipMap - The current ownerships for partitions.\n * @internal\n */\nfunction getEventProcessorCounts(\n minPartitionsPerOwner: number,\n ownerToOwnershipMap: Map<string, PartitionOwnership[]>,\n): EventProcessorCounts {\n const counts: EventProcessorCounts = {\n haveRequiredPartitions: 0,\n haveAdditionalPartition: 0,\n haveTooManyPartitions: 0,\n };\n\n for (const ownershipList of ownerToOwnershipMap.values()) {\n const numberOfPartitions = ownershipList.length;\n\n // there are basically three kinds of partition counts\n // for a processor:\n\n if (numberOfPartitions === minPartitionsPerOwner) {\n // 1. Has _exactly_ the required number of partitions\n counts.haveRequiredPartitions++;\n } else if (numberOfPartitions === minPartitionsPerOwner + 1) {\n // 2. Has the required number plus one extra (correct in cases)\n // where the # of partitions is not evenly divisible by the\n // number of processors.\n counts.haveAdditionalPartition++;\n } else if (numberOfPartitions > minPartitionsPerOwner + 1) {\n // 3. has more than the possible # of partitions required\n counts.haveTooManyPartitions++;\n }\n }\n\n return counts;\n}\n\n/**\n * Validates that we are currently in a balanced state - all EventProcessors own the\n * minimum required number of partitions (and additional partitions, if the # of partitions\n * is not evenly divisible by the # of EventProcessors).\n *\n * @param requiredNumberOfOwnersWithExtraPartition - The # of EventProcessors that process an additional partition, in addition to the required minimum.\n * @param totalExpectedProcessors - The total # of EventProcessors we expect.\n * @param eventProcessorCounts - EventProcessor counts, grouped by criteria.\n * @internal\n */\nfunction isLoadBalanced(\n requiredNumberOfOwnersWithExtraPartition: number,\n totalExpectedEventProcessors: number,\n { haveAdditionalPartition, haveRequiredPartitions }: EventProcessorCounts,\n): boolean {\n return (\n haveAdditionalPartition === requiredNumberOfOwnersWithExtraPartition &&\n haveRequiredPartitions + haveAdditionalPartition === totalExpectedEventProcessors\n );\n}\n\n/**\n * Determines the number of new partitions to claim for this particular processor.\n *\n * @param minRequired - The minimum required number of partitions.\n * @param requiredNumberOfOwnersWithExtraPartition - The current number of processors that should have an additional partition.\n * @param numPartitionsOwnedByUs - The number of partitions we currently own.\n * @param eventProcessorCounts - Processors, grouped by criteria.\n * @internal\n */\nfunction getNumberOfPartitionsToClaim(\n minRequiredPartitionCount: number,\n requiredNumberOfOwnersWithExtraPartition: number,\n numPartitionsOwnedByUs: number,\n { haveAdditionalPartition, haveTooManyPartitions }: EventProcessorCounts,\n): number {\n let actualRequiredPartitionCount = minRequiredPartitionCount;\n\n if (\n requiredNumberOfOwnersWithExtraPartition > 0 &&\n // Eventually the `haveTooManyPartitions` will decay into `haveAdditionalPartition`\n // EventProcessors as partitions are balanced to consumers that aren't at par.\n // We can consider them to be `haveAdditionalPartition` EventProcessors for our purposes.\n haveAdditionalPartition + haveTooManyPartitions < requiredNumberOfOwnersWithExtraPartition\n ) {\n // Overall we don't have enough EventProcessors that are taking on an additional partition\n // so we should attempt to.\n actualRequiredPartitionCount = minRequiredPartitionCount + 1;\n }\n return actualRequiredPartitionCount - numPartitionsOwnedByUs;\n}\n\n/**\n * Determines which partitions can be stolen from other owners while maintaining\n * a balanced state.\n * @param numberOfPartitionsToClaim - The number of partitions the owner needs to claim to reach a balanced state.\n * @param minPartitionsPerOwner - The minimum number of partitions each owner needs for the partition load to be balanced.\n * @param requiredNumberOfOwnersWithExtraPartition - The number of owners that should have 1 extra partition.\n * @param ourOwnerId - The id of _our_ owner.\n * @param ownerToOwnershipMap - The current ownerships for partitions.\n * @internal\n */\nfunction findPartitionsToSteal(\n numberOfPartitionsToClaim: number,\n minPartitionsPerOwner: number,\n requiredNumberOfOwnersWithExtraPartition: number,\n ourOwnerId: string,\n ownerToOwnershipMap: Map<string, PartitionOwnership[]>,\n): string[] {\n const partitionsToSteal: string[] = [];\n // Create a list of PartitionOwnership lists that we can steal from.\n const listOfPartitionOwnerships: Array<PartitionOwnership[]> = [];\n ownerToOwnershipMap.forEach((partitionOwnerships, ownerId) => {\n if (ownerId === ourOwnerId || partitionOwnerships.length <= minPartitionsPerOwner) return;\n listOfPartitionOwnerships.push(partitionOwnerships);\n });\n\n // Sort the list in descending order based on the length of each element.\n listOfPartitionOwnerships.sort((a, b) => {\n if (a.length > b.length) return -1;\n if (a.length < b.length) return 1;\n return 0;\n });\n\n // Attempt to steal partitions from EventProcessors that have the most partitions 1st,\n // then work our way down.\n let ownersEncounteredWithExtraPartitions = 0;\n let currentPartitionOwnershipList = listOfPartitionOwnerships.shift();\n while (numberOfPartitionsToClaim > 0 && currentPartitionOwnershipList) {\n let ownersExpectedPartitionCount = minPartitionsPerOwner;\n // Determine if the current owner should be allowed to have an extra partition.\n if (ownersEncounteredWithExtraPartitions < requiredNumberOfOwnersWithExtraPartition) {\n ownersExpectedPartitionCount++;\n }\n ownersEncounteredWithExtraPartitions++;\n\n let numberAvailableToSteal =\n currentPartitionOwnershipList.length - ownersExpectedPartitionCount;\n // Claim as many random partitions as possible.\n while (Math.min(numberOfPartitionsToClaim, numberAvailableToSteal)) {\n const indexToClaim = Math.floor(Math.random() * currentPartitionOwnershipList.length);\n partitionsToSteal.push(currentPartitionOwnershipList.splice(indexToClaim, 1)[0].partitionId);\n numberOfPartitionsToClaim--;\n numberAvailableToSteal--;\n }\n\n // Move on to the next list of PartitionOwnership.\n currentPartitionOwnershipList = listOfPartitionOwnerships.shift();\n }\n\n return partitionsToSteal;\n}\n\n/**\n * Identifies all of the partitions that can be claimed by the specified owner for\n * that owner to reach a balanced state.\n * @param OwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @param expirationIntervalInMs - The length of time a partition claim is valid.\n * @returns Partition ids that may be claimed.\n * @internal\n */\nexport function listAvailablePartitions(\n ownerId: string,\n claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n expirationIntervalInMs: number,\n): string[] {\n if (!partitionIds.length) {\n return [];\n }\n\n // Collect only the PartitionOwnership that have been updated within the expiration interval.\n // Any PartitionOwnership that has been updated outside the expiration interval can be claimed.\n const activePartitionOwnershipMap = getActivePartitionOwnerships(\n claimedPartitionOwnershipMap,\n expirationIntervalInMs,\n );\n logger.verbose(\n `[${ownerId}] Number of active ownership records: ${activePartitionOwnershipMap.size}.`,\n );\n\n if (activePartitionOwnershipMap.size === 0) {\n // All partitions in this Event Hub are available to claim.\n return partitionIds;\n }\n\n // Map ownerIds to the partitions they own so that we can determine how many each owner has.\n const ownerToOwnershipMap = new Map<string, PartitionOwnership[]>();\n for (const activeOwnership of activePartitionOwnershipMap.values()) {\n const partitionOwnershipList = ownerToOwnershipMap.get(activeOwnership.ownerId) || [];\n\n partitionOwnershipList.push(activeOwnership);\n ownerToOwnershipMap.set(activeOwnership.ownerId, partitionOwnershipList);\n }\n\n // Add the current EventProcessor to the map of owners to ownerships if it doesn't exist.\n if (!ownerToOwnershipMap.has(ownerId)) {\n ownerToOwnershipMap.set(ownerId, []);\n }\n\n logger.info(`[${ownerId}] Number of active event processors: ${ownerToOwnershipMap.size}.`);\n\n const { minPartitionsPerOwner, requiredNumberOfOwnersWithExtraPartition } =\n calculateBalancedLoadCounts(ownerToOwnershipMap, partitionIds);\n\n logger.verbose(\n `[${ownerId}] Expected minimum number of partitions per event processor: ${minPartitionsPerOwner},` +\n `expected number of event processors with additional partition: ${requiredNumberOfOwnersWithExtraPartition}.`,\n );\n\n // Get some stats representing the current state the world with regards to how balanced the\n // partitions are across EventProcessors.\n const eventProcessorCounts = getEventProcessorCounts(minPartitionsPerOwner, ownerToOwnershipMap);\n\n if (\n isLoadBalanced(\n requiredNumberOfOwnersWithExtraPartition,\n ownerToOwnershipMap.size,\n eventProcessorCounts,\n )\n ) {\n // When the partitions are evenly distributed, no change required.\n return [];\n }\n\n let numberOfPartitionsToClaim = getNumberOfPartitionsToClaim(\n minPartitionsPerOwner,\n requiredNumberOfOwnersWithExtraPartition,\n ownerToOwnershipMap.get(ownerId)!.length,\n eventProcessorCounts,\n );\n\n if (numberOfPartitionsToClaim <= 0) {\n return [];\n }\n\n const partitionsToClaim: string[] = [];\n const unclaimedPartitionIds = partitionIds.filter((id) => !activePartitionOwnershipMap.has(id));\n\n // Prioritize getting unclaimed partitions first.\n while (Math.min(numberOfPartitionsToClaim, unclaimedPartitionIds.length)) {\n const indexToClaim = Math.floor(Math.random() * unclaimedPartitionIds.length);\n partitionsToClaim.push(unclaimedPartitionIds.splice(indexToClaim, 1)[0]);\n numberOfPartitionsToClaim--;\n }\n\n if (numberOfPartitionsToClaim === 0) {\n return partitionsToClaim;\n }\n\n // Find partitions that can be stolen from other EventProcessors.\n const partitionsToSteal = findPartitionsToSteal(\n numberOfPartitionsToClaim,\n minPartitionsPerOwner,\n requiredNumberOfOwnersWithExtraPartition,\n ownerId,\n ownerToOwnershipMap,\n );\n\n return partitionsToClaim.concat(partitionsToSteal);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"unbalancedStrategy.js","sourceRoot":"","sources":["../../../src/loadBalancerStrategies/unbalancedStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;;;;GAKG;AACH,MAAM,OAAO,+BAA+B;IAC1C;;;;;;;OAOG;IACI,oBAAoB,CACzB,WAAmB,EACnB,6BAA8D,EAC9D,YAAsB;QAEtB,OAAO,YAAY,CAAC;IACtB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LoadBalancingStrategy } from \"./loadBalancingStrategy\";\nimport { PartitionOwnership } from \"../eventProcessor\";\n\n/**\n * The UnbalancedLoadBalancingStrategy does no actual load balancing.\n * It is intended to be used when you want to avoid load balancing\n * and consume a set of partitions.\n * @internal\n */\nexport class UnbalancedLoadBalancingStrategy implements LoadBalancingStrategy {\n /**\n * Implements load balancing by taking into account current ownership and\n * the full set of partitions in the Event Hub.\n * @param _ourOwnerId - The id we should assume is _our_ id when checking for ownership.\n * @param _claimedPartitionOwnershipMap - The current claimed ownerships for partitions.\n * @param partitionIds - Partitions to assign owners to.\n * @returns Partition ids to claim.\n */\n public getPartitionsToClaim(\n _ourOwnerId: string,\n _claimedPartitionOwnershipMap: Map<string, PartitionOwnership>,\n partitionIds: string[],\n ): string[] {\n return partitionIds;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAA8B,kBAAkB,EAAY,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC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iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC;KAC3D,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,MAAM,CAAC,GAAY;IACjC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AzureLogger, AzureLogLevel, createClientLogger, Debugger } from \"@azure/logger\";\nimport { isObjectWithProperties } from \"@azure/core-util\";\n\n/**\n * The `@azure/logger` configuration for this package.\n * This will output logs using the `azure:event-hubs` namespace prefix.\n */\nexport const logger = createClientLogger(\"event-hubs\");\n\n/**\n * Logs the error's stack trace to \"verbose\" if a stack trace is available.\n * @param error - Error containing a stack trace.\n * @internal\n */\nexport function logErrorStackTrace(error: unknown): void {\n if (isObjectWithProperties(error, [\"stack\"])) {\n logger.verbose(error.stack);\n }\n}\n\n/**\n * @internal\n */\nexport function createReceiverLogPrefix(\n consumerId: string,\n connectionId: string,\n partitionId: string,\n): string {\n return `[${connectionId}] Receiver P${partitionId}-${consumerId}`;\n}\n\n/**\n * @internal\n */\nexport function createSenderLogPrefix(senderId: string, connectionId: string): string {\n return `[${connectionId}] Sender ${senderId}`;\n}\n\n/**\n * @internal\n */\nexport function createManagementLogPrefix(connectionId: string): string {\n return `[${connectionId}] Management`;\n}\n\n/**\n * @internal\n */\nexport type SimpleLogger = {\n [Property in keyof AzureLogger]: Debugger[\"log\"];\n};\n\nfunction createLogFunction(\n azureLogger: AzureLogger,\n prefix: string,\n level: AzureLogLevel,\n): (arg: any, ...args: any[]) => void {\n return (arg: any, ...args: any[]) =>\n azureLogger[level](\n ...(typeof arg === \"string\" ? [`${prefix}: ${arg}`] : [prefix, arg]),\n ...args,\n );\n}\n\n/**\n * @internal\n */\nexport function createSimpleLogger(azureLogger: AzureLogger, prefix: string): SimpleLogger {\n return {\n info: createLogFunction(azureLogger, prefix, \"info\"),\n error: createLogFunction(azureLogger, prefix, \"error\"),\n verbose: createLogFunction(azureLogger, prefix, \"verbose\"),\n warning: createLogFunction(azureLogger, prefix, \"warning\"),\n };\n}\n\n/** @internal */\nexport function logObj(obj: unknown): void {\n JSON.stringify(obj, undefined, 2);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"managementClient.js","sourceRoot":"","sources":["../../src/managementClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,SAAS,EACT,mBAAmB,EAEnB,kBAAkB,EAGlB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,EACL,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,cAAc,EAEd,YAAY,GAEb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,EAEN,yBAAyB,GAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAC;AAK9F,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAkE7C;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAoC3B;;;;;OAKG;IACH,YAAY,OAA0B,EAAE,EAAE,OAAO,EAAE,QAAQ,KAA8B,EAAE;QAzClF,mBAAc,GAAW,aAAa,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;QAMhF;;WAEG;QACc,YAAO,GAAW,aAAa,EAAE,CAAC;QAiCjD,IAAI,CAAC,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,SAAS,CAAC,UAAU,CAAC;QAC/C,IAAI,CAAC,QAAQ,GAAG,QAAQ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,CAAE,IAAI,KAAK,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,OAAO,EAAE,CACxD,CAAC;YACF,kBAAkB,CAAC,eAAe,CAAC,CAAC;YACpC,MAAM,eAAe,CAAC;QACxB,CAAC;IACH,CAAC;IAEO,8BAA8B;QACpC,OAAO,IAAI,CAAC,eAAgB,IAAI,IAAI,CAAC,eAAgB,CAAC,MAAM,EAAE,CAAC;IACjE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Constants,\n RequestResponseLink,\n RetryConfig,\n RetryOperationType,\n RetryOptions,\n SendRequestOptions,\n defaultCancellableLock,\n isSasTokenProvider,\n retry,\n translate,\n} from \"@azure/core-amqp\";\nimport {\n EventContext,\n Message,\n ReceiverEvents,\n ReceiverOptions,\n SenderEvents,\n SenderOptions,\n} from \"rhea-promise\";\nimport {\n logErrorStackTrace,\n createSimpleLogger,\n logger,\n SimpleLogger,\n createManagementLogPrefix,\n} from \"./logger\";\nimport { throwErrorIfConnectionClosed, throwTypeErrorIfParameterMissing } from \"./util/error\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AccessToken } from \"@azure/core-auth\";\nimport { ConnectionContext } from \"./connectionContext\";\nimport { OperationOptions } from \"./util/operationOptions\";\nimport { toSpanOptions, tracingClient } from \"./diagnostics/tracing\";\nimport { getRetryAttemptTimeoutInMs } from \"./util/retries\";\nimport { TimerLoop } from \"./util/timerLoop\";\nimport { withAuth } from \"./withAuth\";\nimport { getRandomName } from \"./util/utils\";\n\n/**\n * Describes the runtime information of an Event Hub.\n */\nexport interface EventHubProperties {\n /**\n * The name of the event hub.\n */\n name: string;\n /**\n * The date and time the hub was created in UTC.\n */\n createdOn: Date;\n /**\n * The slice of string partition identifiers.\n */\n partitionIds: string[];\n /**\n * Whether the hub has geographical disaster recovery enabled.\n */\n isGeoDrEnabled: boolean;\n}\n\n/**\n * Describes the runtime information of an EventHub Partition.\n */\nexport interface PartitionProperties {\n /**\n * The name of the Event Hub.\n */\n eventHubName: string;\n /**\n * Identifier of the partition within the Event Hub.\n */\n partitionId: string;\n /**\n * The starting sequence number of the partition's message log.\n */\n beginningSequenceNumber: number;\n /**\n * The last sequence number of the partition's message log.\n */\n lastEnqueuedSequenceNumber: number;\n /**\n * The offset of the last enqueued message in the partition's message log.\n */\n lastEnqueuedOffset: string;\n /**\n * The time of the last enqueued message in the partition's message log in UTC.\n */\n lastEnqueuedOnUtc: Date;\n /**\n * Indicates whether the partition is empty.\n */\n isEmpty: boolean;\n}\n\n/**\n * @internal\n */\nexport interface ManagementClientOptions {\n address?: string;\n audience?: string;\n}\n\n/**\n * @internal\n * Describes the EventHubs Management Client that talks\n * to the $management endpoint over AMQP connection.\n */\nexport class ManagementClient {\n readonly managementLock: string = getRandomName(Constants.managementRequestKey);\n /**\n * The name/path of the entity (hub name) for which the management\n * request needs to be made.\n */\n private readonly entityPath: string;\n /**\n * The reply to Guid for the management client.\n */\n private readonly replyTo: string = getRandomName();\n /**\n * $management sender, receiver on the same session.\n */\n private _mgmtReqResLink?: RequestResponseLink;\n /**\n * The address in the following form:\n * `\"$management\"`.\n */\n private readonly address: string;\n /**\n * The token audience in the following form:\n * `\"sb://<your-namespace>.servicebus.windows.net/<event-hub-name>/$management\"`.\n */\n private readonly audience: string;\n /**\n * Provides relevant information about the amqp connection,\n * cbs and $management sessions, token provider, sender and receivers.\n */\n private readonly _context: ConnectionContext;\n /**\n * The authentication loop that keeps the token refreshed.\n */\n private authLoop?: TimerLoop;\n private readonly logger: SimpleLogger;\n\n /**\n * Instantiates the management client.\n * @param context - The connection context.\n * @param address - The address for the management endpoint. For IotHub it will be\n * `/messages/events/$management`.\n */\n constructor(context: ConnectionContext, { address, audience }: ManagementClientOptions = {}) {\n this.address = address ?? Constants.management;\n this.audience = audience ?? context.config.getManagementAudience();\n this._context = context;\n const logPrefix = createManagementLogPrefix(this._context.connectionId);\n this.logger = createSimpleLogger(logger, logPrefix);\n this.entityPath = context.config.entityPath as string;\n }\n\n /**\n * Gets the security token for the management application properties.\n * @internal\n */\n async getSecurityToken(): Promise<AccessToken | null> {\n if (isSasTokenProvider(this._context.tokenCredential)) {\n // the security_token has the $management address removed from the end of the audience\n // expected audience: sb://fully.qualified.namespace/event-hub-name/$management\n const audienceParts = this.audience.split(\"/\");\n // for management links, address should be '$management'\n if (audienceParts[audienceParts.length - 1] === this.address) {\n audienceParts.pop();\n }\n const audience = audienceParts.join(\"/\");\n return this._context.tokenCredential.getToken(audience);\n }\n\n // aad credentials use the aad scope\n return this._context.tokenCredential.getToken(Constants.aadEventHubsScope);\n }\n\n /**\n * Provides the eventhub runtime information.\n */\n async getEventHubProperties(\n options: OperationOptions & { retryOptions?: RetryOptions } = {},\n ): Promise<EventHubProperties> {\n throwErrorIfConnectionClosed(this._context);\n return tracingClient.withSpan(\n \"ManagementClient.getEventHubProperties\",\n options,\n async (updatedOptions) => {\n try {\n const securityToken = await this.getSecurityToken();\n\n const request: Message = {\n body: Buffer.from(JSON.stringify([])),\n message_id: getRandomName(),\n reply_to: this.replyTo,\n application_properties: {\n operation: Constants.readOperation,\n name: this.entityPath as string,\n type: `${Constants.vendorString}:${Constants.eventHub}`,\n security_token: securityToken?.token,\n },\n };\n\n const info: any = await this._makeManagementRequest(request, {\n ...updatedOptions,\n requestName: \"getHubRuntimeInformation\",\n });\n const runtimeInfo: EventHubProperties = {\n name: info.name,\n createdOn: new Date(info.created_at),\n partitionIds: info.partition_ids,\n isGeoDrEnabled: info.georeplication_factor > 1,\n };\n logger.verbose(\"the hub runtime info is: %O\", runtimeInfo);\n\n return runtimeInfo;\n } catch (error: any) {\n logger.warning(\n `an error occurred while getting the hub runtime information: ${error?.name}: ${error?.message}`,\n );\n logErrorStackTrace(error);\n throw error;\n }\n },\n toSpanOptions(this._context.config),\n );\n }\n\n /**\n * Provides information about the specified partition.\n * @param partitionId - Partition ID for which partition information is required.\n */\n async getPartitionProperties(\n partitionId: string,\n options: OperationOptions & { retryOptions?: RetryOptions } = {},\n ): Promise<PartitionProperties> {\n throwErrorIfConnectionClosed(this._context);\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"getPartitionProperties\",\n \"partitionId\",\n partitionId,\n );\n partitionId = String(partitionId);\n\n return tracingClient.withSpan(\n \"ManagementClient.getPartitionProperties\",\n options,\n async (updatedOptions) => {\n try {\n const securityToken = await this.getSecurityToken();\n const request: Message = {\n body: Buffer.from(JSON.stringify([])),\n message_id: getRandomName(),\n reply_to: this.replyTo,\n application_properties: {\n operation: Constants.readOperation,\n name: this.entityPath as string,\n type: `${Constants.vendorString}:${Constants.partition}`,\n partition: `${partitionId}`,\n security_token: securityToken?.token,\n },\n };\n\n const info: any = await this._makeManagementRequest(request, {\n ...updatedOptions,\n requestName: \"getPartitionInformation\",\n });\n\n const partitionInfo: PartitionProperties = {\n beginningSequenceNumber: info.begin_sequence_number,\n eventHubName: info.name,\n lastEnqueuedOffset: info.last_enqueued_offset,\n lastEnqueuedOnUtc: new Date(info.last_enqueued_time_utc),\n lastEnqueuedSequenceNumber: info.last_enqueued_sequence_number,\n partitionId: info.partition,\n isEmpty: info.is_partition_empty,\n };\n logger.verbose(\"the partition info is: %O.\", partitionInfo);\n return partitionInfo;\n } catch (error: any) {\n logger.warning(\n `an error occurred while getting the partition information: ${error?.name}: ${error?.message}`,\n );\n logErrorStackTrace(error);\n throw error;\n }\n },\n toSpanOptions(this._context.config),\n );\n }\n\n /**\n * Closes the AMQP management session to the Event Hub for this client,\n * returning a promise that will be resolved when disconnection is completed.\n */\n async close(): Promise<void> {\n try {\n // Always stop the auth loop when closing the management link.\n this.authLoop?.stop();\n if (this._isMgmtRequestResponseLinkOpen()) {\n const mgmtLink = this._mgmtReqResLink;\n this._mgmtReqResLink = undefined;\n await mgmtLink!.close();\n logger.info(\"successfully closed the management session.\");\n }\n } catch (err: any) {\n const msg = `an error occurred while closing the management session: ${err?.name}: ${err?.message}`;\n logger.warning(msg);\n logErrorStackTrace(err);\n throw new Error(msg);\n }\n }\n\n private async _init({\n abortSignal,\n timeoutInMs,\n }: {\n abortSignal: AbortSignalLike | undefined;\n timeoutInMs: number;\n }): Promise<void> {\n const createLink = async () => {\n const rxopt: ReceiverOptions = {\n source: { address: this.address },\n name: this.replyTo,\n target: { address: this.replyTo },\n onSessionError: (context: EventContext) => {\n const ehError = translate(context.session!.error!);\n logger.verbose(\n \"an error occurred on the session for request/response links for \" + \"$management: %O\",\n ehError,\n );\n },\n };\n const sropt: SenderOptions = {\n target: { address: this.address },\n };\n logger.verbose(\n \"creating sender/receiver links with \" + \"srOpts: %o, receiverOpts: %O.\",\n sropt,\n rxopt,\n );\n this._mgmtReqResLink = await RequestResponseLink.create(\n this._context.connection,\n sropt,\n rxopt,\n { abortSignal },\n );\n this._mgmtReqResLink.sender.on(SenderEvents.senderError, (context: EventContext) => {\n const ehError = translate(context.sender!.error!);\n logger.verbose(\"an error occurred on the $management sender link.. %O\", ehError);\n });\n this._mgmtReqResLink.receiver.on(ReceiverEvents.receiverError, (context: EventContext) => {\n const ehError = translate(context.receiver!.error!);\n logger.verbose(\"an error occurred on the $management receiver link.. %O\", ehError);\n });\n logger.verbose(\n \"created sender '%s' and receiver '%s' links\",\n this._mgmtReqResLink.sender.name,\n this._mgmtReqResLink.receiver.name,\n );\n };\n try {\n if (!this._isMgmtRequestResponseLinkOpen()) {\n // Wait for the connectionContext to be ready to open the link.\n await this._context.readyToOpenLink();\n this.authLoop = await withAuth(\n createLink,\n this._context,\n this.audience,\n timeoutInMs,\n this.logger,\n { abortSignal },\n );\n }\n } catch (err) {\n const translatedError = translate(err);\n logger.warning(\n `an error occurred while establishing the links: ${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n /**\n * Helper method to make the management request\n * @param request - The AMQP message to send\n * @param options - The options to use when sending a request over a $management link\n */\n private async _makeManagementRequest(\n request: Message,\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n requestName?: string;\n } = {},\n ): Promise<any> {\n const retryOptions = options.retryOptions || {};\n try {\n const abortSignal: AbortSignalLike | undefined = options && options.abortSignal;\n\n const sendOperationPromise = async (): Promise<Message> => {\n let count = 0;\n\n const retryTimeoutInMs = getRetryAttemptTimeoutInMs(options.retryOptions);\n let timeTakenByInit = 0;\n\n if (!this._isMgmtRequestResponseLinkOpen()) {\n logger.verbose(\"acquiring lock to get the management req res link.\");\n\n const initOperationStartTime = Date.now();\n try {\n await defaultCancellableLock.acquire(\n this.managementLock,\n () => {\n const acquireLockEndTime = Date.now();\n const timeoutInMs =\n retryTimeoutInMs - (acquireLockEndTime - initOperationStartTime);\n return this._init({ abortSignal, timeoutInMs });\n },\n { abortSignal, timeoutInMs: retryTimeoutInMs },\n );\n } catch (err) {\n const translatedError = translate(err);\n logger.warning(\n \"an error occurred while creating the link: %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n timeTakenByInit = Date.now() - initOperationStartTime;\n }\n\n const remainingOperationTimeoutInMs = retryTimeoutInMs - timeTakenByInit;\n\n const sendRequestOptions: SendRequestOptions = {\n abortSignal: options.abortSignal,\n requestName: options.requestName,\n timeoutInMs: remainingOperationTimeoutInMs,\n };\n\n count++;\n if (count !== 1) {\n // Generate a new message_id every time after the first attempt\n request.message_id = getRandomName();\n } else if (!request.message_id) {\n // Set the message_id in the first attempt only if it is not set\n request.message_id = getRandomName();\n }\n\n return this._mgmtReqResLink!.sendRequest(request, sendRequestOptions);\n };\n\n const config: RetryConfig<Message> = Object.defineProperties(\n {\n operation: sendOperationPromise,\n operationType: RetryOperationType.management,\n abortSignal: abortSignal,\n retryOptions: retryOptions,\n },\n {\n connectionId: {\n enumerable: true,\n get: () => {\n return this._context.connectionId;\n },\n },\n },\n ) as RetryConfig<Message>;\n return (await retry<Message>(config)).body;\n } catch (err) {\n const translatedError = translate(err);\n logger.warning(\n \"an error occurred during send on management request-response link with address: %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n private _isMgmtRequestResponseLinkOpen(): boolean {\n return this._mgmtReqResLink! && this._mgmtReqResLink!.isOpen();\n }\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { idempotentProducerAmqpPropertyNames } from "../util/constants";
4
- //# sourceMappingURL=private.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"private.js","sourceRoot":"","sources":["../../../src/models/private.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,mCAAmC,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LoadBalancingStrategy } from \"../loadBalancerStrategies/loadBalancingStrategy\";\nimport { RetryOptions } from \"@azure/core-amqp\";\nimport { Typed } from \"rhea-promise\";\nimport { SubscribeOptions } from \"../eventHubConsumerClientModels\";\nimport { idempotentProducerAmqpPropertyNames } from \"../util/constants\";\n\n/**\n * The set of options to configure the behavior of an `EventHubProducer`.\n * These can be specified when creating the producer via the `createProducer` method.\n * - `partitionId` : The string identifier of the partition that the producer can be bound to.\n * - `retryOptions` : The retry options used to govern retry attempts when an issue is encountered while sending events.\n * A simple usage can be `{ \"maxRetries\": 4 }`.\n * @internal\n */\nexport interface EventHubProducerOptions {\n /**\n * The identifier of the partition that the producer will be bound to.\n * If a value is provided, all events sent using the producer will reach the same partition.\n * If no value is provided, the service will determine the partition to which the event will be sent.\n */\n partitionId?: string;\n /**\n * The retry options used to govern retry attempts when an issue is encountered while sending events.\n * If no value is provided here, the retry options set when creating the `EventHubClient` is used.\n */\n retryOptions?: RetryOptions;\n}\n\n/**\n * @internal\n */\nexport type OperationNames = \"getEventHubProperties\" | \"getPartitionIds\" | \"getPartitionProperties\";\n\n/**\n * @internal\n */\nexport interface CommonEventProcessorOptions\n extends Required<Pick<SubscribeOptions, \"maxBatchSize\" | \"maxWaitTimeInSeconds\">>,\n Pick<\n SubscribeOptions,\n Exclude<\n keyof SubscribeOptions,\n // (made required above)\n \"maxBatchSize\" | \"maxWaitTimeInSeconds\"\n >\n > {\n /**\n * A load balancing strategy that determines how to claim partitions.\n */\n loadBalancingStrategy: LoadBalancingStrategy;\n\n /**\n * An optional ownerId to use rather than using an internally generated ID\n * This allows you to logically group a series of processors together (for instance\n * like we do with EventHubConsumerClient)\n */\n ownerId?: string;\n\n /**\n * The maximum amount of time since a PartitionOwnership was updated\n * to use to determine if a partition is no longer claimed.\n * Setting this value to 0 will cause the default value to be used.\n */\n inactiveTimeLimitInMs?: number;\n /**\n * Retry Options to be used when receiving events\n */\n retryOptions?: RetryOptions;\n}\n\n/**\n * The set of options to configure the behavior of an `EventHubConsumer`.\n * These can be specified when creating the consumer using the `createConsumer` method.\n * - `ownerLevel` : A number indicating that the consumer intends to be an exclusive consumer of events resulting in other\n * consumers to fail if their `ownerLevel` is lower or doesn't exist.\n * - `retryOptions`: The retry options used to govern retry attempts when an issue is encountered while receiving events.\n * A simple usage can be `{ \"maxRetries\": 4 }`.\n * - `skipParsingBodyAsJson` : 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 prefer to work directly with\n * the bytes present in the message body than have the client attempt to parse it.\n *\n * Example usage:\n * ```js\n * {\n * retryOptions: {\n * maxRetries: 4\n * },\n * trackLastEnqueuedEventProperties: false,\n * skipParsingBodyAsJson: true\n * }\n * ```\n * @internal\n */\nexport interface PartitionReceiverOptions {\n /**\n * The owner level associated with an exclusive consumer.\n *\n * When provided, the owner level indicates that a consumer is intended to be the exclusive receiver of events for the\n * requested partition and the associated consumer group.\n * When multiple consumers exist for the same partition/consumer group pair, then the ones with lower or no\n * `ownerLevel` will get a `ReceiverDisconnectedError` during the next attempted receive operation.\n */\n ownerLevel?: number;\n /**\n * The retry options used to govern retry attempts when an issue is encountered while receiving events.\n * If no value is provided here, the retry options set when creating the `EventHubClient` is used.\n */\n retryOptions?: RetryOptions;\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 * 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 * @internal\n */\nexport interface IdempotentLinkProperties {\n [idempotentProducerAmqpPropertyNames.epoch]: Typed | null;\n [idempotentProducerAmqpPropertyNames.producerId]: Typed | null;\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: Typed | null;\n}\n\n/**\n * The set of options that can be specified for an `EventHubProducerClient`\n * to influence its behavior when publishing directly to an Event Hub partition.\n *\n * These options are ignored when publishing to the Event Hubs gateway for automatic\n * routing or when using a partition key.\n */\nexport interface PartitionPublishingOptions {\n /**\n * The owner level indicates that a publishing is intended to be performed exclusively for events in the\n * requested partition in the context of the associated producer group.\n *\n * To do so, publishing will attempt to assert ownership over the partition;\n * in the case where more than one publisher in the producer group attempts to assert ownership for the same partition,\n * the one having a larger `ownerLevel` value will \"win\".\n */\n ownerLevel?: number;\n /**\n * The identifier of the producer group that this producer is associated with when publishing to the associated partition.\n * Events will be published in the context of this group.\n *\n * If `undefined`, the Event Hubs service will control the value.\n *\n * The producer group is only recognized and relevant when certain features of the producer are enabled.\n * For example, it is used by idempotent publishing.\n */\n producerGroupId?: number;\n /**\n * The starting number that should be used for the automatic sequencing of events for the associated partition, when published by this producer.\n *\n * If `undefined`, the Event Hubs service will control the value.\n *\n * The producer group is only recognized and relevant when certain features of the producer are enabled.\n * For example, it is used by idempotent publishing.\n */\n startingSequenceNumber?: number;\n}\n\n/**\n * Describes the information about the state of publishing for a partition.\n */\nexport interface PartitionPublishingProperties {\n /**\n * Indicates whether or not idempotent publishing is enabled for the producer and, by extension, the associated partition.\n */\n isIdempotentPublishingEnabled: boolean;\n /**\n * The owner level of the producer publishing to the associated partition.\n */\n ownerLevel?: number;\n /**\n * The partition id the properties are associated with.\n */\n partitionId: string;\n /**\n * The identifier of the producer group for which this producer is publishing to the associated partition.\n */\n producerGroupId?: number;\n /**\n * The sequence number assigned to the event that was most recently published to the associated partition successfully.\n */\n lastPublishedSequenceNumber?: number;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/models/public.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAwElC;;;GAGG;AACH,MAAM,CAAN,IAAY,WASX;AATD,WAAY,WAAW;IACrB;;OAEG;IACH,8CAA+B,CAAA;IAC/B;;OAEG;IACH,oCAAqB,CAAA;AACvB,CAAC,EATW,WAAW,KAAX,WAAW,QAStB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RetryOptions, WebSocketOptions } from \"@azure/core-amqp\";\nimport { OperationOptions } from \"../util/operationOptions\";\n\n/**\n * The set of options to configure the behavior of `getEventHubProperties`.\n * - `abortSignal` : An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation.\n * - `parentSpan` : The `Span` or `SpanContext` to use as the `parent` of the span created while calling this operation.\n */\nexport interface GetEventHubPropertiesOptions extends OperationOptions {}\n\n/**\n * The set of options to configure the behavior of `getPartitionProperties`.\n * - `abortSignal` : An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation.\n * - `parentSpan` : The `Span` or `SpanContext` to use as the `parent` of the span created while calling this operation.\n */\nexport interface GetPartitionPropertiesOptions extends OperationOptions {}\n\n/**\n * The set of options to configure the behavior of `getPartitionIds`.\n * - `abortSignal` : An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation.\n * - `parentSpan` : The `Span` or `SpanContext` to use as the `parent` of the span created while calling this operation.\n */\nexport interface GetPartitionIdsOptions extends OperationOptions {}\n\n/**\n * Options to configure the `sendBatch` method on the `EventHubProducerClient`\n * when sending an array of events.\n * If `partitionId` is set, `partitionKey` must not be set and vice versa.\n *\n * - `partitionId` : The partition this batch will be sent to.\n * - `partitionKey` : A value that is hashed to produce a partition assignment.\n * - `abortSignal` : A signal used to cancel the send operation.\n */\nexport interface SendBatchOptions extends OperationOptions {\n /**\n * The partition this batch will be sent to.\n * If this value is set then partitionKey can not be set.\n */\n 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 producer was created using a `partitionId`.\n */\n partitionKey?: string;\n}\n\n/**\n * The set of options to configure the `send` operation on the `EventHubProducer`.\n * - `partitionKey` : A value that is hashed to produce a partition assignment.\n * - `abortSignal` : A signal used to cancel the send operation.\n *\n * Example usage:\n * ```js\n * {\n * partitionKey: 'foo'\n * }\n * ```\n *\n * @internal\n */\nexport interface SendOptions extends OperationOptions {\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 producer was created using a `partitionId`.\n */\n partitionKey?: string;\n}\n\n/**\n * An enum representing the different reasons for an `EventHubConsumerClient` to stop processing\n * events from a partition in a consumer group of an Event Hub.\n */\nexport enum CloseReason {\n /**\n * Ownership of the partition was lost or transitioned to a new processor instance.\n */\n OwnershipLost = \"OwnershipLost\",\n /**\n * The EventProcessor was shutdown.\n */\n Shutdown = \"Shutdown\",\n}\n\n/**\n * Describes the options that can be provided while creating the EventHubClient.\n * - `userAgent` : A string to append to the built in user agent string that is passed as a connection property\n * to the service.\n * - `webSocketOptions` : Options to configure the channelling of the AMQP connection over Web Sockets.\n * - `websocket` : The WebSocket constructor used to create an AMQP connection if you choose to make the connection\n * over a WebSocket.\n * - `webSocketConstructorOptions` : Options to pass to the Websocket constructor when you choose to make the connection\n * over a WebSocket.\n * - `retryOptions` : The retry options for all the operations on the client/producer/consumer.\n * - `maxRetries` : The number of times the operation can be retried in case of a retryable error.\n * - `maxRetryDelayInMs`: The maximum delay between retries. Applicable only when performing exponential retries.\n * - `mode`: Which retry mode to apply, specified by the `RetryMode` enum. Options are `Exponential` and `Fixed`. Defaults to `Fixed`.\n * - `retryDelayInMs`: Amount of time to wait in milliseconds before making the next attempt. When `mode` is set to `Exponential`,\n * this is used to compute the exponentially increasing delays between retries. Default: 30000 milliseconds.\n * - `timeoutInMs`: Amount of time in milliseconds to wait before the operation times out. This will trigger a retry if there are any\n * retry attempts remaining. Default value: 60000 milliseconds.\n *\n * A simple usage can be `{ \"maxRetries\": 4 }`.\n *\n * Example usage:\n * ```js\n * {\n * retryOptions: {\n * maxRetries: 4\n * }\n * }\n * ```\n */\nexport interface EventHubClientOptions {\n /**\n * A custom endpoint to use when connecting to the Event Hubs service.\n * This can be useful when your network does not allow connecting to the\n * standard Azure Event Hubs endpoint address, but does allow connecting\n * through an intermediary.\n *\n * Example: \"https://my.custom.endpoint:100/\"\n */\n customEndpointAddress?: string;\n /**\n * Options to configure the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n *\n */\n retryOptions?: RetryOptions;\n /**\n * Options to configure the channelling of the AMQP connection over Web Sockets.\n */\n webSocketOptions?: WebSocketOptions;\n /**\n * Value that is appended to the built in user agent string that is passed to the Event Hubs service.\n */\n userAgent?: string;\n /**\n * A unique name used to identify the client. If not provided, a GUID will be used as the identifier\n */\n identifier?: string;\n}\n\n/**\n * Describes the options that can be provided while creating the EventHubConsumerClient.\n * - `loadBalancingOptions`: Options to tune how the EventHubConsumerClient claims partitions.\n * - `userAgent` : A string to append to the built in user agent string that is passed as a connection property\n * to the service.\n * - `webSocketOptions` : Options to configure the channelling of the AMQP connection over Web Sockets.\n * - `websocket` : The WebSocket constructor used to create an AMQP connection if you choose to make the connection\n * over a WebSocket.\n * - `webSocketConstructorOptions` : Options to pass to the Websocket constructor when you choose to make the connection\n * over a WebSocket.\n * - `retryOptions` : The retry options for all the operations on the client/producer/consumer.\n * - `maxRetries` : The number of times the operation can be retried in case of a retryable error.\n * - `maxRetryDelayInMs`: The maximum delay between retries. Applicable only when performing exponential retries.\n * - `mode`: Which retry mode to apply, specified by the `RetryMode` enum. Options are `Exponential` and `Fixed`. Defaults to `Fixed`.\n * - `retryDelayInMs`: Amount of time to wait in milliseconds before making the next attempt. When `mode` is set to `Exponential`,\n * this is used to compute the exponentially increasing delays between retries. Default: 30000 milliseconds.\n * - `timeoutInMs`: Amount of time in milliseconds to wait before the operation times out. This will trigger a retry if there are any\n * retry attempts remaining. Default value: 60000 milliseconds.\n *\n * A simple usage can be `{ \"maxRetries\": 4 }`.\n *\n * Example usage:\n * ```js\n * {\n * retryOptions: {\n * maxRetries: 4\n * }\n * }\n * ```\n */\nexport interface EventHubConsumerClientOptions extends EventHubClientOptions {\n /**\n * Options to tune how the EventHubConsumerClient claims partitions.\n */\n loadBalancingOptions?: LoadBalancingOptions;\n}\n\n/**\n * An options bag to configure load balancing settings.\n */\nexport interface LoadBalancingOptions {\n /**\n * Whether to apply a greedy or a more balanced approach when\n * claiming partitions.\n *\n * - balanced: The `EventHubConsumerClient` will take a measured approach to\n * requesting partition ownership when balancing work with other clients,\n * slowly claiming partitions until a stabilized distribution is achieved.\n *\n * - greedy: The `EventHubConsumerClient` will attempt to claim ownership\n * of its fair share of partitions aggressively when balancing work with\n * other clients.\n *\n * This option is ignored when either:\n * - `CheckpointStore` is __not__ provided to the `EventHubConsumerClient`.\n * - `subscribe()` is called for a single partition.\n * Default: balanced\n */\n strategy?: \"balanced\" | \"greedy\";\n /**\n * The length of time between attempts to claim partitions.\n * Default: 10000\n */\n updateIntervalInMs?: number;\n /**\n * The length of time a partition claim is valid.\n * Default: 60000\n */\n partitionOwnershipExpirationIntervalInMs?: number;\n}\n\n/**\n * Options to configure the `createBatch` method on the `EventHubProducerClient`.\n * - `partitionKey` : A value that is hashed to produce a partition assignment.\n * - `maxSizeInBytes`: The upper limit for the size of batch.\n * - `abortSignal` : A signal the request to cancel the send operation.\n *\n * Example usage:\n * ```js\n * {\n * partitionKey: 'foo',\n * maxSizeInBytes: 1024 * 1024 // 1 MB\n * }\n * ```\n */\nexport interface CreateBatchOptions extends OperationOptions {\n /**\n * A value that is hashed to produce a partition assignment. It guarantees that messages\n * with the same partitionKey end up in the same partition.\n * If this value is set then partitionId can not be set.\n */\n partitionKey?: string;\n /**\n * The partition this batch will be sent to.\n * If this value is set then partitionKey can not be set.\n */\n partitionId?: string;\n /**\n * The upper limit for the size of batch. The `tryAdd` function will return `false` after this limit is reached.\n */\n maxSizeInBytes?: number;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"partitionProcessor.js","sourceRoot":"","sources":["../../src/partitionProcessor.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAWlC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAyClC;;;;;;;;;GASG;AACH,MAAM,OAAO,kBAAkB;IAG7B,YACU,cAAyC,EACzC,gBAAiC,EACjC,QAEP;QAJO,mBAAc,GAAd,cAAc,CAA2B;QACzC,qBAAgB,GAAhB,gBAAgB,CAAiB;QACjC,aAAQ,GAAR,QAAQ,CAEf;IACA,CAAC;IAEJ;;;;;OAKG;IACH,IAAW,2BAA2B;QACpC,OAAO,IAAI,CAAC,4BAA6B,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,IAAW,2BAA2B,CAAC,UAAuC;QAC5E,IAAI,CAAC,4BAA4B,GAAG,UAAU,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,IAAW,uBAAuB;QAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,uBAAu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;IACI,KAAK,CAAC,gBAAgB,CAAC,SAA4B;QACxD,MAAM,UAAU,GAAe;YAC7B,uBAAuB,EAAE,IAAI,CAAC,QAAQ,CAAC,uBAAuB;YAC9D,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY;YACxC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa;YAC1C,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW;YACtC,cAAc,EAAE,SAAS,CAAC,cAAc;YACxC,MAAM,EAAE,SAAS,CAAC,MAAM;SACzB,CAAC;QAEF,MAAM,IAAI,CAAC,gBAAiB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n BasicPartitionProperties,\n PartitionContext,\n SubscriptionEventHandlers,\n} from \"./eventHubConsumerClientModels\";\nimport { CheckpointStore } from \"./eventProcessor\";\nimport { CloseReason } from \"./models/public\";\nimport { LastEnqueuedEventProperties } from \"./partitionReceiver\";\nimport { ReceivedEventData } from \"./eventData\";\nimport { logger } from \"./logger\";\n\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 * When the `updateCheckpoint()` method on the `PartitionProcessor` class is called by the user, a\n * `Checkpoint` is created internally. It is then stored in the storage solution implemented by the\n * `CheckpointManager` chosen by the user when creating an `EventProcessor`.\n *\n * Users are never expected to interact with `Checkpoint` directly. This interface exists to support the\n * internal workings of `EventProcessor` and `CheckpointManager`.\n **/\nexport interface Checkpoint {\n /**\n * The fully qualified Event Hubs namespace. This is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n */\n fullyQualifiedNamespace: string;\n /**\n * The event hub name\n */\n eventHubName: string;\n /**\n * The consumer group name\n */\n consumerGroup: string;\n /**\n * The identifier of the Event Hub partition\n */\n partitionId: string;\n /**\n * The sequence number of the event\n */\n sequenceNumber: number;\n /**\n * The offset of the event.\n */\n offset: string;\n}\n\n/**\n * The `PartitionProcessor` is responsible for processing events received from Event Hubs when using `EventProcessor`\n *\n * The EventProcessor creates a new instance of the PartitionProcessor for each partition of the event hub it starts processing. When you extend the `PartitionProcessor` in order to customize it as you see fit,\n * - Override the `processEvents()` method to add the code to process the received events. This is also a good place to update the checkpoints using the `updateCheckpoint()` method\n * - Optionally override the `processError()` method to handle any error that might have occurred when processing the events.\n * - Optionally override the `initialize()` method to implement any set up related tasks you would want to carry out before starting to receive events from the partition\n * - Optionally override the `close()` method to implement any tear down or clean up tasks you would want to carry out.\n * @internal\n */\nexport class PartitionProcessor implements PartitionContext {\n private _lastEnqueuedEventProperties?: LastEnqueuedEventProperties;\n\n constructor(\n private _eventHandlers: SubscriptionEventHandlers,\n private _checkpointStore: CheckpointStore,\n private _context: BasicPartitionProperties & {\n eventProcessorId: string;\n },\n ) {}\n\n /**\n * Information on the last enqueued event in the partition that is being processed.\n * This property is updated by the `EventProcessor` if the `trackLastEnqueuedEventProperties` option is set to true\n * when creating an instance of EventProcessor\n * @readonly\n */\n public get lastEnqueuedEventProperties(): LastEnqueuedEventProperties {\n return this._lastEnqueuedEventProperties!;\n }\n\n /**\n * Information on the last enqueued event in the partition that is being processed.\n * This property is updated by the `EventProcessor` if the `trackLastEnqueuedEventProperties` option is set to true\n * when creating an instance of EventProcessor\n */\n public set lastEnqueuedEventProperties(properties: LastEnqueuedEventProperties) {\n this._lastEnqueuedEventProperties = properties;\n }\n\n /**\n * The fully qualified namespace from where the current partition is being processed. It is set by the `EventProcessor`\n * @readonly\n */\n public get fullyQualifiedNamespace(): string {\n return this._context.fullyQualifiedNamespace;\n }\n\n /**\n * The name of the consumer group from where the current partition is being processed. It is set by the `EventProcessor`\n * @readonly\n */\n public get consumerGroup(): string {\n return this._context.consumerGroup!;\n }\n\n /**\n * The name of the event hub to which the current partition belongs. It is set by the `EventProcessor`\n * @readonly\n */\n public get eventHubName(): string {\n return this._context.eventHubName;\n }\n\n /**\n * The identifier of the Event Hub partition that is being processed. It is set by the `EventProcessor`\n * @readonly\n */\n public get partitionId(): string {\n return this._context.partitionId;\n }\n\n /**\n * The unique identifier of the `EventProcessor` that has spawned the current instance of `PartitionProcessor`. This is set by the `EventProcessor`\n */\n public get eventProcessorId(): string {\n return this._context.eventProcessorId;\n }\n\n /**\n * This method is called when the `EventProcessor` takes ownership of a new partition and before any\n * events are received.\n */\n async initialize(): Promise<void> {\n return this._eventHandlers.processInitialize?.(this);\n }\n\n /**\n * This method is called before the partition processor is closed by the EventProcessor.\n *\n * @param reason - The reason for closing this partition processor.\n */\n async close(reason: CloseReason): Promise<void> {\n if (this._eventHandlers.processClose) {\n await this._eventHandlers.processClose(reason, this);\n }\n }\n\n /**\n * This method is called when new events are received.\n *\n * This is also a good place to update checkpoints as appropriate.\n *\n * @param event - The received events to be processed.\n */\n async processEvents(events: ReceivedEventData[]): Promise<void> {\n await this._eventHandlers.processEvents(events, this);\n }\n\n /**\n * This method is called when an error occurs while receiving events from Event Hubs.\n *\n * @param error - The error to be processed.\n */\n async processError(error: Error): Promise<void> {\n if (this._eventHandlers.processError) {\n try {\n await this._eventHandlers.processError(error, this);\n } catch (err: any) {\n logger.verbose(`Error thrown from user's processError handler : ${err}`);\n }\n }\n }\n\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 public async updateCheckpoint(eventData: ReceivedEventData): Promise<void> {\n const checkpoint: Checkpoint = {\n fullyQualifiedNamespace: this._context.fullyQualifiedNamespace,\n eventHubName: this._context.eventHubName,\n consumerGroup: this._context.consumerGroup,\n partitionId: this._context.partitionId,\n sequenceNumber: eventData.sequenceNumber,\n offset: eventData.offset,\n };\n\n await this._checkpointStore!.updateCheckpoint(checkpoint);\n }\n}\n"]}