@azure/event-hubs 6.0.2-alpha.20251015.1 → 6.0.2-alpha.20251021.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/dist/browser/batchingPartitionChannel.d.ts.map +1 -1
  2. package/dist/browser/batchingPartitionChannel.js +2 -1
  3. package/dist/browser/batchingPartitionChannel.js.map +1 -1
  4. package/dist/browser/connectionContext.d.ts.map +1 -1
  5. package/dist/browser/connectionContext.js +10 -4
  6. package/dist/browser/connectionContext.js.map +1 -1
  7. package/dist/browser/eventHubBufferedProducerClient.d.ts.map +1 -1
  8. package/dist/browser/eventHubBufferedProducerClient.js +2 -1
  9. package/dist/browser/eventHubBufferedProducerClient.js.map +1 -1
  10. package/dist/browser/eventHubConsumerClient.d.ts.map +1 -1
  11. package/dist/browser/eventHubConsumerClient.js +3 -6
  12. package/dist/browser/eventHubConsumerClient.js.map +1 -1
  13. package/dist/browser/eventHubProducerClient.d.ts.map +1 -1
  14. package/dist/browser/eventHubProducerClient.js +3 -6
  15. package/dist/browser/eventHubProducerClient.js.map +1 -1
  16. package/dist/browser/eventHubSender.d.ts.map +1 -1
  17. package/dist/browser/eventHubSender.js +6 -4
  18. package/dist/browser/eventHubSender.js.map +1 -1
  19. package/dist/browser/partitionReceiver.js +4 -4
  20. package/dist/browser/partitionReceiver.js.map +1 -1
  21. package/dist/browser/util/timerLoop.d.ts.map +1 -1
  22. package/dist/browser/util/timerLoop.js +12 -5
  23. package/dist/browser/util/timerLoop.js.map +1 -1
  24. package/dist/commonjs/batchingPartitionChannel.d.ts.map +1 -1
  25. package/dist/commonjs/batchingPartitionChannel.js +2 -1
  26. package/dist/commonjs/batchingPartitionChannel.js.map +1 -1
  27. package/dist/commonjs/connectionContext.d.ts.map +1 -1
  28. package/dist/commonjs/connectionContext.js +10 -4
  29. package/dist/commonjs/connectionContext.js.map +1 -1
  30. package/dist/commonjs/eventHubBufferedProducerClient.d.ts.map +1 -1
  31. package/dist/commonjs/eventHubBufferedProducerClient.js +2 -1
  32. package/dist/commonjs/eventHubBufferedProducerClient.js.map +1 -1
  33. package/dist/commonjs/eventHubConsumerClient.d.ts.map +1 -1
  34. package/dist/commonjs/eventHubConsumerClient.js +3 -6
  35. package/dist/commonjs/eventHubConsumerClient.js.map +1 -1
  36. package/dist/commonjs/eventHubProducerClient.d.ts.map +1 -1
  37. package/dist/commonjs/eventHubProducerClient.js +3 -6
  38. package/dist/commonjs/eventHubProducerClient.js.map +1 -1
  39. package/dist/commonjs/eventHubSender.d.ts.map +1 -1
  40. package/dist/commonjs/eventHubSender.js +6 -4
  41. package/dist/commonjs/eventHubSender.js.map +1 -1
  42. package/dist/commonjs/partitionReceiver.js +4 -4
  43. package/dist/commonjs/partitionReceiver.js.map +1 -1
  44. package/dist/commonjs/tsdoc-metadata.json +1 -1
  45. package/dist/commonjs/util/timerLoop.d.ts.map +1 -1
  46. package/dist/commonjs/util/timerLoop.js +12 -5
  47. package/dist/commonjs/util/timerLoop.js.map +1 -1
  48. package/dist/esm/batchingPartitionChannel.d.ts.map +1 -1
  49. package/dist/esm/batchingPartitionChannel.js +2 -1
  50. package/dist/esm/batchingPartitionChannel.js.map +1 -1
  51. package/dist/esm/connectionContext.d.ts.map +1 -1
  52. package/dist/esm/connectionContext.js +10 -4
  53. package/dist/esm/connectionContext.js.map +1 -1
  54. package/dist/esm/eventHubBufferedProducerClient.d.ts.map +1 -1
  55. package/dist/esm/eventHubBufferedProducerClient.js +2 -1
  56. package/dist/esm/eventHubBufferedProducerClient.js.map +1 -1
  57. package/dist/esm/eventHubConsumerClient.d.ts.map +1 -1
  58. package/dist/esm/eventHubConsumerClient.js +3 -6
  59. package/dist/esm/eventHubConsumerClient.js.map +1 -1
  60. package/dist/esm/eventHubProducerClient.d.ts.map +1 -1
  61. package/dist/esm/eventHubProducerClient.js +3 -6
  62. package/dist/esm/eventHubProducerClient.js.map +1 -1
  63. package/dist/esm/eventHubSender.d.ts.map +1 -1
  64. package/dist/esm/eventHubSender.js +6 -4
  65. package/dist/esm/eventHubSender.js.map +1 -1
  66. package/dist/esm/partitionReceiver.js +4 -4
  67. package/dist/esm/partitionReceiver.js.map +1 -1
  68. package/dist/esm/util/timerLoop.d.ts.map +1 -1
  69. package/dist/esm/util/timerLoop.js +12 -5
  70. package/dist/esm/util/timerLoop.js.map +1 -1
  71. package/dist/react-native/batchingPartitionChannel.d.ts +94 -0
  72. package/dist/react-native/batchingPartitionChannel.d.ts.map +1 -0
  73. package/dist/react-native/batchingPartitionChannel.js +255 -0
  74. package/dist/react-native/batchingPartitionChannel.js.map +1 -0
  75. package/dist/react-native/connectionContext.d.ts +108 -0
  76. package/dist/react-native/connectionContext.d.ts.map +1 -0
  77. package/dist/react-native/connectionContext.js +310 -0
  78. package/dist/react-native/connectionContext.js.map +1 -0
  79. package/dist/react-native/dataTransformer.d.ts +53 -0
  80. package/dist/react-native/dataTransformer.d.ts.map +1 -0
  81. package/dist/react-native/dataTransformer.js +133 -0
  82. package/dist/react-native/dataTransformer.js.map +1 -0
  83. package/dist/react-native/diagnostics/instrumentEventData.d.ts +28 -0
  84. package/dist/react-native/diagnostics/instrumentEventData.d.ts.map +1 -0
  85. package/dist/react-native/diagnostics/instrumentEventData.js +67 -0
  86. package/dist/react-native/diagnostics/instrumentEventData.js.map +1 -0
  87. package/dist/react-native/diagnostics/tracing.d.ts +19 -0
  88. package/dist/react-native/diagnostics/tracing.d.ts.map +1 -0
  89. package/dist/react-native/diagnostics/tracing.js +40 -0
  90. package/dist/react-native/diagnostics/tracing.js.map +1 -0
  91. package/dist/react-native/eventData.d.ts +295 -0
  92. package/dist/react-native/eventData.d.ts.map +1 -0
  93. package/dist/react-native/eventData.js +247 -0
  94. package/dist/react-native/eventData.js.map +1 -0
  95. package/dist/react-native/eventDataAdapter.d.ts +69 -0
  96. package/dist/react-native/eventDataAdapter.d.ts.map +1 -0
  97. package/dist/react-native/eventDataAdapter.js +38 -0
  98. package/dist/react-native/eventDataAdapter.js.map +1 -0
  99. package/dist/react-native/eventDataBatch.d.ts +225 -0
  100. package/dist/react-native/eventDataBatch.d.ts.map +1 -0
  101. package/dist/react-native/eventDataBatch.js +301 -0
  102. package/dist/react-native/eventDataBatch.js.map +1 -0
  103. package/dist/react-native/eventHubBufferedProducerClient.d.ts +323 -0
  104. package/dist/react-native/eventHubBufferedProducerClient.d.ts.map +1 -0
  105. package/dist/react-native/eventHubBufferedProducerClient.js +301 -0
  106. package/dist/react-native/eventHubBufferedProducerClient.js.map +1 -0
  107. package/dist/react-native/eventHubConsumerClient.d.ts +293 -0
  108. package/dist/react-native/eventHubConsumerClient.d.ts.map +1 -0
  109. package/dist/react-native/eventHubConsumerClient.js +336 -0
  110. package/dist/react-native/eventHubConsumerClient.js.map +1 -0
  111. package/dist/react-native/eventHubConsumerClientModels.d.ts +218 -0
  112. package/dist/react-native/eventHubConsumerClientModels.d.ts.map +1 -0
  113. package/dist/react-native/eventHubConsumerClientModels.js +4 -0
  114. package/dist/react-native/eventHubConsumerClientModels.js.map +1 -0
  115. package/dist/react-native/eventHubProducerClient.d.ts +299 -0
  116. package/dist/react-native/eventHubProducerClient.d.ts.map +1 -0
  117. package/dist/react-native/eventHubProducerClient.js +366 -0
  118. package/dist/react-native/eventHubProducerClient.js.map +1 -0
  119. package/dist/react-native/eventHubSender.d.ts +227 -0
  120. package/dist/react-native/eventHubSender.d.ts.map +1 -0
  121. package/dist/react-native/eventHubSender.js +626 -0
  122. package/dist/react-native/eventHubSender.js.map +1 -0
  123. package/dist/react-native/eventPosition.d.ts +73 -0
  124. package/dist/react-native/eventPosition.d.ts.map +1 -0
  125. package/dist/react-native/eventPosition.js +121 -0
  126. package/dist/react-native/eventPosition.js.map +1 -0
  127. package/dist/react-native/eventProcessor.d.ts +232 -0
  128. package/dist/react-native/eventProcessor.d.ts.map +1 -0
  129. package/dist/react-native/eventProcessor.js +389 -0
  130. package/dist/react-native/eventProcessor.js.map +1 -0
  131. package/dist/react-native/eventhubConnectionConfig.d.ts +96 -0
  132. package/dist/react-native/eventhubConnectionConfig.d.ts.map +1 -0
  133. package/dist/react-native/eventhubConnectionConfig.js +98 -0
  134. package/dist/react-native/eventhubConnectionConfig.js.map +1 -0
  135. package/dist/react-native/impl/awaitableQueue.d.ts +25 -0
  136. package/dist/react-native/impl/awaitableQueue.d.ts.map +1 -0
  137. package/dist/react-native/impl/awaitableQueue.js +51 -0
  138. package/dist/react-native/impl/awaitableQueue.js.map +1 -0
  139. package/dist/react-native/impl/partitionAssigner.d.ts +29 -0
  140. package/dist/react-native/impl/partitionAssigner.d.ts.map +1 -0
  141. package/dist/react-native/impl/partitionAssigner.js +52 -0
  142. package/dist/react-native/impl/partitionAssigner.js.map +1 -0
  143. package/dist/react-native/impl/partitionGate.d.ts +27 -0
  144. package/dist/react-native/impl/partitionGate.d.ts.map +1 -0
  145. package/dist/react-native/impl/partitionGate.js +38 -0
  146. package/dist/react-native/impl/partitionGate.js.map +1 -0
  147. package/dist/react-native/impl/partitionKeyToIdMapper.d.ts +6 -0
  148. package/dist/react-native/impl/partitionKeyToIdMapper.d.ts.map +1 -0
  149. package/dist/react-native/impl/partitionKeyToIdMapper.js +111 -0
  150. package/dist/react-native/impl/partitionKeyToIdMapper.js.map +1 -0
  151. package/dist/react-native/inMemoryCheckpointStore.d.ts +44 -0
  152. package/dist/react-native/inMemoryCheckpointStore.d.ts.map +1 -0
  153. package/dist/react-native/inMemoryCheckpointStore.js +94 -0
  154. package/dist/react-native/inMemoryCheckpointStore.js.map +1 -0
  155. package/dist/react-native/index.d.ts +21 -0
  156. package/dist/react-native/index.d.ts.map +1 -0
  157. package/dist/react-native/index.js +12 -0
  158. package/dist/react-native/index.js.map +1 -0
  159. package/dist/react-native/loadBalancerStrategies/balancedStrategy.d.ts +30 -0
  160. package/dist/react-native/loadBalancerStrategies/balancedStrategy.d.ts.map +1 -0
  161. package/dist/react-native/loadBalancerStrategies/balancedStrategy.js +40 -0
  162. package/dist/react-native/loadBalancerStrategies/balancedStrategy.js.map +1 -0
  163. package/dist/react-native/loadBalancerStrategies/greedyStrategy.d.ts +24 -0
  164. package/dist/react-native/loadBalancerStrategies/greedyStrategy.d.ts.map +1 -0
  165. package/dist/react-native/loadBalancerStrategies/greedyStrategy.js +29 -0
  166. package/dist/react-native/loadBalancerStrategies/greedyStrategy.js.map +1 -0
  167. package/dist/react-native/loadBalancerStrategies/loadBalancingStrategy.d.ts +28 -0
  168. package/dist/react-native/loadBalancerStrategies/loadBalancingStrategy.d.ts.map +1 -0
  169. package/dist/react-native/loadBalancerStrategies/loadBalancingStrategy.js +245 -0
  170. package/dist/react-native/loadBalancerStrategies/loadBalancingStrategy.js.map +1 -0
  171. package/dist/react-native/loadBalancerStrategies/unbalancedStrategy.d.ts +20 -0
  172. package/dist/react-native/loadBalancerStrategies/unbalancedStrategy.d.ts.map +1 -0
  173. package/dist/react-native/loadBalancerStrategies/unbalancedStrategy.js +22 -0
  174. package/dist/react-native/loadBalancerStrategies/unbalancedStrategy.js.map +1 -0
  175. package/dist/react-native/logger.d.ts +37 -0
  176. package/dist/react-native/logger.d.ts.map +1 -0
  177. package/dist/react-native/logger.js +56 -0
  178. package/dist/react-native/logger.js.map +1 -0
  179. package/dist/react-native/managementClient.d.ts +145 -0
  180. package/dist/react-native/managementClient.d.ts.map +1 -0
  181. package/dist/react-native/managementClient.js +305 -0
  182. package/dist/react-native/managementClient.js.map +1 -0
  183. package/dist/react-native/models/private.d.ts +185 -0
  184. package/dist/react-native/models/private.d.ts.map +1 -0
  185. package/dist/react-native/models/private.js +4 -0
  186. package/dist/react-native/models/private.js.map +1 -0
  187. package/dist/react-native/models/public.d.ts +240 -0
  188. package/dist/react-native/models/public.d.ts.map +1 -0
  189. package/dist/react-native/models/public.js +18 -0
  190. package/dist/react-native/models/public.js.map +1 -0
  191. package/dist/react-native/package.json +3 -0
  192. package/dist/react-native/partitionProcessor.d.ts +134 -0
  193. package/dist/react-native/partitionProcessor.d.ts.map +1 -0
  194. package/dist/react-native/partitionProcessor.js +137 -0
  195. package/dist/react-native/partitionProcessor.js.map +1 -0
  196. package/dist/react-native/partitionPump.d.ts +38 -0
  197. package/dist/react-native/partitionPump.d.ts.map +1 -0
  198. package/dist/react-native/partitionPump.js +175 -0
  199. package/dist/react-native/partitionPump.js.map +1 -0
  200. package/dist/react-native/partitionReceiver.d.ts +82 -0
  201. package/dist/react-native/partitionReceiver.d.ts.map +1 -0
  202. package/dist/react-native/partitionReceiver.js +335 -0
  203. package/dist/react-native/partitionReceiver.js.map +1 -0
  204. package/dist/react-native/pumpManager.d.ts +72 -0
  205. package/dist/react-native/pumpManager.d.ts.map +1 -0
  206. package/dist/react-native/pumpManager.js +120 -0
  207. package/dist/react-native/pumpManager.js.map +1 -0
  208. package/dist/react-native/util/connectionStringUtils.d.ts +52 -0
  209. package/dist/react-native/util/connectionStringUtils.d.ts.map +1 -0
  210. package/dist/react-native/util/connectionStringUtils.js +48 -0
  211. package/dist/react-native/util/connectionStringUtils.js.map +1 -0
  212. package/dist/react-native/util/constants.d.ts +25 -0
  213. package/dist/react-native/util/constants.d.ts.map +1 -0
  214. package/dist/react-native/util/constants.js +27 -0
  215. package/dist/react-native/util/constants.js.map +1 -0
  216. package/dist/react-native/util/delayWithoutThrow.d.ts +8 -0
  217. package/dist/react-native/util/delayWithoutThrow.d.ts.map +1 -0
  218. package/dist/react-native/util/delayWithoutThrow.js +17 -0
  219. package/dist/react-native/util/delayWithoutThrow.js.map +1 -0
  220. package/dist/react-native/util/error.d.ts +39 -0
  221. package/dist/react-native/util/error.d.ts.map +1 -0
  222. package/dist/react-native/util/error.js +103 -0
  223. package/dist/react-native/util/error.js.map +1 -0
  224. package/dist/react-native/util/getPromiseParts.d.ts +10 -0
  225. package/dist/react-native/util/getPromiseParts.d.ts.map +1 -0
  226. package/dist/react-native/util/getPromiseParts.js +20 -0
  227. package/dist/react-native/util/getPromiseParts.js.map +1 -0
  228. package/dist/react-native/util/operationOptions.d.ts +16 -0
  229. package/dist/react-native/util/operationOptions.d.ts.map +1 -0
  230. package/dist/react-native/util/operationOptions.js +4 -0
  231. package/dist/react-native/util/operationOptions.js.map +1 -0
  232. package/dist/react-native/util/parseEndpoint.d.ts +11 -0
  233. package/dist/react-native/util/parseEndpoint.d.ts.map +1 -0
  234. package/dist/react-native/util/parseEndpoint.js +17 -0
  235. package/dist/react-native/util/parseEndpoint.js.map +1 -0
  236. package/dist/react-native/util/retries.d.ts +6 -0
  237. package/dist/react-native/util/retries.d.ts.map +1 -0
  238. package/dist/react-native/util/retries.js +13 -0
  239. package/dist/react-native/util/retries.js.map +1 -0
  240. package/dist/react-native/util/runtimeInfo-react-native.d.mts.map +1 -0
  241. package/dist/react-native/util/runtimeInfo-react-native.mjs.map +1 -0
  242. package/dist/react-native/util/runtimeInfo.d.ts +6 -0
  243. package/dist/react-native/util/runtimeInfo.js +20 -0
  244. package/dist/react-native/util/timerLoop.d.ts +26 -0
  245. package/dist/react-native/util/timerLoop.d.ts.map +1 -0
  246. package/dist/react-native/util/timerLoop.js +34 -0
  247. package/dist/react-native/util/timerLoop.js.map +1 -0
  248. package/dist/react-native/util/typeGuards.d.ts +8 -0
  249. package/dist/react-native/util/typeGuards.d.ts.map +1 -0
  250. package/dist/react-native/util/typeGuards.js +12 -0
  251. package/dist/react-native/util/typeGuards.js.map +1 -0
  252. package/dist/react-native/util/utils.d.ts +7 -0
  253. package/dist/react-native/util/utils.d.ts.map +1 -0
  254. package/dist/react-native/util/utils.js +13 -0
  255. package/dist/react-native/util/utils.js.map +1 -0
  256. package/dist/react-native/withAuth.d.ts +25 -0
  257. package/dist/react-native/withAuth.d.ts.map +1 -0
  258. package/dist/react-native/withAuth.js +84 -0
  259. package/dist/react-native/withAuth.js.map +1 -0
  260. package/package.json +16 -11
@@ -0,0 +1,305 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { Constants, RequestResponseLink, RetryOperationType, defaultCancellableLock, isSasTokenProvider, retry, translate, } from "@azure/core-amqp";
4
+ import { ReceiverEvents, SenderEvents } from "rhea-promise";
5
+ import { logErrorStackTrace, createSimpleLogger, logger, createManagementLogPrefix, } from "./logger.js";
6
+ import { throwErrorIfConnectionClosed, throwTypeErrorIfParameterMissing } from "./util/error.js";
7
+ import { toSpanOptions, tracingClient } from "./diagnostics/tracing.js";
8
+ import { getRetryAttemptTimeoutInMs } from "./util/retries.js";
9
+ import { withAuth } from "./withAuth.js";
10
+ import { getRandomName } from "./util/utils.js";
11
+ /**
12
+ * @internal
13
+ * Describes the EventHubs Management Client that talks
14
+ * to the $management endpoint over AMQP connection.
15
+ */
16
+ export class ManagementClient {
17
+ managementLock = getRandomName(Constants.managementRequestKey);
18
+ /**
19
+ * The name/path of the entity (hub name) for which the management
20
+ * request needs to be made.
21
+ */
22
+ entityPath;
23
+ /**
24
+ * The reply to Guid for the management client.
25
+ */
26
+ replyTo = getRandomName();
27
+ /**
28
+ * $management sender, receiver on the same session.
29
+ */
30
+ _mgmtReqResLink;
31
+ /**
32
+ * The address in the following form:
33
+ * `"$management"`.
34
+ */
35
+ address;
36
+ /**
37
+ * The token audience in the following form:
38
+ * `"sb://<your-namespace>.servicebus.windows.net/<event-hub-name>/$management"`.
39
+ */
40
+ audience;
41
+ /**
42
+ * Provides relevant information about the amqp connection,
43
+ * cbs and $management sessions, token provider, sender and receivers.
44
+ */
45
+ _context;
46
+ /**
47
+ * The authentication loop that keeps the token refreshed.
48
+ */
49
+ authLoop;
50
+ logger;
51
+ /**
52
+ * Instantiates the management client.
53
+ * @param context - The connection context.
54
+ * @param address - The address for the management endpoint. For IotHub it will be
55
+ * `/messages/events/$management`.
56
+ */
57
+ constructor(context, { address, audience } = {}) {
58
+ this.address = address ?? Constants.management;
59
+ this.audience = audience ?? context.config.getManagementAudience();
60
+ this._context = context;
61
+ const logPrefix = createManagementLogPrefix(this._context.connectionId);
62
+ this.logger = createSimpleLogger(logger, logPrefix);
63
+ this.entityPath = context.config.entityPath;
64
+ }
65
+ /**
66
+ * Gets the security token for the management application properties.
67
+ * @internal
68
+ */
69
+ async getSecurityToken() {
70
+ if (isSasTokenProvider(this._context.tokenCredential)) {
71
+ // the security_token has the $management address removed from the end of the audience
72
+ // expected audience: sb://fully.qualified.namespace/event-hub-name/$management
73
+ const audienceParts = this.audience.split("/");
74
+ // for management links, address should be '$management'
75
+ if (audienceParts[audienceParts.length - 1] === this.address) {
76
+ audienceParts.pop();
77
+ }
78
+ const audience = audienceParts.join("/");
79
+ return this._context.tokenCredential.getToken(audience);
80
+ }
81
+ // aad credentials use the aad scope
82
+ return this._context.tokenCredential.getToken(Constants.aadEventHubsScope);
83
+ }
84
+ /**
85
+ * Provides the eventhub runtime information.
86
+ */
87
+ async getEventHubProperties(options = {}) {
88
+ throwErrorIfConnectionClosed(this._context);
89
+ return tracingClient.withSpan("ManagementClient.getEventHubProperties", options, async (updatedOptions) => {
90
+ try {
91
+ const securityToken = await this.getSecurityToken();
92
+ const request = {
93
+ body: Buffer.from(JSON.stringify([])),
94
+ message_id: getRandomName(),
95
+ reply_to: this.replyTo,
96
+ application_properties: {
97
+ operation: Constants.readOperation,
98
+ name: this.entityPath,
99
+ type: `${Constants.vendorString}:${Constants.eventHub}`,
100
+ security_token: securityToken?.token,
101
+ },
102
+ };
103
+ const info = await this._makeManagementRequest(request, {
104
+ ...updatedOptions,
105
+ requestName: "getHubRuntimeInformation",
106
+ });
107
+ const runtimeInfo = {
108
+ name: info.name,
109
+ createdOn: new Date(info.created_at),
110
+ partitionIds: info.partition_ids,
111
+ isGeoDrEnabled: info.georeplication_factor > 1,
112
+ };
113
+ logger.verbose("the hub runtime info is: %O", runtimeInfo);
114
+ return runtimeInfo;
115
+ }
116
+ catch (error) {
117
+ logger.warning(`an error occurred while getting the hub runtime information: ${error?.name}: ${error?.message}`);
118
+ logErrorStackTrace(error);
119
+ throw error;
120
+ }
121
+ }, toSpanOptions(this._context.config));
122
+ }
123
+ /**
124
+ * Provides information about the specified partition.
125
+ * @param partitionId - Partition ID for which partition information is required.
126
+ */
127
+ async getPartitionProperties(partitionId, options = {}) {
128
+ throwErrorIfConnectionClosed(this._context);
129
+ throwTypeErrorIfParameterMissing(this._context.connectionId, "getPartitionProperties", "partitionId", partitionId);
130
+ partitionId = String(partitionId);
131
+ return tracingClient.withSpan("ManagementClient.getPartitionProperties", options, async (updatedOptions) => {
132
+ try {
133
+ const securityToken = await this.getSecurityToken();
134
+ const request = {
135
+ body: Buffer.from(JSON.stringify([])),
136
+ message_id: getRandomName(),
137
+ reply_to: this.replyTo,
138
+ application_properties: {
139
+ operation: Constants.readOperation,
140
+ name: this.entityPath,
141
+ type: `${Constants.vendorString}:${Constants.partition}`,
142
+ partition: `${partitionId}`,
143
+ security_token: securityToken?.token,
144
+ },
145
+ };
146
+ const info = await this._makeManagementRequest(request, {
147
+ ...updatedOptions,
148
+ requestName: "getPartitionInformation",
149
+ });
150
+ const partitionInfo = {
151
+ beginningSequenceNumber: info.begin_sequence_number,
152
+ eventHubName: info.name,
153
+ lastEnqueuedOffset: info.last_enqueued_offset,
154
+ lastEnqueuedOnUtc: new Date(info.last_enqueued_time_utc),
155
+ lastEnqueuedSequenceNumber: info.last_enqueued_sequence_number,
156
+ partitionId: info.partition,
157
+ isEmpty: info.is_partition_empty,
158
+ };
159
+ logger.verbose("the partition info is: %O.", partitionInfo);
160
+ return partitionInfo;
161
+ }
162
+ catch (error) {
163
+ logger.warning(`an error occurred while getting the partition information: ${error?.name}: ${error?.message}`);
164
+ logErrorStackTrace(error);
165
+ throw error;
166
+ }
167
+ }, toSpanOptions(this._context.config));
168
+ }
169
+ /**
170
+ * Closes the AMQP management session to the Event Hub for this client,
171
+ * returning a promise that will be resolved when disconnection is completed.
172
+ */
173
+ async close() {
174
+ try {
175
+ // Always stop the auth loop when closing the management link.
176
+ this.authLoop?.stop();
177
+ if (this._isMgmtRequestResponseLinkOpen()) {
178
+ const mgmtLink = this._mgmtReqResLink;
179
+ this._mgmtReqResLink = undefined;
180
+ await mgmtLink.close();
181
+ logger.info("successfully closed the management session.");
182
+ }
183
+ }
184
+ catch (err) {
185
+ const msg = `an error occurred while closing the management session: ${err?.name}: ${err?.message}`;
186
+ logger.warning(msg);
187
+ logErrorStackTrace(err);
188
+ throw new Error(msg);
189
+ }
190
+ }
191
+ async _init({ abortSignal, timeoutInMs, }) {
192
+ const createLink = async () => {
193
+ const rxopt = {
194
+ source: { address: this.address },
195
+ name: this.replyTo,
196
+ target: { address: this.replyTo },
197
+ onSessionError: (context) => {
198
+ const ehError = translate(context.session.error);
199
+ logger.verbose("an error occurred on the session for request/response links for " + "$management: %O", ehError);
200
+ },
201
+ };
202
+ const sropt = {
203
+ target: { address: this.address },
204
+ };
205
+ logger.verbose("creating sender/receiver links with " + "srOpts: %o, receiverOpts: %O.", sropt, rxopt);
206
+ this._mgmtReqResLink = await RequestResponseLink.create(this._context.connection, sropt, rxopt, { abortSignal });
207
+ this._mgmtReqResLink.sender.on(SenderEvents.senderError, (context) => {
208
+ const ehError = translate(context.sender.error);
209
+ logger.verbose("an error occurred on the $management sender link.. %O", ehError);
210
+ });
211
+ this._mgmtReqResLink.receiver.on(ReceiverEvents.receiverError, (context) => {
212
+ const ehError = translate(context.receiver.error);
213
+ logger.verbose("an error occurred on the $management receiver link.. %O", ehError);
214
+ });
215
+ logger.verbose("created sender '%s' and receiver '%s' links", this._mgmtReqResLink.sender.name, this._mgmtReqResLink.receiver.name);
216
+ };
217
+ try {
218
+ if (!this._isMgmtRequestResponseLinkOpen()) {
219
+ // Wait for the connectionContext to be ready to open the link.
220
+ await this._context.readyToOpenLink();
221
+ this.authLoop = await withAuth(createLink, this._context, this.audience, timeoutInMs, this.logger, { abortSignal });
222
+ }
223
+ }
224
+ catch (err) {
225
+ const translatedError = translate(err);
226
+ logger.warning(`an error occurred while establishing the links: ${translatedError?.name}: ${translatedError?.message}`);
227
+ logErrorStackTrace(translatedError);
228
+ throw translatedError;
229
+ }
230
+ }
231
+ /**
232
+ * Helper method to make the management request
233
+ * @param request - The AMQP message to send
234
+ * @param options - The options to use when sending a request over a $management link
235
+ */
236
+ async _makeManagementRequest(request, options = {}) {
237
+ const retryOptions = options.retryOptions || {};
238
+ try {
239
+ const abortSignal = options && options.abortSignal;
240
+ const sendOperationPromise = async () => {
241
+ let count = 0;
242
+ const retryTimeoutInMs = getRetryAttemptTimeoutInMs(options.retryOptions);
243
+ let timeTakenByInit = 0;
244
+ if (!this._isMgmtRequestResponseLinkOpen()) {
245
+ logger.verbose("acquiring lock to get the management req res link.");
246
+ const initOperationStartTime = Date.now();
247
+ try {
248
+ await defaultCancellableLock.acquire(this.managementLock, () => {
249
+ const acquireLockEndTime = Date.now();
250
+ const timeoutInMs = retryTimeoutInMs - (acquireLockEndTime - initOperationStartTime);
251
+ return this._init({ abortSignal, timeoutInMs });
252
+ }, { abortSignal, timeoutInMs: retryTimeoutInMs });
253
+ }
254
+ catch (err) {
255
+ const translatedError = translate(err);
256
+ logger.warning("an error occurred while creating the link: %s", `${translatedError?.name}: ${translatedError?.message}`);
257
+ logErrorStackTrace(translatedError);
258
+ throw translatedError;
259
+ }
260
+ timeTakenByInit = Date.now() - initOperationStartTime;
261
+ }
262
+ const remainingOperationTimeoutInMs = retryTimeoutInMs - timeTakenByInit;
263
+ const sendRequestOptions = {
264
+ abortSignal: options.abortSignal,
265
+ requestName: options.requestName,
266
+ timeoutInMs: remainingOperationTimeoutInMs,
267
+ };
268
+ count++;
269
+ if (count !== 1) {
270
+ // Generate a new message_id every time after the first attempt
271
+ request.message_id = getRandomName();
272
+ }
273
+ else if (!request.message_id) {
274
+ // Set the message_id in the first attempt only if it is not set
275
+ request.message_id = getRandomName();
276
+ }
277
+ return this._mgmtReqResLink.sendRequest(request, sendRequestOptions);
278
+ };
279
+ const config = Object.defineProperties({
280
+ operation: sendOperationPromise,
281
+ operationType: RetryOperationType.management,
282
+ abortSignal: abortSignal,
283
+ retryOptions: retryOptions,
284
+ }, {
285
+ connectionId: {
286
+ enumerable: true,
287
+ get: () => {
288
+ return this._context.connectionId;
289
+ },
290
+ },
291
+ });
292
+ return (await retry(config)).body;
293
+ }
294
+ catch (err) {
295
+ const translatedError = translate(err);
296
+ logger.warning("an error occurred during send on management request-response link with address: %s", `${translatedError?.name}: ${translatedError?.message}`);
297
+ logErrorStackTrace(translatedError);
298
+ throw translatedError;
299
+ }
300
+ }
301
+ _isMgmtRequestResponseLinkOpen() {
302
+ return this._mgmtReqResLink && this._mgmtReqResLink.isOpen();
303
+ }
304
+ }
305
+ //# sourceMappingURL=managementClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managementClient.js","sourceRoot":"","sources":["../../src/managementClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,EACL,SAAS,GACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,EACN,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AAKjG,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAkEhD;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAClB,cAAc,GAAW,aAAa,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAChF;;;OAGG;IACc,UAAU,CAAS;IACpC;;OAEG;IACc,OAAO,GAAW,aAAa,EAAE,CAAC;IACnD;;OAEG;IACK,eAAe,CAAuB;IAC9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AG,eAAe,EAAE,IAAI,KAAK,eAAe,EAAE,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 type { RetryConfig, RetryOptions, SendRequestOptions } from \"@azure/core-amqp\";\nimport {\n Constants,\n RequestResponseLink,\n RetryOperationType,\n defaultCancellableLock,\n isSasTokenProvider,\n retry,\n translate,\n} from \"@azure/core-amqp\";\nimport type { EventContext, Message, ReceiverOptions, SenderOptions } from \"rhea-promise\";\nimport { ReceiverEvents, SenderEvents } from \"rhea-promise\";\nimport type { SimpleLogger } from \"./logger.js\";\nimport {\n logErrorStackTrace,\n createSimpleLogger,\n logger,\n createManagementLogPrefix,\n} from \"./logger.js\";\nimport { throwErrorIfConnectionClosed, throwTypeErrorIfParameterMissing } from \"./util/error.js\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { AccessToken } from \"@azure/core-auth\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { OperationOptions } from \"./util/operationOptions.js\";\nimport { toSpanOptions, tracingClient } from \"./diagnostics/tracing.js\";\nimport { getRetryAttemptTimeoutInMs } from \"./util/retries.js\";\nimport type { TimerLoop } from \"./util/timerLoop.js\";\nimport { withAuth } from \"./withAuth.js\";\nimport { getRandomName } from \"./util/utils.js\";\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"]}
@@ -0,0 +1,185 @@
1
+ import type { LoadBalancingStrategy } from "../loadBalancerStrategies/loadBalancingStrategy.js";
2
+ import type { RetryOptions } from "@azure/core-amqp";
3
+ import type { Typed } from "rhea-promise";
4
+ import type { SubscribeOptions } from "../eventHubConsumerClientModels.js";
5
+ import type { idempotentProducerAmqpPropertyNames } from "../util/constants.js";
6
+ /**
7
+ * The set of options to configure the behavior of an `EventHubProducer`.
8
+ * These can be specified when creating the producer via the `createProducer` method.
9
+ * - `partitionId` : The string identifier of the partition that the producer can be bound to.
10
+ * - `retryOptions` : The retry options used to govern retry attempts when an issue is encountered while sending events.
11
+ * A simple usage can be `{ "maxRetries": 4 }`.
12
+ * @internal
13
+ */
14
+ export interface EventHubProducerOptions {
15
+ /**
16
+ * The identifier of the partition that the producer will be bound to.
17
+ * If a value is provided, all events sent using the producer will reach the same partition.
18
+ * If no value is provided, the service will determine the partition to which the event will be sent.
19
+ */
20
+ partitionId?: string;
21
+ /**
22
+ * The retry options used to govern retry attempts when an issue is encountered while sending events.
23
+ * If no value is provided here, the retry options set when creating the `EventHubClient` is used.
24
+ */
25
+ retryOptions?: RetryOptions;
26
+ }
27
+ /**
28
+ * @internal
29
+ */
30
+ export type OperationNames = "getEventHubProperties" | "getPartitionIds" | "getPartitionProperties";
31
+ /**
32
+ * @internal
33
+ */
34
+ export interface CommonEventProcessorOptions extends Required<Pick<SubscribeOptions, "maxBatchSize" | "maxWaitTimeInSeconds">>, Pick<SubscribeOptions, Exclude<keyof SubscribeOptions, "maxBatchSize" | "maxWaitTimeInSeconds">> {
35
+ /**
36
+ * A load balancing strategy that determines how to claim partitions.
37
+ */
38
+ loadBalancingStrategy: LoadBalancingStrategy;
39
+ /**
40
+ * An optional ownerId to use rather than using an internally generated ID
41
+ * This allows you to logically group a series of processors together (for instance
42
+ * like we do with EventHubConsumerClient)
43
+ */
44
+ ownerId?: string;
45
+ /**
46
+ * The maximum amount of time since a PartitionOwnership was updated
47
+ * to use to determine if a partition is no longer claimed.
48
+ * Setting this value to 0 will cause the default value to be used.
49
+ */
50
+ inactiveTimeLimitInMs?: number;
51
+ /**
52
+ * Retry Options to be used when receiving events
53
+ */
54
+ retryOptions?: RetryOptions;
55
+ }
56
+ /**
57
+ * The set of options to configure the behavior of an `EventHubConsumer`.
58
+ * These can be specified when creating the consumer using the `createConsumer` method.
59
+ * - `ownerLevel` : A number indicating that the consumer intends to be an exclusive consumer of events resulting in other
60
+ * consumers to fail if their `ownerLevel` is lower or doesn't exist.
61
+ * - `retryOptions`: The retry options used to govern retry attempts when an issue is encountered while receiving events.
62
+ * A simple usage can be `{ "maxRetries": 4 }`.
63
+ * - `skipParsingBodyAsJson` : Option to disable the client from running JSON.parse() on the message body when receiving the message.
64
+ * Not applicable if the message was sent with AMQP body type value or sequence. Use this option when you prefer to work directly with
65
+ * the bytes present in the message body than have the client attempt to parse it.
66
+ *
67
+ * Example usage:
68
+ * ```ts snippet:ignore
69
+ * {
70
+ * retryOptions: {
71
+ * maxRetries: 4
72
+ * },
73
+ * trackLastEnqueuedEventProperties: false,
74
+ * skipParsingBodyAsJson: true
75
+ * }
76
+ * ```
77
+ * @internal
78
+ */
79
+ export interface PartitionReceiverOptions {
80
+ /**
81
+ * The owner level associated with an exclusive consumer.
82
+ *
83
+ * When provided, the owner level indicates that a consumer is intended to be the exclusive receiver of events for the
84
+ * requested partition and the associated consumer group.
85
+ * When multiple consumers exist for the same partition/consumer group pair, then the ones with lower or no
86
+ * `ownerLevel` will get a `ReceiverDisconnectedError` during the next attempted receive operation.
87
+ */
88
+ ownerLevel?: number;
89
+ /**
90
+ * The retry options used to govern retry attempts when an issue is encountered while receiving events.
91
+ * If no value is provided here, the retry options set when creating the `EventHubClient` is used.
92
+ */
93
+ retryOptions?: RetryOptions;
94
+ /**
95
+ * Indicates whether or not the consumer should request information on the last enqueued event on its
96
+ * associated partition, and track that information as events are received.
97
+
98
+ * When information about the partition's last enqueued event is being tracked, each event received
99
+ * from the Event Hubs service will carry metadata about the partition that it otherwise would not. This results in a small amount of
100
+ * additional network bandwidth consumption that is generally a favorable trade-off when considered
101
+ * against periodically making requests for partition properties using the Event Hub client.
102
+ */
103
+ trackLastEnqueuedEventProperties?: boolean;
104
+ /**
105
+ * Option to disable the client from running JSON.parse() on the message body when receiving the message.
106
+ * Not applicable if the message was sent with AMQP body type value or sequence. Use this option when you
107
+ * prefer to work directly with the bytes present in the message body than have the client attempt to parse it.
108
+ */
109
+ skipParsingBodyAsJson?: boolean;
110
+ /**
111
+ * The count of events requested eagerly and queued without regard to whether a read was requested.
112
+ */
113
+ prefetchCount?: number;
114
+ }
115
+ /**
116
+ * @internal
117
+ */
118
+ export interface IdempotentLinkProperties {
119
+ [idempotentProducerAmqpPropertyNames.epoch]: Typed | null;
120
+ [idempotentProducerAmqpPropertyNames.producerId]: Typed | null;
121
+ [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: Typed | null;
122
+ }
123
+ /**
124
+ * The set of options that can be specified for an `EventHubProducerClient`
125
+ * to influence its behavior when publishing directly to an Event Hub partition.
126
+ *
127
+ * These options are ignored when publishing to the Event Hubs gateway for automatic
128
+ * routing or when using a partition key.
129
+ */
130
+ export interface PartitionPublishingOptions {
131
+ /**
132
+ * The owner level indicates that a publishing is intended to be performed exclusively for events in the
133
+ * requested partition in the context of the associated producer group.
134
+ *
135
+ * To do so, publishing will attempt to assert ownership over the partition;
136
+ * in the case where more than one publisher in the producer group attempts to assert ownership for the same partition,
137
+ * the one having a larger `ownerLevel` value will "win".
138
+ */
139
+ ownerLevel?: number;
140
+ /**
141
+ * The identifier of the producer group that this producer is associated with when publishing to the associated partition.
142
+ * Events will be published in the context of this group.
143
+ *
144
+ * If `undefined`, the Event Hubs service will control the value.
145
+ *
146
+ * The producer group is only recognized and relevant when certain features of the producer are enabled.
147
+ * For example, it is used by idempotent publishing.
148
+ */
149
+ producerGroupId?: number;
150
+ /**
151
+ * The starting number that should be used for the automatic sequencing of events for the associated partition, when published by this producer.
152
+ *
153
+ * If `undefined`, the Event Hubs service will control the value.
154
+ *
155
+ * The producer group is only recognized and relevant when certain features of the producer are enabled.
156
+ * For example, it is used by idempotent publishing.
157
+ */
158
+ startingSequenceNumber?: number;
159
+ }
160
+ /**
161
+ * Describes the information about the state of publishing for a partition.
162
+ */
163
+ export interface PartitionPublishingProperties {
164
+ /**
165
+ * Indicates whether or not idempotent publishing is enabled for the producer and, by extension, the associated partition.
166
+ */
167
+ isIdempotentPublishingEnabled: boolean;
168
+ /**
169
+ * The owner level of the producer publishing to the associated partition.
170
+ */
171
+ ownerLevel?: number;
172
+ /**
173
+ * The partition id the properties are associated with.
174
+ */
175
+ partitionId: string;
176
+ /**
177
+ * The identifier of the producer group for which this producer is publishing to the associated partition.
178
+ */
179
+ producerGroupId?: number;
180
+ /**
181
+ * The sequence number assigned to the event that was most recently published to the associated partition successfully.
182
+ */
183
+ lastPublishedSequenceNumber?: number;
184
+ }
185
+ //# sourceMappingURL=private.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private.d.ts","sourceRoot":"","sources":["../../../src/models/private.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,sBAAsB,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;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;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,6BAA6B,EAAE,OAAO,CAAC;IACvC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACtC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=private.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private.js","sourceRoot":"","sources":["../../../src/models/private.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { LoadBalancingStrategy } from \"../loadBalancerStrategies/loadBalancingStrategy.js\";\nimport type { RetryOptions } from \"@azure/core-amqp\";\nimport type { Typed } from \"rhea-promise\";\nimport type { SubscribeOptions } from \"../eventHubConsumerClientModels.js\";\nimport type { idempotentProducerAmqpPropertyNames } from \"../util/constants.js\";\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 * ```ts snippet:ignore\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"]}