@azure/event-hubs 6.0.0-alpha.20250131.1 → 6.0.0-alpha.20250205.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.
- package/README.md +143 -165
- package/dist/browser/eventHubConsumerClient.d.ts +31 -15
- package/dist/browser/eventHubConsumerClient.d.ts.map +1 -1
- package/dist/browser/eventHubConsumerClient.js.map +1 -1
- package/dist/browser/eventHubProducerClient.d.ts +57 -24
- package/dist/browser/eventHubProducerClient.d.ts.map +1 -1
- package/dist/browser/eventHubProducerClient.js +22 -11
- package/dist/browser/eventHubProducerClient.js.map +1 -1
- package/dist/browser/eventProcessor.d.ts +1 -1
- package/dist/browser/eventProcessor.js.map +1 -1
- package/dist/browser/models/private.d.ts +1 -1
- package/dist/browser/models/private.js.map +1 -1
- package/dist/browser/models/public.d.ts +4 -4
- package/dist/browser/models/public.js.map +1 -1
- package/dist/commonjs/eventHubConsumerClient.d.ts +31 -15
- package/dist/commonjs/eventHubConsumerClient.d.ts.map +1 -1
- package/dist/commonjs/eventHubConsumerClient.js.map +1 -1
- package/dist/commonjs/eventHubProducerClient.d.ts +57 -24
- package/dist/commonjs/eventHubProducerClient.d.ts.map +1 -1
- package/dist/commonjs/eventHubProducerClient.js +22 -11
- package/dist/commonjs/eventHubProducerClient.js.map +1 -1
- package/dist/commonjs/eventProcessor.d.ts +1 -1
- package/dist/commonjs/eventProcessor.js.map +1 -1
- package/dist/commonjs/models/private.d.ts +1 -1
- package/dist/commonjs/models/private.js.map +1 -1
- package/dist/commonjs/models/public.d.ts +4 -4
- package/dist/commonjs/models/public.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/esm/eventHubConsumerClient.d.ts +31 -15
- package/dist/esm/eventHubConsumerClient.d.ts.map +1 -1
- package/dist/esm/eventHubConsumerClient.js.map +1 -1
- package/dist/esm/eventHubProducerClient.d.ts +57 -24
- package/dist/esm/eventHubProducerClient.d.ts.map +1 -1
- package/dist/esm/eventHubProducerClient.js +22 -11
- package/dist/esm/eventHubProducerClient.js.map +1 -1
- package/dist/esm/eventProcessor.d.ts +1 -1
- package/dist/esm/eventProcessor.js.map +1 -1
- package/dist/esm/models/private.d.ts +1 -1
- package/dist/esm/models/private.js.map +1 -1
- package/dist/esm/models/public.d.ts +4 -4
- package/dist/esm/models/public.js.map +1 -1
- package/package.json +12 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventHubProducerClient.js","sourceRoot":"","sources":["../../src/eventHubProducerClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAcjE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI3E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,4BAA4B,EAC5B,gCAAgC,EAChC,iCAAiC,GAClC,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,sBAAsB;IA4BjC;;;OAGG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH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C,CAAC;IAC7C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport { createConnectionContext } from \"./connectionContext.js\";\nimport type {\n CreateBatchOptions,\n EventHubClientOptions,\n GetEventHubPropertiesOptions,\n GetPartitionIdsOptions,\n GetPartitionPropertiesOptions,\n SendBatchOptions,\n} from \"./models/public.js\";\nimport type {\n PartitionPublishingOptions,\n PartitionPublishingProperties,\n} from \"./models/private.js\";\nimport type { EventDataBatch } from \"./eventDataBatch.js\";\nimport { EventDataBatchImpl, isEventDataBatch } from \"./eventDataBatch.js\";\nimport type { EventHubProperties, PartitionProperties } from \"./managementClient.js\";\nimport type { TracingContext, TracingSpanLink } from \"@azure/core-tracing\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isDefined } from \"@azure/core-util\";\nimport { isCredential } from \"./util/typeGuards.js\";\nimport { logErrorStackTrace, logger } from \"./logger.js\";\nimport {\n idempotentAlreadyPublished,\n idempotentSomeAlreadyPublished,\n throwErrorIfConnectionClosed,\n throwTypeErrorIfParameterMissing,\n validateProducerPartitionSettings,\n} from \"./util/error.js\";\nimport type { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport type { EventData, EventDataInternal } from \"./eventData.js\";\nimport { assertIsEventData } from \"./eventData.js\";\nimport { EventHubSender } from \"./eventHubSender.js\";\nimport type { OperationOptions } from \"./util/operationOptions.js\";\nimport { toSpanOptions, tracingClient } from \"./diagnostics/tracing.js\";\nimport { instrumentEventData } from \"./diagnostics/instrumentEventData.js\";\nimport { getRandomName } from \"./util/utils.js\";\n\n/**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n *\n * There are multiple ways to create an `EventHubProducerClient`\n * - Use the connection string from the SAS policy created for your Event Hub instance.\n * - Use the connection string from the SAS policy created for your Event Hub namespace,\n * and the name of the Event Hub instance\n * - Use the full namespace like `<yournamespace>.servicebus.windows.net`, and a credentials object.\n *\n * Optionally, you can also pass an options bag to configure the retry policy or proxy settings.\n *\n */\nexport class EventHubProducerClient {\n /**\n * Describes the amqp connection context for the client.\n */\n private _context: ConnectionContext;\n\n /**\n * The options passed by the user when creating the EventHubClient instance.\n */\n private _clientOptions: EventHubClientOptions;\n /**\n * Map of partitionId to senders\n */\n private _sendersMap: Map<string, EventHubSender>;\n /**\n * Indicates whether or not the EventHubProducerClient should enable idempotent publishing to Event Hub partitions.\n * If enabled, the producer will only be able to publish directly to partitions;\n * it will not be able to publish to the Event Hubs gateway for automatic partition routing\n * nor will it be able to use a partition key.\n * Default: false\n */\n private _enableIdempotentRetries?: boolean;\n /**\n * The set of options that can be specified to influence publishing behavior specific to the configured Event Hub partition.\n * These options are not necessary in the majority of scenarios and are intended for use with specialized scenarios,\n * such as when recovering the state used for idempotent publishing.\n */\n private _partitionOptions?: Record<string, PartitionPublishingOptions>;\n /**\n * @readonly\n * The name of the Event Hub instance for which this client is created.\n */\n get eventHubName(): string {\n return this._context.config.entityPath;\n }\n\n /**\n * @readonly\n * The fully qualified namespace of the Event Hub instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n get fullyQualifiedNamespace(): string {\n return this._context.config.host;\n }\n\n /**\n * The name used to identify this EventHubProducerClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public readonly identifier: string;\n\n /**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(connectionString: string, options?: EventHubClientOptions); // eslint-disable-line @azure/azure-sdk/ts-naming-options\n /**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(connectionString: string, eventHubName: string, options?: EventHubClientOptions); // eslint-disable-line @azure/azure-sdk/ts-naming-options\n /**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See @azure/identity for creating credentials that support AAD auth.\n * Use the `AzureNamedKeyCredential` from @azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from @azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options?: EventHubClientOptions, // eslint-disable-line @azure/azure-sdk/ts-naming-options\n );\n constructor(\n fullyQualifiedNamespaceOrConnectionString1: string,\n eventHubNameOrOptions2?: string | EventHubClientOptions,\n credentialOrOptions3?:\n | TokenCredential\n | NamedKeyCredential\n | SASCredential\n | EventHubClientOptions,\n options4?: EventHubClientOptions, // eslint-disable-line @azure/azure-sdk/ts-naming-options\n ) {\n this._context = createConnectionContext(\n fullyQualifiedNamespaceOrConnectionString1,\n eventHubNameOrOptions2,\n credentialOrOptions3,\n options4,\n );\n if (typeof eventHubNameOrOptions2 !== \"string\") {\n this._clientOptions = eventHubNameOrOptions2 || {};\n } else if (!isCredential(credentialOrOptions3)) {\n this._clientOptions = credentialOrOptions3 || {};\n } else {\n this._clientOptions = options4 || {};\n }\n this.identifier = this._clientOptions.identifier ?? getRandomName();\n this._sendersMap = new Map();\n }\n\n /**\n * Creates an instance of `EventDataBatch` to which one can add events until the maximum supported size is reached.\n * The batch can be passed to the {@link sendBatch} method of the `EventHubProducerClient` to be sent to Azure Event Hubs.\n *\n * Events with different values for partitionKey or partitionId will need to be put into different batches.\n * To simplify such batch management across partitions or to have the client automatically batch events\n * and send them in specific intervals, use `EventHubBufferedProducerClient` instead.\n *\n * The below example assumes you have an array of events at hand to be batched safely.\n * If you have events coming in one by one, `EventHubBufferedProducerClient` is recommended instead\n * for effecient management of batches.\n *\n * Example usage:\n * ```ts\n * const client = new EventHubProducerClient(connectionString);\n * let batch = await client.createBatch();\n * for (let i = 0; i < messages.length; i++) {\n * if (!batch.tryAdd(messages[i])) {\n * await client.sendBatch(batch);\n * batch = await client.createBatch();\n * if (!batch.tryAdd(messages[i])) {\n * throw new Error(\"Message too big to fit\")\n * }\n * if (i === messages.length - 1) {\n * await client.sendBatch(batch);\n * }\n * }\n * }\n * ```\n *\n * @param options - Configures the behavior of the batch.\n * - `partitionKey` : A value that is hashed and used by the Azure Event Hubs service to determine the partition to which\n * the events need to be sent.\n * - `partitionId` : Id of the partition to which the batch of events need to be sent.\n * - `maxSizeInBytes`: The upper limit for the size of batch. The `tryAdd` function will return `false` after this limit is reached.\n * - `abortSignal` : A signal the request to cancel the operation.\n * @returns Promise<EventDataBatch>\n * @throws Error if both `partitionId` and `partitionKey` are set in the options.\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal in the options.\n */\n async createBatch(options: CreateBatchOptions = {}): Promise<EventDataBatch> {\n throwErrorIfConnectionClosed(this._context);\n\n const partitionId = isDefined(options.partitionId) ? String(options.partitionId) : undefined;\n\n validateProducerPartitionSettings({\n enableIdempotentRetries: this._enableIdempotentRetries,\n partitionId,\n partitionKey: options.partitionKey,\n });\n\n let sender = this._sendersMap.get(partitionId || \"\");\n if (!sender) {\n const partitionPublishingOptions = isDefined(partitionId)\n ? this._partitionOptions?.[partitionId]\n : undefined;\n sender = EventHubSender.create(this._context, this.identifier, {\n enableIdempotentProducer: Boolean(this._enableIdempotentRetries),\n partitionId,\n partitionPublishingOptions,\n });\n this._sendersMap.set(partitionId || \"\", sender);\n }\n\n let maxMessageSize = await sender.getMaxMessageSize({\n retryOptions: this._clientOptions.retryOptions,\n abortSignal: options.abortSignal,\n });\n\n if (options.maxSizeInBytes) {\n if (options.maxSizeInBytes > maxMessageSize) {\n const error = new Error(\n `Max message size (${options.maxSizeInBytes} bytes) is greater than maximum message size (${maxMessageSize} bytes) on the AMQP sender link.`,\n );\n logger.warning(`[${this._context.connectionId}] ${error.message}`);\n logErrorStackTrace(error);\n throw error;\n }\n maxMessageSize = options.maxSizeInBytes;\n }\n return new EventDataBatchImpl(\n this._context,\n maxMessageSize,\n Boolean(this._enableIdempotentRetries),\n options.partitionKey,\n partitionId,\n );\n }\n\n /**\n * Get the information about the state of publishing for a partition as observed by the `EventHubProducerClient`.\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 * @param partitionId - Id of the partition from which to retrieve publishing properties.\n * @param options - The set of options to apply to the operation call.\n * - `abortSignal` : A signal the request to cancel the send operation.\n * @returns Promise<void>\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore this is called in EventHubBufferedProducerClient via cast-to-any workaround\n private async getPartitionPublishingProperties(\n partitionId: string,\n options: OperationOptions = {},\n ): Promise<PartitionPublishingProperties> {\n if (!isDefined(partitionId)) {\n throw new TypeError(\n `getPartitionPublishingProperties called without required argument \"partitionId\"`,\n );\n }\n\n if (typeof partitionId === \"number\") {\n partitionId = String(partitionId);\n }\n\n let sender = this._sendersMap.get(partitionId);\n if (!sender) {\n sender = EventHubSender.create(this._context, this.identifier, {\n enableIdempotentProducer: Boolean(this._enableIdempotentRetries),\n partitionId,\n partitionPublishingOptions: this._partitionOptions?.[partitionId],\n });\n this._sendersMap.set(partitionId, sender);\n }\n\n return sender.getPartitionPublishingProperties(options);\n }\n\n /**\n * Sends an array of events as a batch to the associated Event Hub.\n *\n * Azure Event Hubs has a limit on the size of the batch that can be sent which if exceeded\n * will result in an error with code `MessageTooLargeError`.\n * To safely send within batch size limits, use `EventHubProducerClient.createBatch()` or\n * `EventHubBufferedProducerClient` instead.\n *\n * Example usage:\n * ```ts\n * const client = new EventHubProducerClient(connectionString);\n * await client.sendBatch(messages);\n * ```\n *\n * @param batch - An array of {@link EventData} or `AmqpAnnotatedMessage`.\n * @param options - A set of options that can be specified to influence the way in which\n * events are sent to the associated Event Hub.\n * - `abortSignal` : A signal the request to cancel the send operation.\n * - `partitionId` : The partition this batch will be sent to. If set, `partitionKey` can not be set.\n * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.\n *\n * @returns Promise<void>\n * @throws MessageTooLargeError if all the events in the input array cannot be fit into a batch.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n * @throws MessagingError if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n async sendBatch(\n batch: EventData[] | AmqpAnnotatedMessage[],\n options?: SendBatchOptions,\n ): Promise<void>;\n /**\n * Sends a batch of events created using `EventHubProducerClient.createBatch()` to the associated Event Hub.\n *\n * Events with different values for partitionKey or partitionId will need to be put into different batches.\n * To simplify such batch management across partitions or to have the client automatically batch events\n * and send them in specific intervals, use `EventHubBufferedProducerClient` instead.\n *\n * The below example assumes you have an array of events at hand to be batched safely.\n * If you have events coming in one by one, `EventHubBufferedProducerClient` is recommended instead\n * for effecient management of batches.\n *\n * Example usage:\n * ```ts\n * const client = new EventHubProducerClient(connectionString);\n * let batch = await client.createBatch();\n * for (let i = 0; i < messages.length; i++) {\n * if (!batch.tryAdd(messages[i])) {\n * await client.sendBatch(batch);\n * batch = await client.createBatch();\n * if (!batch.tryAdd(messages[i])) {\n * throw new Error(\"Message too big to fit\")\n * }\n * if (i === messages.length - 1) {\n * await client.sendBatch(batch);\n * }\n * }\n * }\n * ```\n * @param batch - A batch of events that you can create using the {@link createBatch} method.\n * @param options - A set of options that can be specified to influence the way in which\n * events are sent to the associated Event Hub.\n * - `abortSignal` : A signal the request to cancel the send operation.\n *\n * @returns Promise<void>\n * @throws AbortError if the operation is cancelled via the abortSignal.\n * @throws MessagingError if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n async sendBatch(batch: EventDataBatch, options?: OperationOptions): Promise<void>;\n async sendBatch(\n batch: EventDataBatch | EventData[],\n options: SendBatchOptions | OperationOptions = {},\n ): Promise<void> {\n throwErrorIfConnectionClosed(this._context);\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"sendBatch\", \"batch\", batch);\n\n let partitionId: string | undefined;\n let partitionKey: string | undefined;\n\n // Holds an EventData properties object containing tracing properties.\n // This lets us avoid cloning batch when it is EventData[], which is\n // important as the idempotent EventHubSender needs to decorate the\n // original EventData passed through.\n const eventDataTracingProperties: Array<EventData[\"properties\"]> = [];\n\n // link message span contexts\n let spanContextsToLink: TracingContext[] = [];\n\n if (isEventDataBatch(batch)) {\n if (\n this._enableIdempotentRetries &&\n isDefined((batch as EventDataBatchImpl).startingPublishedSequenceNumber)\n ) {\n throw new Error(idempotentAlreadyPublished);\n }\n const partitionAssignment = extractPartitionAssignmentFromBatch(batch, options);\n partitionId = partitionAssignment.partitionId;\n partitionKey = partitionAssignment.partitionKey;\n spanContextsToLink = (batch as EventDataBatchImpl)._messageSpanContexts;\n } else {\n if (!Array.isArray(batch)) {\n batch = [batch];\n }\n batch.forEach(assertIsEventData);\n if (batch.some((event) => isDefined((event as EventDataInternal)._publishedSequenceNumber))) {\n throw new Error(idempotentSomeAlreadyPublished);\n }\n const partitionAssignment = extractPartitionAssignmentFromOptions(options);\n partitionId = partitionAssignment.partitionId;\n partitionKey = partitionAssignment.partitionKey;\n\n for (let i = 0; i < batch.length; i++) {\n batch[i] = instrumentEventData(\n batch[i],\n options,\n this._context.config.entityPath,\n this._context.config.host,\n \"publish\",\n ).event;\n eventDataTracingProperties[i] = batch[i].properties;\n }\n }\n\n validateProducerPartitionSettings({\n enableIdempotentRetries: this._enableIdempotentRetries,\n partitionId,\n partitionKey,\n });\n\n return tracingClient.withSpan(\n `${EventHubProducerClient.name}.${this.sendBatch.name}`,\n options,\n (updatedOptions) => {\n let sender = this._sendersMap.get(partitionId || \"\");\n if (!sender) {\n const partitionPublishingOptions = isDefined(partitionId)\n ? this._partitionOptions?.[partitionId]\n : undefined;\n sender = EventHubSender.create(this._context, this.identifier, {\n enableIdempotentProducer: Boolean(this._enableIdempotentRetries),\n partitionId,\n partitionPublishingOptions,\n });\n this._sendersMap.set(partitionId || \"\", sender);\n }\n\n return sender.send(batch, {\n ...updatedOptions,\n partitionId,\n partitionKey,\n retryOptions: this._clientOptions.retryOptions,\n });\n },\n {\n spanLinks: spanContextsToLink.map<TracingSpanLink>((tracingContext) => {\n return { tracingContext };\n }),\n ...toSpanOptions(this._context.config, \"publish\", \"client\"),\n },\n );\n }\n\n /**\n * Closes the AMQP connection to the Event Hub instance,\n * returning a promise that will be resolved when disconnection is completed.\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n async close(): Promise<void> {\n await this._context.close();\n\n for (const pair of this._sendersMap) {\n await pair[1].close();\n }\n this._sendersMap.clear();\n }\n\n /**\n * Provides the Event Hub runtime information.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the Event Hub instance.\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise<EventHubProperties> {\n return this._context.managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n\n /**\n * Provides the id for each partition associated with the Event Hub.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with an Array of strings representing the id for\n * each partition associated with the Event Hub.\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionIds(options: GetPartitionIdsOptions = {}): Promise<Array<string>> {\n return this._context\n .managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n })\n .then((eventHubProperties) => {\n return eventHubProperties.partitionIds;\n });\n }\n\n /**\n * Provides information about the state of the specified partition.\n * @param partitionId - The id of the partition for which information is required.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the state of the partition .\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionProperties(\n partitionId: string,\n options: GetPartitionPropertiesOptions = {},\n ): Promise<PartitionProperties> {\n return this._context.managementSession!.getPartitionProperties(partitionId, {\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n}\n\n/**\n * @internal\n */\nfunction extractPartitionAssignmentFromOptions(options: SendBatchOptions = {}): {\n partitionKey?: string;\n partitionId?: string;\n} {\n const result: ReturnType<typeof extractPartitionAssignmentFromOptions> = {};\n const { partitionId, partitionKey } = options;\n\n if (isDefined(partitionId)) {\n result.partitionId = String(partitionId);\n }\n if (isDefined(partitionKey)) {\n result.partitionKey = String(partitionKey);\n }\n\n return result;\n}\n\n/**\n * @internal\n */\nfunction extractPartitionAssignmentFromBatch(\n batch: EventDataBatch,\n options: SendBatchOptions,\n): { partitionKey?: string; partitionId?: string } {\n const result: ReturnType<typeof extractPartitionAssignmentFromBatch> = {};\n const partitionId = batch.partitionId;\n const partitionKey = batch.partitionKey;\n\n const { partitionId: unexpectedPartitionId, partitionKey: unexpectedPartitionKey } =\n extractPartitionAssignmentFromOptions(options);\n if (unexpectedPartitionKey && partitionKey !== unexpectedPartitionKey) {\n throw new Error(\n `The partitionKey (${unexpectedPartitionKey}) set on sendBatch does not match the partitionKey (${partitionKey}) set when creating the batch.`,\n );\n }\n if (unexpectedPartitionId && unexpectedPartitionId !== partitionId) {\n throw new Error(\n `The partitionId (${unexpectedPartitionId}) set on sendBatch does not match the partitionId (${partitionId}) set when creating the batch.`,\n );\n }\n\n if (isDefined(partitionId)) {\n result.partitionId = String(partitionId);\n }\n if (isDefined(partitionKey)) {\n result.partitionKey = String(partitionKey);\n }\n\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"eventHubProducerClient.js","sourceRoot":"","sources":["../../src/eventHubProducerClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAcjE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI3E,OAAO,EAA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AM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACtC,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;IAExC,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,YAAY,EAAE,sBAAsB,EAAE,GAChF,qCAAqC,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,sBAAsB,IAAI,YAAY,KAAK,sBAAsB,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CACb,qBAAqB,sBAAsB,uDAAuD,YAAY,gCAAgC,CAC/I,CAAC;IACJ,CAAC;IACD,IAAI,qBAAqB,IAAI,qBAAqB,KAAK,WAAW,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CACb,oBAAoB,qBAAqB,sDAAsD,WAAW,gCAAgC,CAC3I,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;QAC5B,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport { createConnectionContext } from \"./connectionContext.js\";\nimport type {\n CreateBatchOptions,\n EventHubClientOptions,\n GetEventHubPropertiesOptions,\n GetPartitionIdsOptions,\n GetPartitionPropertiesOptions,\n SendBatchOptions,\n} from \"./models/public.js\";\nimport type {\n PartitionPublishingOptions,\n PartitionPublishingProperties,\n} from \"./models/private.js\";\nimport type { EventDataBatch } from \"./eventDataBatch.js\";\nimport { EventDataBatchImpl, isEventDataBatch } from \"./eventDataBatch.js\";\nimport type { EventHubProperties, PartitionProperties } from \"./managementClient.js\";\nimport type { TracingContext, TracingSpanLink } from \"@azure/core-tracing\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isDefined } from \"@azure/core-util\";\nimport { isCredential } from \"./util/typeGuards.js\";\nimport { logErrorStackTrace, logger } from \"./logger.js\";\nimport {\n idempotentAlreadyPublished,\n idempotentSomeAlreadyPublished,\n throwErrorIfConnectionClosed,\n throwTypeErrorIfParameterMissing,\n validateProducerPartitionSettings,\n} from \"./util/error.js\";\nimport type { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport type { EventData, EventDataInternal } from \"./eventData.js\";\nimport { assertIsEventData } from \"./eventData.js\";\nimport { EventHubSender } from \"./eventHubSender.js\";\nimport type { OperationOptions } from \"./util/operationOptions.js\";\nimport { toSpanOptions, tracingClient } from \"./diagnostics/tracing.js\";\nimport { instrumentEventData } from \"./diagnostics/instrumentEventData.js\";\nimport { getRandomName } from \"./util/utils.js\";\n\n/**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n *\n * There are multiple ways to create an `EventHubProducerClient`\n * - Use the connection string from the SAS policy created for your Event Hub instance.\n * - Use the connection string from the SAS policy created for your Event Hub namespace,\n * and the name of the Event Hub instance\n * - Use the full namespace like `<yournamespace>.servicebus.windows.net`, and a credentials object.\n *\n * Optionally, you can also pass an options bag to configure the retry policy or proxy settings.\n *\n */\nexport class EventHubProducerClient {\n /**\n * Describes the amqp connection context for the client.\n */\n private _context: ConnectionContext;\n\n /**\n * The options passed by the user when creating the EventHubClient instance.\n */\n private _clientOptions: EventHubClientOptions;\n /**\n * Map of partitionId to senders\n */\n private _sendersMap: Map<string, EventHubSender>;\n /**\n * Indicates whether or not the EventHubProducerClient should enable idempotent publishing to Event Hub partitions.\n * If enabled, the producer will only be able to publish directly to partitions;\n * it will not be able to publish to the Event Hubs gateway for automatic partition routing\n * nor will it be able to use a partition key.\n * Default: false\n */\n private _enableIdempotentRetries?: boolean;\n /**\n * The set of options that can be specified to influence publishing behavior specific to the configured Event Hub partition.\n * These options are not necessary in the majority of scenarios and are intended for use with specialized scenarios,\n * such as when recovering the state used for idempotent publishing.\n */\n private _partitionOptions?: Record<string, PartitionPublishingOptions>;\n /**\n * @readonly\n * The name of the Event Hub instance for which this client is created.\n */\n get eventHubName(): string {\n return this._context.config.entityPath;\n }\n\n /**\n * @readonly\n * The fully qualified namespace of the Event Hub instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n get fullyQualifiedNamespace(): string {\n return this._context.config.host;\n }\n\n /**\n * The name used to identify this EventHubProducerClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public readonly identifier: string;\n\n /**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hub instance.\n * It is expected that the shared key properties and the Event Hub path are contained in this connection string.\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-event-hub-name'.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(connectionString: string, options?: EventHubClientOptions); // eslint-disable-line @azure/azure-sdk/ts-naming-options\n /**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param connectionString - The connection string to use for connecting to the Event Hubs namespace.\n * It is expected that the shared key properties are contained in this connection string, but not the Event Hub path,\n * e.g. 'Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;'.\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(connectionString: string, eventHubName: string, options?: EventHubClientOptions); // eslint-disable-line @azure/azure-sdk/ts-naming-options\n /**\n * The `EventHubProducerClient` class is used to send events to an Event Hub.\n * Use the `options` parmeter to configure retry policy or proxy settings.\n * @param fullyQualifiedNamespace - The full namespace which is likely to be similar to\n * <yournamespace>.servicebus.windows.net\n * @param eventHubName - The name of the specific Event Hub to connect the client to.\n * @param credential - An credential object used by the client to get the token to authenticate the connection\n * with the Azure Event Hubs service.\n * See @azure/identity for creating credentials that support AAD auth.\n * Use the `AzureNamedKeyCredential` from @azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from @azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n * - `userAgent` : A string to append to the built in user agent string that is passed to the service.\n */\n constructor(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options?: EventHubClientOptions, // eslint-disable-line @azure/azure-sdk/ts-naming-options\n );\n constructor(\n fullyQualifiedNamespaceOrConnectionString1: string,\n eventHubNameOrOptions2?: string | EventHubClientOptions,\n credentialOrOptions3?:\n | TokenCredential\n | NamedKeyCredential\n | SASCredential\n | EventHubClientOptions,\n options4?: EventHubClientOptions, // eslint-disable-line @azure/azure-sdk/ts-naming-options\n ) {\n this._context = createConnectionContext(\n fullyQualifiedNamespaceOrConnectionString1,\n eventHubNameOrOptions2,\n credentialOrOptions3,\n options4,\n );\n if (typeof eventHubNameOrOptions2 !== \"string\") {\n this._clientOptions = eventHubNameOrOptions2 || {};\n } else if (!isCredential(credentialOrOptions3)) {\n this._clientOptions = credentialOrOptions3 || {};\n } else {\n this._clientOptions = options4 || {};\n }\n this.identifier = this._clientOptions.identifier ?? getRandomName();\n this._sendersMap = new Map();\n }\n\n /**\n * Creates an instance of `EventDataBatch` to which one can add events until the maximum supported size is reached.\n * The batch can be passed to the {@link sendBatch} method of the `EventHubProducerClient` to be sent to Azure Event Hubs.\n *\n * Events with different values for partitionKey or partitionId will need to be put into different batches.\n * To simplify such batch management across partitions or to have the client automatically batch events\n * and send them in specific intervals, use `EventHubBufferedProducerClient` instead.\n *\n * The below example assumes you have an array of events at hand to be batched safely.\n * If you have events coming in one by one, `EventHubBufferedProducerClient` is recommended instead\n * for effecient management of batches.\n *\n * Example usage:\n * ```ts snippet:EventHubProducerClient_CreateBatch\n * import { EventHubProducerClient } from \"@azure/event-hubs\";\n *\n * const client = new EventHubProducerClient(\"my-connection-string\", \"my-event-hub\");\n *\n * const messages = [\n * { body: \"my-event-body1\" },\n * { body: \"my-event-body2\" },\n * { body: \"my-event-body3\" },\n * { body: \"my-event-body4\" },\n * { body: \"my-event-body5\" },\n * ];\n *\n * let batch = await client.createBatch();\n * for (let i = 0; i < messages.length; i++) {\n * if (!batch.tryAdd(messages[i])) {\n * await client.sendBatch(batch);\n * batch = await client.createBatch();\n * if (!batch.tryAdd(messages[i])) {\n * throw new Error(\"Message too big to fit\");\n * }\n * if (i === messages.length - 1) {\n * await client.sendBatch(batch);\n * }\n * }\n * }\n * ```\n *\n * @param options - Configures the behavior of the batch.\n * - `partitionKey` : A value that is hashed and used by the Azure Event Hubs service to determine the partition to which\n * the events need to be sent.\n * - `partitionId` : Id of the partition to which the batch of events need to be sent.\n * - `maxSizeInBytes`: The upper limit for the size of batch. The `tryAdd` function will return `false` after this limit is reached.\n * - `abortSignal` : A signal the request to cancel the operation.\n * @returns Promise<EventDataBatch>\n * @throws Error if both `partitionId` and `partitionKey` are set in the options.\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal in the options.\n */\n async createBatch(options: CreateBatchOptions = {}): Promise<EventDataBatch> {\n throwErrorIfConnectionClosed(this._context);\n\n const partitionId = isDefined(options.partitionId) ? String(options.partitionId) : undefined;\n\n validateProducerPartitionSettings({\n enableIdempotentRetries: this._enableIdempotentRetries,\n partitionId,\n partitionKey: options.partitionKey,\n });\n\n let sender = this._sendersMap.get(partitionId || \"\");\n if (!sender) {\n const partitionPublishingOptions = isDefined(partitionId)\n ? this._partitionOptions?.[partitionId]\n : undefined;\n sender = EventHubSender.create(this._context, this.identifier, {\n enableIdempotentProducer: Boolean(this._enableIdempotentRetries),\n partitionId,\n partitionPublishingOptions,\n });\n this._sendersMap.set(partitionId || \"\", sender);\n }\n\n let maxMessageSize = await sender.getMaxMessageSize({\n retryOptions: this._clientOptions.retryOptions,\n abortSignal: options.abortSignal,\n });\n\n if (options.maxSizeInBytes) {\n if (options.maxSizeInBytes > maxMessageSize) {\n const error = new Error(\n `Max message size (${options.maxSizeInBytes} bytes) is greater than maximum message size (${maxMessageSize} bytes) on the AMQP sender link.`,\n );\n logger.warning(`[${this._context.connectionId}] ${error.message}`);\n logErrorStackTrace(error);\n throw error;\n }\n maxMessageSize = options.maxSizeInBytes;\n }\n return new EventDataBatchImpl(\n this._context,\n maxMessageSize,\n Boolean(this._enableIdempotentRetries),\n options.partitionKey,\n partitionId,\n );\n }\n\n /**\n * Get the information about the state of publishing for a partition as observed by the `EventHubProducerClient`.\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 * @param partitionId - Id of the partition from which to retrieve publishing properties.\n * @param options - The set of options to apply to the operation call.\n * - `abortSignal` : A signal the request to cancel the send operation.\n * @returns Promise<void>\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore this is called in EventHubBufferedProducerClient via cast-to-any workaround\n private async getPartitionPublishingProperties(\n partitionId: string,\n options: OperationOptions = {},\n ): Promise<PartitionPublishingProperties> {\n if (!isDefined(partitionId)) {\n throw new TypeError(\n `getPartitionPublishingProperties called without required argument \"partitionId\"`,\n );\n }\n\n if (typeof partitionId === \"number\") {\n partitionId = String(partitionId);\n }\n\n let sender = this._sendersMap.get(partitionId);\n if (!sender) {\n sender = EventHubSender.create(this._context, this.identifier, {\n enableIdempotentProducer: Boolean(this._enableIdempotentRetries),\n partitionId,\n partitionPublishingOptions: this._partitionOptions?.[partitionId],\n });\n this._sendersMap.set(partitionId, sender);\n }\n\n return sender.getPartitionPublishingProperties(options);\n }\n\n /**\n * Sends an array of events as a batch to the associated Event Hub.\n *\n * Azure Event Hubs has a limit on the size of the batch that can be sent which if exceeded\n * will result in an error with code `MessageTooLargeError`.\n * To safely send within batch size limits, use `EventHubProducerClient.createBatch()` or\n * `EventHubBufferedProducerClient` instead.\n *\n * Example usage:\n * ```ts snippet:EventHubProducerClient_SendBatch\n * import { EventHubProducerClient } from \"@azure/event-hubs\";\n *\n * const client = new EventHubProducerClient(\"my-connection-string\", \"my-event-hub\");\n *\n * const messages = [\n * { body: \"my-event-body1\" },\n * { body: \"my-event-body2\" },\n * { body: \"my-event-body3\" },\n * { body: \"my-event-body4\" },\n * { body: \"my-event-body5\" },\n * ];\n *\n * await client.sendBatch(messages);\n * ```\n *\n * @param batch - An array of {@link EventData} or `AmqpAnnotatedMessage`.\n * @param options - A set of options that can be specified to influence the way in which\n * events are sent to the associated Event Hub.\n * - `abortSignal` : A signal the request to cancel the send operation.\n * - `partitionId` : The partition this batch will be sent to. If set, `partitionKey` can not be set.\n * - `partitionKey` : A value that is hashed to produce a partition assignment. If set, `partitionId` can not be set.\n *\n * @returns Promise<void>\n * @throws MessageTooLargeError if all the events in the input array cannot be fit into a batch.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n * @throws MessagingError if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n async sendBatch(\n batch: EventData[] | AmqpAnnotatedMessage[],\n options?: SendBatchOptions,\n ): Promise<void>;\n /**\n * Sends a batch of events created using `EventHubProducerClient.createBatch()` to the associated Event Hub.\n *\n * Events with different values for partitionKey or partitionId will need to be put into different batches.\n * To simplify such batch management across partitions or to have the client automatically batch events\n * and send them in specific intervals, use `EventHubBufferedProducerClient` instead.\n *\n * The below example assumes you have an array of events at hand to be batched safely.\n * If you have events coming in one by one, `EventHubBufferedProducerClient` is recommended instead\n * for effecient management of batches.\n *\n * Example usage:\n * ```ts snippet:EventHubProducerClient_SendBatchPartitioned\n * import { EventHubProducerClient } from \"@azure/event-hubs\";\n *\n * const client = new EventHubProducerClient(\"my-connection-string\", \"my-event-hub\");\n *\n * const messages = [\n * { body: \"my-event-body1\" },\n * { body: \"my-event-body2\" },\n * { body: \"my-event-body3\" },\n * { body: \"my-event-body4\" },\n * { body: \"my-event-body5\" },\n * ];\n *\n * let batch = await client.createBatch();\n * for (let i = 0; i < messages.length; i++) {\n * if (!batch.tryAdd(messages[i])) {\n * await client.sendBatch(batch);\n * batch = await client.createBatch();\n * if (!batch.tryAdd(messages[i])) {\n * throw new Error(\"Message too big to fit\");\n * }\n * if (i === messages.length - 1) {\n * await client.sendBatch(batch);\n * }\n * }\n * }\n * ```\n * @param batch - A batch of events that you can create using the {@link createBatch} method.\n * @param options - A set of options that can be specified to influence the way in which\n * events are sent to the associated Event Hub.\n * - `abortSignal` : A signal the request to cancel the send operation.\n *\n * @returns Promise<void>\n * @throws AbortError if the operation is cancelled via the abortSignal.\n * @throws MessagingError if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n async sendBatch(batch: EventDataBatch, options?: OperationOptions): Promise<void>;\n async sendBatch(\n batch: EventDataBatch | EventData[],\n options: SendBatchOptions | OperationOptions = {},\n ): Promise<void> {\n throwErrorIfConnectionClosed(this._context);\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"sendBatch\", \"batch\", batch);\n\n let partitionId: string | undefined;\n let partitionKey: string | undefined;\n\n // Holds an EventData properties object containing tracing properties.\n // This lets us avoid cloning batch when it is EventData[], which is\n // important as the idempotent EventHubSender needs to decorate the\n // original EventData passed through.\n const eventDataTracingProperties: Array<EventData[\"properties\"]> = [];\n\n // link message span contexts\n let spanContextsToLink: TracingContext[] = [];\n\n if (isEventDataBatch(batch)) {\n if (\n this._enableIdempotentRetries &&\n isDefined((batch as EventDataBatchImpl).startingPublishedSequenceNumber)\n ) {\n throw new Error(idempotentAlreadyPublished);\n }\n const partitionAssignment = extractPartitionAssignmentFromBatch(batch, options);\n partitionId = partitionAssignment.partitionId;\n partitionKey = partitionAssignment.partitionKey;\n spanContextsToLink = (batch as EventDataBatchImpl)._messageSpanContexts;\n } else {\n if (!Array.isArray(batch)) {\n batch = [batch];\n }\n batch.forEach(assertIsEventData);\n if (batch.some((event) => isDefined((event as EventDataInternal)._publishedSequenceNumber))) {\n throw new Error(idempotentSomeAlreadyPublished);\n }\n const partitionAssignment = extractPartitionAssignmentFromOptions(options);\n partitionId = partitionAssignment.partitionId;\n partitionKey = partitionAssignment.partitionKey;\n\n for (let i = 0; i < batch.length; i++) {\n batch[i] = instrumentEventData(\n batch[i],\n options,\n this._context.config.entityPath,\n this._context.config.host,\n \"publish\",\n ).event;\n eventDataTracingProperties[i] = batch[i].properties;\n }\n }\n\n validateProducerPartitionSettings({\n enableIdempotentRetries: this._enableIdempotentRetries,\n partitionId,\n partitionKey,\n });\n\n return tracingClient.withSpan(\n `${EventHubProducerClient.name}.${this.sendBatch.name}`,\n options,\n (updatedOptions) => {\n let sender = this._sendersMap.get(partitionId || \"\");\n if (!sender) {\n const partitionPublishingOptions = isDefined(partitionId)\n ? this._partitionOptions?.[partitionId]\n : undefined;\n sender = EventHubSender.create(this._context, this.identifier, {\n enableIdempotentProducer: Boolean(this._enableIdempotentRetries),\n partitionId,\n partitionPublishingOptions,\n });\n this._sendersMap.set(partitionId || \"\", sender);\n }\n\n return sender.send(batch, {\n ...updatedOptions,\n partitionId,\n partitionKey,\n retryOptions: this._clientOptions.retryOptions,\n });\n },\n {\n spanLinks: spanContextsToLink.map<TracingSpanLink>((tracingContext) => {\n return { tracingContext };\n }),\n ...toSpanOptions(this._context.config, \"publish\", \"client\"),\n },\n );\n }\n\n /**\n * Closes the AMQP connection to the Event Hub instance,\n * returning a promise that will be resolved when disconnection is completed.\n * @returns Promise<void>\n * @throws Error if the underlying connection encounters an error while closing.\n */\n async close(): Promise<void> {\n await this._context.close();\n\n for (const pair of this._sendersMap) {\n await pair[1].close();\n }\n this._sendersMap.clear();\n }\n\n /**\n * Provides the Event Hub runtime information.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the Event Hub instance.\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise<EventHubProperties> {\n return this._context.managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n\n /**\n * Provides the id for each partition associated with the Event Hub.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with an Array of strings representing the id for\n * each partition associated with the Event Hub.\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionIds(options: GetPartitionIdsOptions = {}): Promise<Array<string>> {\n return this._context\n .managementSession!.getEventHubProperties({\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n })\n .then((eventHubProperties) => {\n return eventHubProperties.partitionIds;\n });\n }\n\n /**\n * Provides information about the state of the specified partition.\n * @param partitionId - The id of the partition for which information is required.\n * @param options - The set of options to apply to the operation call.\n * @returns A promise that resolves with information about the state of the partition .\n * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient.\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n getPartitionProperties(\n partitionId: string,\n options: GetPartitionPropertiesOptions = {},\n ): Promise<PartitionProperties> {\n return this._context.managementSession!.getPartitionProperties(partitionId, {\n ...options,\n retryOptions: this._clientOptions.retryOptions,\n });\n }\n}\n\n/**\n * @internal\n */\nfunction extractPartitionAssignmentFromOptions(options: SendBatchOptions = {}): {\n partitionKey?: string;\n partitionId?: string;\n} {\n const result: ReturnType<typeof extractPartitionAssignmentFromOptions> = {};\n const { partitionId, partitionKey } = options;\n\n if (isDefined(partitionId)) {\n result.partitionId = String(partitionId);\n }\n if (isDefined(partitionKey)) {\n result.partitionKey = String(partitionKey);\n }\n\n return result;\n}\n\n/**\n * @internal\n */\nfunction extractPartitionAssignmentFromBatch(\n batch: EventDataBatch,\n options: SendBatchOptions,\n): { partitionKey?: string; partitionId?: string } {\n const result: ReturnType<typeof extractPartitionAssignmentFromBatch> = {};\n const partitionId = batch.partitionId;\n const partitionKey = batch.partitionKey;\n\n const { partitionId: unexpectedPartitionId, partitionKey: unexpectedPartitionKey } =\n extractPartitionAssignmentFromOptions(options);\n if (unexpectedPartitionKey && partitionKey !== unexpectedPartitionKey) {\n throw new Error(\n `The partitionKey (${unexpectedPartitionKey}) set on sendBatch does not match the partitionKey (${partitionKey}) set when creating the batch.`,\n );\n }\n if (unexpectedPartitionId && unexpectedPartitionId !== partitionId) {\n throw new Error(\n `The partitionId (${unexpectedPartitionId}) set on sendBatch does not match the partitionId (${partitionId}) set when creating the batch.`,\n );\n }\n\n if (isDefined(partitionId)) {\n result.partitionId = String(partitionId);\n }\n if (isDefined(partitionKey)) {\n result.partitionKey = String(partitionKey);\n }\n\n return result;\n}\n"]}
|
|
@@ -110,7 +110,7 @@ export interface CheckpointStore {
|
|
|
110
110
|
* passing the data to user code for processing. If not provided, it defaults to 60 seconds.
|
|
111
111
|
*
|
|
112
112
|
* Example usage with default values:
|
|
113
|
-
* ```ts
|
|
113
|
+
* ```ts snippet:ignore
|
|
114
114
|
* {
|
|
115
115
|
* maxBatchSize: 1,
|
|
116
116
|
* maxWaitTimeInSeconds: 60,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventProcessor.js","sourceRoot":"","sources":["../../src/eventProcessor.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAqJxD;;;;;;;;;;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;QAC3B,+BAA0B,GAA1B,0BAA0B,CAA2B;QACrD,qBAAgB,GAAhB,gBAAgB,CAAiB;QAlCnC,eAAU,GAAY,KAAK,CAAC;QAqClC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;YAC3B,MAAM,CAAC,OAAO,CAAC,oCAAoC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;Q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C,GAAG,IAAI,GAAG,EAA8B,CAAC;IAChF,MAAM,iBAAiB,GAAa,EAAE,CAAC;IAEvC,yDAAyD;IACzD,0DAA0D;IAC1D,wDAAwD;IACxD,+DAA+D;IAC/D,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;QAC3C,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,iCAAiC,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,SAAS,CAAC,OAAO,KAAK,EAAE,IAAI,wBAAwB,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;YAChF,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,4FAA4F;IAC5F,gCAAgC;IAChC,8EAA8E;IAC9E,4CAA4C;IAC5C,qEAAqE;IACrE,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,oBAAoB,CAClE,EAAE,EACF,iCAAiC,EACjC,YAAY,CACb,CAAC;IACF,iBAAiB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAE7C,OAAO;QACL,iBAAiB,EAAE,IAAI,GAAG,CAAC,iBAAiB,CAAC;QAC7C,qBAAqB;KACtB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AbortError } from \"@azure/abort-controller\";\nimport type { Checkpoint } from \"./partitionProcessor.js\";\nimport { PartitionProcessor } from \"./partitionProcessor.js\";\nimport type { EventPosition } from \"./eventPosition.js\";\nimport { isEventPosition, latestEventPosition } from \"./eventPosition.js\";\nimport type { PumpManager } from \"./pumpManager.js\";\nimport { PumpManagerImpl } from \"./pumpManager.js\";\nimport { logErrorStackTrace, logger } from \"./logger.js\";\nimport { CloseReason } from \"./models/public.js\";\nimport type { CommonEventProcessorOptions } from \"./models/private.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { LoadBalancingStrategy } from \"./loadBalancerStrategies/loadBalancingStrategy.js\";\nimport type { OperationOptions } from \"./util/operationOptions.js\";\nimport type { SubscriptionEventHandlers } from \"./eventHubConsumerClientModels.js\";\nimport { delayWithoutThrow } from \"./util/delayWithoutThrow.js\";\nimport { getRandomName } from \"./util/utils.js\";\nimport { StandardAbortMessage } from \"@azure/core-amqp\";\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 @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 @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 occurred 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,\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(StandardAbortMessage);\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(StandardAbortMessage);\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 // cancel the event processor loop\n this._abortController?.abort();\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 occurred 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
|
+
{"version":3,"file":"eventProcessor.js","sourceRoot":"","sources":["../../src/eventProcessor.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAqJxD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAsBzB;;;;;;;;;;;OAWG;IACH,YACU,cAAsB,EACtB,QAA2B,EAC3B,0BAAqD,EACrD,gBAAiC,EACzC,OAAkC;QAJ1B,mBAAc,GAAd,cAAc,CAAQ;Q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AAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AbortError } from \"@azure/abort-controller\";\nimport type { Checkpoint } from \"./partitionProcessor.js\";\nimport { PartitionProcessor } from \"./partitionProcessor.js\";\nimport type { EventPosition } from \"./eventPosition.js\";\nimport { isEventPosition, latestEventPosition } from \"./eventPosition.js\";\nimport type { PumpManager } from \"./pumpManager.js\";\nimport { PumpManagerImpl } from \"./pumpManager.js\";\nimport { logErrorStackTrace, logger } from \"./logger.js\";\nimport { CloseReason } from \"./models/public.js\";\nimport type { CommonEventProcessorOptions } from \"./models/private.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { LoadBalancingStrategy } from \"./loadBalancerStrategies/loadBalancingStrategy.js\";\nimport type { OperationOptions } from \"./util/operationOptions.js\";\nimport type { SubscriptionEventHandlers } from \"./eventHubConsumerClientModels.js\";\nimport { delayWithoutThrow } from \"./util/delayWithoutThrow.js\";\nimport { getRandomName } from \"./util/utils.js\";\nimport { StandardAbortMessage } from \"@azure/core-amqp\";\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 @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 snippet:ignore\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 @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 occurred 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,\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(StandardAbortMessage);\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(StandardAbortMessage);\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 // cancel the event processor loop\n this._abortController?.abort();\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 occurred 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"]}
|
|
@@ -65,7 +65,7 @@ export interface CommonEventProcessorOptions extends Required<Pick<SubscribeOpti
|
|
|
65
65
|
* the bytes present in the message body than have the client attempt to parse it.
|
|
66
66
|
*
|
|
67
67
|
* Example usage:
|
|
68
|
-
* ```
|
|
68
|
+
* ```ts snippet:ignore
|
|
69
69
|
* {
|
|
70
70
|
* retryOptions: {
|
|
71
71
|
* maxRetries: 4
|
|
@@ -1 +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 * ```
|
|
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"]}
|
|
@@ -49,7 +49,7 @@ export interface SendBatchOptions extends OperationOptions {
|
|
|
49
49
|
* - `abortSignal` : A signal used to cancel the send operation.
|
|
50
50
|
*
|
|
51
51
|
* Example usage:
|
|
52
|
-
* ```
|
|
52
|
+
* ```ts snippet:ignore
|
|
53
53
|
* {
|
|
54
54
|
* partitionKey: 'foo'
|
|
55
55
|
* }
|
|
@@ -100,7 +100,7 @@ export declare enum CloseReason {
|
|
|
100
100
|
* A simple usage can be `{ "maxRetries": 4 }`.
|
|
101
101
|
*
|
|
102
102
|
* Example usage:
|
|
103
|
-
* ```
|
|
103
|
+
* ```ts snippet:ignore
|
|
104
104
|
* {
|
|
105
105
|
* retryOptions: {
|
|
106
106
|
* maxRetries: 4
|
|
@@ -159,7 +159,7 @@ export interface EventHubClientOptions {
|
|
|
159
159
|
* A simple usage can be `{ "maxRetries": 4 }`.
|
|
160
160
|
*
|
|
161
161
|
* Example usage:
|
|
162
|
-
* ```
|
|
162
|
+
* ```ts snippet:ignore
|
|
163
163
|
* {
|
|
164
164
|
* retryOptions: {
|
|
165
165
|
* maxRetries: 4
|
|
@@ -213,7 +213,7 @@ export interface LoadBalancingOptions {
|
|
|
213
213
|
* - `abortSignal` : A signal the request to cancel the send operation.
|
|
214
214
|
*
|
|
215
215
|
* Example usage:
|
|
216
|
-
* ```
|
|
216
|
+
* ```ts snippet:ignore
|
|
217
217
|
* {
|
|
218
218
|
* partitionKey: 'foo',
|
|
219
219
|
* maxSizeInBytes: 1024 * 1024 // 1 MB
|
|
@@ -1 +1 @@
|
|
|
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 type { RetryOptions, WebSocketOptions } from \"@azure/core-amqp\";\nimport type { OperationOptions } from \"../util/operationOptions.js\";\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
|
+
{"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 type { RetryOptions, WebSocketOptions } from \"@azure/core-amqp\";\nimport type { OperationOptions } from \"../util/operationOptions.js\";\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 * ```ts snippet:ignore\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 * ```ts snippet:ignore\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 * ```ts snippet:ignore\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 * ```ts snippet:ignore\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"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/event-hubs",
|
|
3
3
|
"sdk-type": "client",
|
|
4
|
-
"version": "6.0.0-alpha.
|
|
4
|
+
"version": "6.0.0-alpha.20250205.1",
|
|
5
5
|
"description": "Azure Event Hubs SDK for JS.",
|
|
6
6
|
"author": "Microsoft Corporation",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"execute:samples": "dev-tool samples run samples-dev",
|
|
41
41
|
"extract-api": "dev-tool run build-package && dev-tool run extract-api",
|
|
42
42
|
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"samples-dev/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"",
|
|
43
|
-
"generate-certs": "
|
|
43
|
+
"generate-certs": "node generateCerts.mjs",
|
|
44
44
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
45
45
|
"integration-test:browser": "dev-tool run build-package && dev-tool run build-test && dev-tool run vendored cross-env TEST_MODE=live dev-tool run test:vitest --browser --no-test-proxy",
|
|
46
46
|
"integration-test:node": "dev-tool run vendored cross-env TEST_MODE=live npm run vitest:node --esm",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
|
55
55
|
"unit-test:browser": "echo skipped",
|
|
56
56
|
"unit-test:node": "dev-tool run vendored cross-env NODE_EXTRA_CA_CERTS=\"./certs/my-private-root-ca.crt.pem\" AZURE_LOG_LEVEL=\"info\" npm run vitest:node",
|
|
57
|
-
"update-snippets": "
|
|
57
|
+
"update-snippets": "dev-tool run update-snippets",
|
|
58
58
|
"vitest:node": "dev-tool run test:vitest --no-test-proxy"
|
|
59
59
|
},
|
|
60
60
|
"//metadata": {
|
|
@@ -107,12 +107,12 @@
|
|
|
107
107
|
"@azure/core-auth": "^1.3.0",
|
|
108
108
|
"@azure/core-tracing": "^1.1.2",
|
|
109
109
|
"@azure/core-util": "^1.9.1",
|
|
110
|
-
"@azure/logger": "^1.
|
|
110
|
+
"@azure/logger": "^1.1.4",
|
|
111
111
|
"buffer": "^6.0.3",
|
|
112
112
|
"is-buffer": "^2.0.5",
|
|
113
113
|
"process": "^0.11.10",
|
|
114
114
|
"rhea-promise": "^3.0.0",
|
|
115
|
-
"tslib": "^2.
|
|
115
|
+
"tslib": "^2.8.1"
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
118
|
"@azure-tools/test-credential": "^2.0.0",
|
|
@@ -120,26 +120,25 @@
|
|
|
120
120
|
"@azure-tools/vite-plugin-browser-test-map": ">=1.0.0-alpha <1.0.0-alphb",
|
|
121
121
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
|
122
122
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
|
123
|
-
"@azure/identity": "^4.
|
|
124
|
-
"@azure/keyvault-secrets": "^4.
|
|
123
|
+
"@azure/identity": "^4.6.0",
|
|
124
|
+
"@azure/keyvault-secrets": "^4.9.0",
|
|
125
125
|
"@azure/mock-hub": ">=1.0.0-alpha <1.0.0-alphb",
|
|
126
126
|
"@rollup/plugin-inject": "^5.0.5",
|
|
127
|
-
"@types/chai-as-promised": "^
|
|
128
|
-
"@types/debug": "^4.1.
|
|
127
|
+
"@types/chai-as-promised": "^8.0.1",
|
|
128
|
+
"@types/debug": "^4.1.12",
|
|
129
129
|
"@types/node": "^18.0.0",
|
|
130
130
|
"@types/ws": "^7.2.4",
|
|
131
131
|
"@vitest/browser": "^3.0.3",
|
|
132
132
|
"@vitest/coverage-istanbul": "^3.0.3",
|
|
133
|
-
"chai": "^5.1.
|
|
134
|
-
"chai-as-promised": "^8.0.
|
|
133
|
+
"chai": "^5.1.2",
|
|
134
|
+
"chai-as-promised": "^8.0.1",
|
|
135
135
|
"chai-exclude": "^3.0.0",
|
|
136
136
|
"copyfiles": "^2.4.1",
|
|
137
|
-
"debug": "^4.
|
|
137
|
+
"debug": "^4.4.0",
|
|
138
138
|
"dotenv": "^16.0.0",
|
|
139
139
|
"eslint": "^9.9.0",
|
|
140
140
|
"https-proxy-agent": "^7.0.0",
|
|
141
141
|
"playwright": "^1.45.3",
|
|
142
|
-
"tsx": "^4.16.2",
|
|
143
142
|
"typescript": "~5.7.2",
|
|
144
143
|
"vitest": "^3.0.3",
|
|
145
144
|
"ws": "^8.2.0"
|