@azure/event-hubs 5.7.0-beta.1 → 5.7.0

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 (31) hide show
  1. package/CHANGELOG.md +1 -9
  2. package/README.md +1 -1
  3. package/dist/index.js +38 -729
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/src/diagnostics/instrumentEventData.js +15 -33
  6. package/dist-esm/src/diagnostics/instrumentEventData.js.map +1 -1
  7. package/dist-esm/src/diagnostics/tracing.js.map +1 -1
  8. package/dist-esm/src/eventDataBatch.js +17 -6
  9. package/dist-esm/src/eventDataBatch.js.map +1 -1
  10. package/dist-esm/src/eventHubProducerClient.js +11 -2
  11. package/dist-esm/src/eventHubProducerClient.js.map +1 -1
  12. package/dist-esm/src/index.js +0 -1
  13. package/dist-esm/src/index.js.map +1 -1
  14. package/dist-esm/src/util/constants.js +1 -1
  15. package/dist-esm/src/util/constants.js.map +1 -1
  16. package/package.json +15 -19
  17. package/types/3.1/event-hubs.d.ts +2 -287
  18. package/types/latest/event-hubs.d.ts +2 -310
  19. package/types/latest/tsdoc-metadata.json +1 -1
  20. package/dist-esm/src/batchingPartitionChannel.js +0 -241
  21. package/dist-esm/src/batchingPartitionChannel.js.map +0 -1
  22. package/dist-esm/src/eventHubBufferedProducerClient.js +0 -242
  23. package/dist-esm/src/eventHubBufferedProducerClient.js.map +0 -1
  24. package/dist-esm/src/impl/awaitableQueue.js +0 -46
  25. package/dist-esm/src/impl/awaitableQueue.js.map +0 -1
  26. package/dist-esm/src/impl/partitionAssigner.js +0 -54
  27. package/dist-esm/src/impl/partitionAssigner.js.map +0 -1
  28. package/dist-esm/src/impl/patitionKeyToIdMapper.js +0 -106
  29. package/dist-esm/src/impl/patitionKeyToIdMapper.js.map +0 -1
  30. package/dist-esm/src/util/getPromiseParts.js +0 -20
  31. package/dist-esm/src/util/getPromiseParts.js.map +0 -1
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { AbortSignalLike } from '@azure/abort-controller';
3
3
  import { AmqpAnnotatedMessage } from '@azure/core-amqp';
4
- import { AzureLogger } from '@azure/logger';
5
4
  import { MessagingError } from '@azure/core-amqp';
6
5
  import { NamedKeyCredential } from '@azure/core-auth';
7
6
  import { OperationTracingOptions } from '@azure/core-tracing';
@@ -13,22 +12,6 @@ import { SpanContext } from '@azure/core-tracing';
13
12
  import { TokenCredential } from '@azure/core-auth';
14
13
  import { WebSocketImpl } from 'rhea-promise';
15
14
  import { WebSocketOptions } from '@azure/core-amqp';
16
- /**
17
- * Options to configure the `close` method on the `EventHubBufferedProducerClient`.
18
- */
19
- export declare interface BufferedCloseOptions extends OperationOptions {
20
- /**
21
- * When `true`, all buffered events that are pending should be sent before closing.
22
- * When `false`, abandon all buffered events and close immediately.
23
- * Defaults to `true`.
24
- */
25
- flush?: boolean;
26
- }
27
- /**
28
- * Options to configure the `flush` method on the `EventHubBufferedProducerClient`.
29
- */
30
- export declare interface BufferedFlushOptions extends OperationOptions {
31
- }
32
15
  /**
33
16
  * A checkpoint is meant to represent the last successfully processed event by the user from a particular
34
17
  * partition of a consumer group in an Event Hub instance.
@@ -179,11 +162,6 @@ export declare interface CreateBatchOptions extends OperationOptions {
179
162
  * first event in the partition which has not expired due to the retention policy.
180
163
  */
181
164
  export declare const earliestEventPosition: EventPosition;
182
- /**
183
- * Options to configure the `enqueueEvents` method on the `EventHubBufferedProcuerClient`.
184
- */
185
- export declare interface EnqueueEventOptions extends SendBatchOptions {
186
- }
187
165
  /**
188
166
  * The interface that describes the data to be sent to Event Hub.
189
167
  * Use this as a reference when creating the object to be sent when using the `EventHubProducerClient`.
@@ -270,237 +248,6 @@ export declare interface EventDataBatch {
270
248
  */
271
249
  tryAdd(eventData: EventData | AmqpAnnotatedMessage, options?: TryAddOptions): boolean;
272
250
  }
273
- /**
274
- * The `EventHubBufferedProducerClient`is used to publish events to a specific Event Hub.
275
- *
276
- * The `EventHubBufferedProducerClient` does not publish events immediately.
277
- * Instead, events are buffered so they can be efficiently batched and published
278
- * when the batch is full or the `maxWaitTimeInMs` has elapsed with no new events
279
- * enqueued.
280
- *
281
- * Depending on the options specified when events are enqueued, they may be
282
- * automatically assigned to a partition, grouped according to the specified partition key,
283
- * or assigned a specifically requested partition.
284
- *
285
- * This model is intended to shift the burden of batch management from callers, at the cost of
286
- * non-deterministic timing, for when events will be published. There are additional trade-offs
287
- * to consider, as well:
288
- * - If the application crashes, events in the buffer will not have been published. To prevent
289
- * data loss, callers are encouraged to track publishing progress using the
290
- * `onSendEventsSuccessHandler` and `onSendEventsErrorHandler` handlers.
291
- * - Events specifying a partition key may be assigned a different partition than those using
292
- * the same key with other producers.
293
- * - In the unlikely event that a partition becomes temporarily unavailable, the
294
- * `EventHubBufferedProducerClient` may take longer to recover than other producers.
295
- *
296
- * In scenarios where it is important to have events published immediately with a deterministic
297
- * outcome, ensure that partition keys are assigned to a partition consistent with other
298
- * publishers, or where maximizing availability is a requirement, using the
299
- * `EventHubProducerClient` is recommended.
300
- */
301
- export declare class EventHubBufferedProducerClient {
302
- /**
303
- * Controls the `abortSignal` passed to each `BatchingPartitionChannel`.
304
- * Used to signal when a channel should stop waiting for events.
305
- */
306
- private _abortController;
307
- /**
308
- * Indicates whether the client has been explicitly closed.
309
- */
310
- private _isClosed;
311
- /**
312
- * Handles assigning partitions.
313
- */
314
- private _partitionAssigner;
315
- /**
316
- * The known partitionIds that will be used when assigning events to partitions.
317
- */
318
- private _partitionIds;
319
- /**
320
- * The EventHubProducerClient to use when creating and sending batches to the Event Hub.
321
- */
322
- private _producer;
323
- /**
324
- * Mapping of partitionIds to `BatchingPartitionChannels`.
325
- * Each `BatchingPartitionChannel` handles buffering events and backpressure independently.
326
- */
327
- private _partitionChannels;
328
- /**
329
- * The options passed by the user when creating the EventHubBufferedProducerClient instance.
330
- */
331
- private _clientOptions;
332
- readonly eventHubName: string;
333
- readonly fullyQualifiedNamespace: string;
334
- /**
335
- * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.
336
- * Use the `options` parmeter to configure retry policy or proxy settings.
337
- * @param connectionString - The connection string to use for connecting to the Event Hub instance.
338
- * It is expected that the shared key properties and the Event Hub path are contained in this connection string.
339
- * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.
340
- * @param options - A set of options to apply when configuring the client.
341
- * - `retryOptions` : Configures the retry policy for all the operations on the client.
342
- * For example, `{ "maxRetries": 4 }` or `{ "maxRetries": 4, "retryDelayInMs": 30000 }`.
343
- * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.
344
- * - `userAgent` : A string to append to the built in user agent string that is passed to the service.
345
- */
346
- constructor(connectionString: string, options: EventHubBufferedProducerClientOptions);
347
- /**
348
- * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.
349
- * Use the `options` parmeter to configure retry policy or proxy settings.
350
- * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.
351
- * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,
352
- * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.
353
- * @param eventHubName - The name of the specific Event Hub to connect the client to.
354
- * @param options - A set of options to apply when configuring the client.
355
- * - `retryOptions` : Configures the retry policy for all the operations on the client.
356
- * For example, `{ "maxRetries": 4 }` or `{ "maxRetries": 4, "retryDelayInMs": 30000 }`.
357
- * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.
358
- * - `userAgent` : A string to append to the built in user agent string that is passed to the service.
359
- */
360
- constructor(connectionString: string, eventHubName: string, options: EventHubBufferedProducerClientOptions);
361
- /**
362
- * The `EventHubBufferedProducerClient` class is used to send events to an Event Hub.
363
- * Use the `options` parmeter to configure retry policy or proxy settings.
364
- * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to
365
- * <yournamespace>.servicebus.windows.net
366
- * @param eventHubName - The name of the specific Event Hub to connect the client to.
367
- * @param credential - An credential object used by the client to get the token to authenticate the connection
368
- * with the Azure Event Hubs service.
369
- * See &commat;azure/identity for creating credentials that support AAD auth.
370
- * Use the `AzureNamedKeyCredential` from &commat;azure/core-auth if you want to pass in a `SharedAccessKeyName`
371
- * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively
372
- * in `AzureNamedKeyCredential`.
373
- * Use the `AzureSASCredential` from &commat;azure/core-auth if you want to pass in a `SharedAccessSignature`
374
- * without using a connection string. This field maps to `signature` in `AzureSASCredential`.
375
- * @param options - A set of options to apply when configuring the client.
376
- * - `retryOptions` : Configures the retry policy for all the operations on the client.
377
- * For example, `{ "maxRetries": 4 }` or `{ "maxRetries": 4, "retryDelayInMs": 30000 }`.
378
- * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.
379
- * - `userAgent` : A string to append to the built in user agent string that is passed to the service.
380
- */
381
- constructor(fullyQualifiedNamespace: string, eventHubName: string, credential: TokenCredential | NamedKeyCredential | SASCredential, options: EventHubBufferedProducerClientOptions);
382
- /**
383
- * Closes the AMQP connection to the Event Hub instance,
384
- * returning a promise that will be resolved when disconnection is completed.
385
- *
386
- * This will wait for enqueued events to be flushed to the service before closing
387
- * the connection.
388
- * To close without flushing, set the `flush` option to `false`.
389
- *
390
- * @param options - The set of options to apply to the operation call.
391
- * @returns Promise<void>
392
- * @throws Error if the underlying connection encounters an error while closing.
393
- */
394
- close(options?: BufferedCloseOptions): Promise<void>;
395
- /**
396
- * Enqueues an event into the buffer to be published to the Event Hub.
397
- * If there is no capacity in the buffer when this method is invoked,
398
- * it will wait for space to become available and ensure that the event
399
- * has been enqueued.
400
- *
401
- * When this call returns, the event has been accepted into the buffer,
402
- * but it may not have been published yet.
403
- * Publishing will take place at a nondeterministic point in the future as the buffer is processed.
404
- *
405
- * @param events - An {@link EventData} or `AmqpAnnotatedMessage`.
406
- * @param options - A set of options that can be specified to influence the way in which
407
- * the event is sent to the associated Event Hub.
408
- * - `abortSignal` : A signal used to cancel the enqueueEvent operation.
409
- * - `partitionId` : The partition this set of events will be sent to. If set, `partitionKey` can not be set.
410
- * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.
411
- * @returns The total number of events that are currently buffered and waiting to be published, across all partitions.
412
- */
413
- enqueueEvent(event: EventData | AmqpAnnotatedMessage, options?: EnqueueEventOptions): Promise<number>;
414
- /**
415
- * Enqueues events into the buffer to be published to the Event Hub.
416
- * If there is no capacity in the buffer when this method is invoked,
417
- * it will wait for space to become available and ensure that the events
418
- * have been enqueued.
419
- *
420
- * When this call returns, the events have been accepted into the buffer,
421
- * but it may not have been published yet.
422
- * Publishing will take place at a nondeterministic point in the future as the buffer is processed.
423
- *
424
- * @param events - An array of {@link EventData} or `AmqpAnnotatedMessage`.
425
- * @param options - A set of options that can be specified to influence the way in which
426
- * events are sent to the associated Event Hub.
427
- * - `abortSignal` : A signal used to cancel the enqueueEvents operation.
428
- * - `partitionId` : The partition this set of events will be sent to. If set, `partitionKey` can not be set.
429
- * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.
430
- * @returns The total number of events that are currently buffered and waiting to be published, across all partitions.
431
- */
432
- enqueueEvents(events: EventData[] | AmqpAnnotatedMessage[], options?: EnqueueEventOptions): Promise<number>;
433
- /**
434
- * Attempts to publish all events in the buffer immediately.
435
- * This may result in multiple batches being published,
436
- * the outcome of each of which will be individually reported by
437
- * the `onSendEventsSuccessHandler` and `onSendEventsErrorHandler` handlers.
438
- *
439
- * @param options - The set of options to apply to the operation call.
440
- */
441
- flush(options?: BufferedFlushOptions): Promise<void>;
442
- /**
443
- * Provides the Event Hub runtime information.
444
- * @param options - The set of options to apply to the operation call.
445
- * @returns A promise that resolves with information about the Event Hub instance.
446
- * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.
447
- * @throws AbortError if the operation is cancelled via the abortSignal.
448
- */
449
- getEventHubProperties(options?: GetEventHubPropertiesOptions): Promise<EventHubProperties>;
450
- /**
451
- * Provides the id for each partition associated with the Event Hub.
452
- * @param options - The set of options to apply to the operation call.
453
- * @returns A promise that resolves with an Array of strings representing the id for
454
- * each partition associated with the Event Hub.
455
- * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.
456
- * @throws AbortError if the operation is cancelled via the abortSignal.
457
- */
458
- getPartitionIds(options?: GetPartitionIdsOptions): Promise<Array<string>>;
459
- /**
460
- * Provides information about the state of the specified partition.
461
- * @param partitionId - The id of the partition for which information is required.
462
- * @param options - The set of options to apply to the operation call.
463
- * @returns A promise that resolves with information about the state of the partition .
464
- * @throws Error if the underlying connection has been closed, create a new EventHubBufferedProducerClient.
465
- * @throws AbortError if the operation is cancelled via the abortSignal.
466
- */
467
- getPartitionProperties(partitionId: string, options?: GetPartitionPropertiesOptions): Promise<PartitionProperties>;
468
- /**
469
- * Gets the `BatchingPartitionChannel` associated with the partitionId.
470
- *
471
- * If one does not exist, it is created.
472
- */
473
- private _getPartitionChannel;
474
- /**
475
- * Returns the total number of buffered events across all partitions.
476
- */
477
- private _getTotalBufferedEventsCount;
478
- }
479
- /**
480
- * Describes the options that can be provided while creating the `EventHubBufferedProducerClient`.
481
- */
482
- export declare interface EventHubBufferedProducerClientOptions extends EventHubClientOptions {
483
- /**
484
- * The total number of events that can be buffered for publishing at a given time for a given partition.
485
- *
486
- * Default: 1500
487
- */
488
- maxEventBufferLengthPerPartition?: number;
489
- /**
490
- * The amount of time to wait for a new event to be enqueued in the buffer before publishing a partially full batch.
491
- *
492
- * Default: 1 second.
493
- */
494
- maxWaitTimeInMs?: number;
495
- /**
496
- * The handler to call once a batch has successfully published.
497
- */
498
- onSendEventsSuccessHandler?: (ctx: OnSendEventsSuccessContext) => Promise<void>;
499
- /**
500
- * The handler to call when a batch fails to publish.
501
- */
502
- onSendEventsErrorHandler: (ctx: OnSendEventsErrorContext) => Promise<void>;
503
- }
504
251
  /**
505
252
  * Describes the options that can be provided while creating the EventHubClient.
506
253
  * - `userAgent` : A string to append to the built in user agent string that is passed as a connection property
@@ -1225,40 +972,8 @@ export declare interface LoadBalancingOptions {
1225
972
  * The `@azure/logger` configuration for this package.
1226
973
  * This will output logs using the `azure:event-hubs` namespace prefix.
1227
974
  */
1228
- export declare const logger: AzureLogger;
975
+ export declare const logger: import("@azure/logger").AzureLogger;
1229
976
  export { MessagingError };
1230
- /**
1231
- * Contains the events that were not successfully sent to the Event Hub,
1232
- * the partition they were assigned to, and the error that was encountered while sending.
1233
- */
1234
- export declare interface OnSendEventsErrorContext {
1235
- /**
1236
- * The partition each event was assigned.
1237
- */
1238
- partitionId: string;
1239
- /**
1240
- * The array of {@link EventData} and/or `AmqpAnnotatedMessage` that were not successfully sent to the Event Hub.
1241
- */
1242
- events: Array<EventData | AmqpAnnotatedMessage>;
1243
- /**
1244
- * The error that occurred when sending the associated events to the Event Hub.
1245
- */
1246
- error: Error;
1247
- }
1248
- /**
1249
- * Contains the events that were successfully sent to the Event Hub,
1250
- * and the partition they were assigned to.
1251
- */
1252
- export declare interface OnSendEventsSuccessContext {
1253
- /**
1254
- * The partition each event was assigned.
1255
- */
1256
- partitionId: string;
1257
- /**
1258
- * The array of {@link EventData} and/or `AmqpAnnotatedMessage` that were successfully sent to the Event Hub.
1259
- */
1260
- events: Array<EventData | AmqpAnnotatedMessage>;
1261
- }
1262
977
  /**
1263
978
  * Options for configuring tracing and the abortSignal.
1264
979
  */
@@ -1519,7 +1234,7 @@ export declare interface SubscribeOptions {
1519
1234
  /**
1520
1235
  * Indicates whether or not the consumer should request information on the last enqueued event on its
1521
1236
  * associated partition, and track that information as events are received.
1522
-
1237
+
1523
1238
  * When information about the partition's last enqueued event is being tracked, each event received
1524
1239
  * from the Event Hubs service will carry metadata about the partition that it otherwise would not. This results in a small amount of
1525
1240
  * additional network bandwidth consumption that is generally a favorable trade-off when considered