@azure/eventhubs-checkpointstore-table 1.0.0-alpha.20240801.2 → 1.0.0-alpha.20240805.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +5 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/log.d.ts +12 -0
- package/dist/browser/log.d.ts.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/tableCheckpointStore.d.ts +94 -0
- package/dist/browser/tableCheckpointStore.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/tableCheckpointStore.js +2 -2
- package/dist/browser/tableCheckpointStore.js.map +1 -0
- package/dist/browser/util/error.d.ts +9 -0
- package/dist/browser/util/error.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/util/error.js +1 -1
- package/dist/browser/util/error.js.map +1 -0
- package/dist/commonjs/index.d.ts +3 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +10 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/log.d.ts +12 -0
- package/dist/commonjs/log.d.ts.map +1 -0
- package/dist/commonjs/log.js +23 -0
- package/dist/commonjs/log.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/tableCheckpointStore.d.ts +94 -0
- package/dist/commonjs/tableCheckpointStore.d.ts.map +1 -0
- package/dist/commonjs/tableCheckpointStore.js +219 -0
- package/dist/commonjs/tableCheckpointStore.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/commonjs/util/error.d.ts +9 -0
- package/dist/commonjs/util/error.d.ts.map +1 -0
- package/dist/commonjs/util/error.js +22 -0
- package/dist/commonjs/util/error.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/log.d.ts +12 -0
- package/dist/esm/log.d.ts.map +1 -0
- package/dist/esm/log.js +19 -0
- package/dist/esm/log.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/tableCheckpointStore.d.ts +94 -0
- package/dist/esm/tableCheckpointStore.d.ts.map +1 -0
- package/dist/{index.js → esm/tableCheckpointStore.js} +10 -36
- package/dist/esm/tableCheckpointStore.js.map +1 -0
- package/dist/esm/util/error.d.ts +9 -0
- package/dist/esm/util/error.d.ts.map +1 -0
- package/dist/esm/util/error.js +19 -0
- package/dist/esm/util/error.js.map +1 -0
- package/package.json +73 -51
- package/dist/index.js.map +0 -1
- package/dist-esm/src/index.js +0 -6
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/src/tableCheckpointStore.js.map +0 -1
- package/dist-esm/src/util/error.js.map +0 -1
- /package/{dist-esm/src → dist/browser}/log.js +0 -0
- /package/{dist-esm/src → dist/browser}/log.js.map +0 -0
- /package/{typings → dist}/eventhubs-checkpointstore-table.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableCheckpointStore.js","sourceRoot":"","sources":["../../src/tableCheckpointStore.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAGlC,oDAAkF;AAClF,qCAAsD;AAEtD;;;GAGG;AACH,SAAS,aAAa,CACpB,KAAQ;IAER,OAAO,OAAQ,KAAa,CAAC,SAAS,KAAK,QAAQ,CAAC;AACtD,CAAC;AAwCD;;GAEG;AACH,MAAa,oBAAoB;IAG/B,YAAY,WAAwB;QAClC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,aAAa,CACjB,uBAA+B,EAC/B,YAAoB,EACpB,aAAqB;;QAErB,MAAM,YAAY,GAAG,GAAG,uBAAuB,IAAI,YAAY,IAAI,aAAa,YAAY,CAAC;QAC7F,MAAM,uBAAuB,GAAyB,EAAE,C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CAAC,WAAW,EAAE,CAAC,CAAC;YAC3F,OAAO;QACT,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,eAAM,CAAC,OAAO,CACZ,+DAA+D,UAAU,CAAC,WAAW,GAAG,EACxF,GAAG,CAAC,OAAO,CACZ,CAAC;YACF,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAjND,oDAiNC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Checkpoint, CheckpointStore, PartitionOwnership } from \"@azure/event-hubs\";\nimport { TableClient, TableInsertEntityHeaders, odata } from \"@azure/data-tables\";\nimport { logErrorStackTrace, logger } from \"./log.js\";\n\n/**\n *\n * Checks if the value contains a `Timestamp` field of type `string`.\n */\nfunction _hasTimestamp<T extends TableInsertEntityHeaders>(\n value: T,\n): value is T & { Timestamp: string } {\n return typeof (value as any).Timestamp === \"string\";\n}\n\n/**\n * A checkpoint entity of type CheckpointEntity to be stored in the table\n * @internal\n *\n */\nexport interface CheckpointEntity {\n /**\n * The partitionKey is a composite key assembled in the following format:\n * `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Checkpoint`\n */\n partitionKey: string;\n /**\n * The rowKey is the partitionId\n *\n */\n rowKey: string;\n sequencenumber: string;\n offset: string;\n}\n\n/**\n * An ownership entity of type PartitionOwnership to be stored in the table\n * @internal\n */\nexport interface PartitionOwnershipEntity {\n /**\n * The partitionKey is a composite key assembled in the following format:\n * `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Ownership`\n */\n partitionKey: string;\n /**\n * The rowKey is the partitionId\n *\n */\n rowKey: string;\n ownerid: string;\n}\n\n/**\n * An implementation of CheckpointStore that uses Azure Table Storage to persist checkpoint data.\n */\nexport class TableCheckpointStore implements CheckpointStore {\n private _tableClient: TableClient;\n\n constructor(tableClient: TableClient) {\n this._tableClient = tableClient;\n }\n\n /**\n * Get the list of all existing partition ownership from the underlying data store. May return empty\n * results if there are is no existing ownership information.\n * Partition Ownership contains the information on which `EventHubConsumerClient` subscribe call is currently processing the partition.\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 Partition ownership details of all the partitions that have had an owner.\n */\n async listOwnership(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n ): Promise<PartitionOwnership[]> {\n const partitionKey = `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Ownership`;\n const partitionOwnershipArray: PartitionOwnership[] = [];\n const entitiesIter = this._tableClient.listEntities<PartitionOwnershipEntity>({\n queryOptions: { filter: odata`PartitionKey eq ${partitionKey}` },\n });\n try {\n for await (const entity of entitiesIter) {\n if (!entity.timestamp) {\n throw new Error(\n `Unable to retrieve timestamp from partitionKey \"${partitionKey}\", rowKey \"${entity.rowKey}\"`,\n );\n }\n\n const partitionOwnership: PartitionOwnership = {\n fullyQualifiedNamespace,\n eventHubName,\n consumerGroup,\n ownerId: entity.ownerid,\n partitionId: entity.rowKey,\n lastModifiedTimeInMs: new Date(entity.timestamp).getTime(),\n etag: entity.etag,\n };\n partitionOwnershipArray.push(partitionOwnership);\n }\n return partitionOwnershipArray;\n } catch (err: any) {\n logger.warning(`Error occurred while fetching the list of entities`, err.message);\n logErrorStackTrace(err);\n if (err?.name === \"AbortError\") throw err;\n\n throw new Error(`Error occurred while fetching the list of entities. \\n${err}`);\n }\n }\n\n /**\n * Claim ownership of a list of partitions. This will return the list of partitions that were\n * successfully claimed.\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 partitions this instance successfully claimed ownership.\n */\n async claimOwnership(partitionOwnership: PartitionOwnership[]): Promise<PartitionOwnership[]> {\n const partitionOwnershipArray: PartitionOwnership[] = [];\n\n for (const ownership of partitionOwnership) {\n const updatedOwnership = { ...ownership };\n const partitionKey = `${ownership.fullyQualifiedNamespace} ${ownership.eventHubName} ${ownership.consumerGroup} Ownership`;\n const ownershipEntity: PartitionOwnershipEntity = {\n partitionKey: partitionKey,\n rowKey: ownership.partitionId,\n ownerid: ownership.ownerId,\n };\n\n // When we have an etag, we know the entity existed.\n // If we encounter an error we should fail.\n try {\n if (ownership.etag) {\n const updatedMetadata = await this._tableClient.updateEntity(ownershipEntity, \"Replace\", {\n etag: ownership.etag,\n });\n const entityRetrieved = await this._tableClient.getEntity(\n ownershipEntity.partitionKey,\n ownershipEntity.rowKey,\n );\n if (!entityRetrieved.timestamp) {\n throw new Error(\n `Unable to retrieve timestamp from partitionKey \"${partitionKey}\", rowKey \"${entityRetrieved.rowKey}\"`,\n );\n }\n updatedOwnership.lastModifiedTimeInMs = new Date(entityRetrieved.timestamp).getTime();\n updatedOwnership.etag = updatedMetadata.etag;\n partitionOwnershipArray.push(updatedOwnership);\n logger.info(\n `[${ownership.ownerId}] Claimed ownership successfully for partition: ${ownership.partitionId}`,\n `LastModifiedTime: ${ownership.lastModifiedTimeInMs}, ETag: ${ownership.etag}`,\n );\n } else {\n const newOwnershipMetadata = await this._tableClient.createEntity(ownershipEntity, {\n requestOptions: {\n customHeaders: {\n Prefer: \"return-content\",\n },\n },\n });\n\n if (!_hasTimestamp(newOwnershipMetadata)) {\n throw new Error(\n `Unable to retrieve timestamp from partitionKey \"${partitionKey}\", rowKey \"${ownershipEntity.rowKey}\"`,\n );\n }\n\n updatedOwnership.lastModifiedTimeInMs = new Date(\n newOwnershipMetadata.Timestamp,\n ).getTime();\n updatedOwnership.etag = newOwnershipMetadata.etag;\n partitionOwnershipArray.push(updatedOwnership);\n }\n } catch (err: any) {\n if (err.statusCode === 412) {\n // etag failures (precondition not met) aren't fatal errors. They happen\n // as multiple consumers attempt to claim the same partition (first one wins)\n // and losers get this error.\n logger.verbose(\n `[${ownership.ownerId}] Did not claim partition ${ownership.partitionId}. Another processor has already claimed it.`,\n );\n continue;\n }\n logger.warning(\n `Error occurred while claiming ownership for partition: ${ownership.partitionId}`,\n err.message,\n );\n logErrorStackTrace(err);\n }\n }\n return partitionOwnershipArray;\n }\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 */\n async listCheckpoints(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n ): Promise<Checkpoint[]> {\n const partitionKey = `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Checkpoint`;\n const checkpoints: Checkpoint[] = [];\n const entitiesIter = this._tableClient.listEntities<CheckpointEntity>({\n queryOptions: { filter: odata`PartitionKey eq ${partitionKey}` },\n });\n for await (const entity of entitiesIter) {\n checkpoints.push({\n consumerGroup,\n eventHubName,\n fullyQualifiedNamespace,\n partitionId: entity.rowKey,\n offset: parseInt(entity.offset, 10),\n sequenceNumber: parseInt(entity.sequencenumber, 10),\n });\n }\n return checkpoints;\n }\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 * @returns A promise that resolves when the checkpoint has been updated.\n */\n async updateCheckpoint(checkpoint: Checkpoint): Promise<void> {\n const partitionKey = `${checkpoint.fullyQualifiedNamespace} ${checkpoint.eventHubName} ${checkpoint.consumerGroup} Checkpoint`;\n const checkpointEntity: CheckpointEntity = {\n partitionKey: partitionKey,\n rowKey: checkpoint.partitionId,\n sequencenumber: checkpoint.sequenceNumber.toString(),\n offset: checkpoint.offset.toString(),\n };\n try {\n await this._tableClient.upsertEntity(checkpointEntity);\n logger.verbose(`Updated checkpoint successfully for partition: ${checkpoint.partitionId}`);\n return;\n } catch (err: any) {\n logger.verbose(\n `Error occurred while updating the checkpoint for partition: ${checkpoint.partitionId}.`,\n err.message,\n );\n throw err;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.47.5"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Logs and Throws TypeError if given parameter is undefined or null
|
|
4
|
+
* @param methodName - Name of the method that was passed the parameter
|
|
5
|
+
* @param parameterName - Name of the parameter to check
|
|
6
|
+
* @param parameterValue - Value of the parameter to check
|
|
7
|
+
*/
|
|
8
|
+
export declare function throwTypeErrorIfParameterMissing(methodName: string, parameterName: string, parameterValue: unknown): void;
|
|
9
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/util/error.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,OAAO,GACtB,IAAI,CASN"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.throwTypeErrorIfParameterMissing = throwTypeErrorIfParameterMissing;
|
|
6
|
+
const log_js_1 = require("../log.js");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* Logs and Throws TypeError if given parameter is undefined or null
|
|
10
|
+
* @param methodName - Name of the method that was passed the parameter
|
|
11
|
+
* @param parameterName - Name of the parameter to check
|
|
12
|
+
* @param parameterValue - Value of the parameter to check
|
|
13
|
+
*/
|
|
14
|
+
function throwTypeErrorIfParameterMissing(methodName, parameterName, parameterValue) {
|
|
15
|
+
if (parameterValue === undefined || parameterValue === null) {
|
|
16
|
+
const error = new TypeError(`${methodName} called without required argument "${parameterName}"`);
|
|
17
|
+
log_js_1.logger.warning(error.message);
|
|
18
|
+
(0, log_js_1.logErrorStackTrace)(error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/util/error.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAWlC,4EAaC;AAtBD,sCAAuD;AAEvD;;;;;;GAMG;AACH,SAAgB,gCAAgC,CAC9C,UAAkB,EAClB,aAAqB,EACrB,cAAuB;IAEvB,IAAI,cAAc,KAAK,SAAS,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,IAAI,SAAS,CACzB,GAAG,UAAU,sCAAsC,aAAa,GAAG,CACpE,CAAC;QACF,eAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAA,2BAAkB,EAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { logErrorStackTrace, logger } from \"../log.js\";\n\n/**\n * @internal\n * Logs and Throws TypeError if given parameter is undefined or null\n * @param methodName - Name of the method that was passed the parameter\n * @param parameterName - Name of the parameter to check\n * @param parameterValue - Value of the parameter to check\n */\nexport function throwTypeErrorIfParameterMissing(\n methodName: string,\n parameterName: string,\n parameterValue: unknown,\n): void {\n if (parameterValue === undefined || parameterValue === null) {\n const error = new TypeError(\n `${methodName} called without required argument \"${parameterName}\"`,\n );\n logger.warning(error.message);\n logErrorStackTrace(error);\n throw error;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport { TableCheckpointStore } from \"./tableCheckpointStore.js\";\nexport { logger } from \"./log.js\";\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@azure/logger` configuration for this package.
|
|
3
|
+
* This will output logs using the `azure:eventhubs-checkpointstore-table` namespace prefix.
|
|
4
|
+
*/
|
|
5
|
+
export declare const logger: import("@azure/logger").AzureLogger;
|
|
6
|
+
/**
|
|
7
|
+
* Logs the error's stack trace to "verbose" if a stack trace is available.
|
|
8
|
+
* @param error - Error containing a stack trace.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function logErrorStackTrace(error: unknown): void;
|
|
12
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,MAAM,qCAAwD,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAIvD"}
|
package/dist/esm/log.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { createClientLogger } from "@azure/logger";
|
|
4
|
+
/**
|
|
5
|
+
* The `@azure/logger` configuration for this package.
|
|
6
|
+
* This will output logs using the `azure:eventhubs-checkpointstore-table` namespace prefix.
|
|
7
|
+
*/
|
|
8
|
+
export const logger = createClientLogger("eventhubs-checkpointstore-table");
|
|
9
|
+
/**
|
|
10
|
+
* Logs the error's stack trace to "verbose" if a stack trace is available.
|
|
11
|
+
* @param error - Error containing a stack trace.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export function logErrorStackTrace(error) {
|
|
15
|
+
if (error && typeof error === "object" && "stack" in error) {
|
|
16
|
+
logger.verbose(error.stack);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,iCAAiC,CAAC,CAAC;AAE5E;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;QAC3D,MAAM,CAAC,OAAO,CAAE,KAAa,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\n\n/**\n * The `@azure/logger` configuration for this package.\n * This will output logs using the `azure:eventhubs-checkpointstore-table` namespace prefix.\n */\nexport const logger = createClientLogger(\"eventhubs-checkpointstore-table\");\n\n/**\n * Logs the error's stack trace to \"verbose\" if a stack trace is available.\n * @param error - Error containing a stack trace.\n * @internal\n */\nexport function logErrorStackTrace(error: unknown): void {\n if (error && typeof error === \"object\" && \"stack\" in error) {\n logger.verbose((error as any).stack);\n }\n}\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Checkpoint, CheckpointStore, PartitionOwnership } from "@azure/event-hubs";
|
|
2
|
+
import { TableClient } from "@azure/data-tables";
|
|
3
|
+
/**
|
|
4
|
+
* A checkpoint entity of type CheckpointEntity to be stored in the table
|
|
5
|
+
* @internal
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export interface CheckpointEntity {
|
|
9
|
+
/**
|
|
10
|
+
* The partitionKey is a composite key assembled in the following format:
|
|
11
|
+
* `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Checkpoint`
|
|
12
|
+
*/
|
|
13
|
+
partitionKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* The rowKey is the partitionId
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
rowKey: string;
|
|
19
|
+
sequencenumber: string;
|
|
20
|
+
offset: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* An ownership entity of type PartitionOwnership to be stored in the table
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export interface PartitionOwnershipEntity {
|
|
27
|
+
/**
|
|
28
|
+
* The partitionKey is a composite key assembled in the following format:
|
|
29
|
+
* `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Ownership`
|
|
30
|
+
*/
|
|
31
|
+
partitionKey: string;
|
|
32
|
+
/**
|
|
33
|
+
* The rowKey is the partitionId
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
rowKey: string;
|
|
37
|
+
ownerid: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An implementation of CheckpointStore that uses Azure Table Storage to persist checkpoint data.
|
|
41
|
+
*/
|
|
42
|
+
export declare class TableCheckpointStore implements CheckpointStore {
|
|
43
|
+
private _tableClient;
|
|
44
|
+
constructor(tableClient: TableClient);
|
|
45
|
+
/**
|
|
46
|
+
* Get the list of all existing partition ownership from the underlying data store. May return empty
|
|
47
|
+
* results if there are is no existing ownership information.
|
|
48
|
+
* Partition Ownership contains the information on which `EventHubConsumerClient` subscribe call is currently processing the partition.
|
|
49
|
+
*
|
|
50
|
+
* @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to
|
|
51
|
+
* <yournamespace>.servicebus.windows.net.
|
|
52
|
+
* @param eventHubName - The event hub name.
|
|
53
|
+
* @param consumerGroup - The consumer group name.
|
|
54
|
+
* @param options - A set of options that can be specified to influence the behavior of this method.
|
|
55
|
+
* - `abortSignal`: A signal used to request operation cancellation.
|
|
56
|
+
* - `tracingOptions`: Options for configuring tracing.
|
|
57
|
+
* @returns Partition ownership details of all the partitions that have had an owner.
|
|
58
|
+
*/
|
|
59
|
+
listOwnership(fullyQualifiedNamespace: string, eventHubName: string, consumerGroup: string): Promise<PartitionOwnership[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Claim ownership of a list of partitions. This will return the list of partitions that were
|
|
62
|
+
* successfully claimed.
|
|
63
|
+
*
|
|
64
|
+
* @param partitionOwnership - The list of partition ownership this instance is claiming to own.
|
|
65
|
+
* @param options - A set of options that can be specified to influence the behavior of this method.
|
|
66
|
+
* - `abortSignal`: A signal used to request operation cancellation.
|
|
67
|
+
* - `tracingOptions`: Options for configuring tracing.
|
|
68
|
+
* @returns A list partitions this instance successfully claimed ownership.
|
|
69
|
+
*/
|
|
70
|
+
claimOwnership(partitionOwnership: PartitionOwnership[]): Promise<PartitionOwnership[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Lists all the checkpoints in a data store for a given namespace, eventhub and consumer group.
|
|
73
|
+
*
|
|
74
|
+
* @param fullyQualifiedNamespace - The fully qualified Event Hubs namespace. This is likely to be similar to
|
|
75
|
+
* <yournamespace>.servicebus.windows.net.
|
|
76
|
+
* @param eventHubName - The event hub name.
|
|
77
|
+
* @param consumerGroup - The consumer group name.
|
|
78
|
+
* @param options - A set of options that can be specified to influence the behavior of this method.
|
|
79
|
+
* - `abortSignal`: A signal used to request operation cancellation.
|
|
80
|
+
* - `tracingOptions`: Options for configuring tracing.
|
|
81
|
+
*/
|
|
82
|
+
listCheckpoints(fullyQualifiedNamespace: string, eventHubName: string, consumerGroup: string): Promise<Checkpoint[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Updates the checkpoint in the data store for a partition.
|
|
85
|
+
*
|
|
86
|
+
* @param checkpoint - The checkpoint.
|
|
87
|
+
* @param options - A set of options that can be specified to influence the behavior of this method.
|
|
88
|
+
* - `abortSignal`: A signal used to request operation cancellation.
|
|
89
|
+
* - `tracingOptions`: Options for configuring tracing.
|
|
90
|
+
* @returns A promise that resolves when the checkpoint has been updated.
|
|
91
|
+
*/
|
|
92
|
+
updateCheckpoint(checkpoint: Checkpoint): Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=tableCheckpointStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableCheckpointStore.d.ts","sourceRoot":"","sources":["../../src/tableCheckpointStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAmC,MAAM,oBAAoB,CAAC;AAalF;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,OAAO,CAAC,YAAY,CAAc;gBAEtB,WAAW,EAAE,WAAW;IAIpC;;;;;;;;;;;;;OAaG;IACG,aAAa,CACjB,uBAAuB,EAAE,MAAM,EAC/B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAmChC;;;;;;;;;OASG;IACG,cAAc,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IA4E7F;;;;;;;;;;OAUG;IACG,eAAe,CACnB,uBAAuB,EAAE,MAAM,EAC/B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,EAAE,CAAC;IAmBxB;;;;;;;;OAQG;IACG,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB9D"}
|
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var dataTables = require('@azure/data-tables');
|
|
7
|
-
var logger$1 = require('@azure/logger');
|
|
8
|
-
|
|
9
|
-
// Copyright (c) Microsoft Corporation.
|
|
10
|
-
// Licensed under the MIT license.
|
|
11
|
-
/**
|
|
12
|
-
* The `@azure/logger` configuration for this package.
|
|
13
|
-
* This will output logs using the `azure:eventhubs-checkpointstore-table` namespace prefix.
|
|
14
|
-
*/
|
|
15
|
-
const logger = logger$1.createClientLogger("eventhubs-checkpointstore-table");
|
|
16
|
-
/**
|
|
17
|
-
* Logs the error's stack trace to "verbose" if a stack trace is available.
|
|
18
|
-
* @param error - Error containing a stack trace.
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
function logErrorStackTrace(error) {
|
|
22
|
-
if (error && typeof error === "object" && "stack" in error) {
|
|
23
|
-
logger.verbose(error.stack);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
1
|
// Copyright (c) Microsoft Corporation.
|
|
28
2
|
// Licensed under the MIT license.
|
|
3
|
+
import { __asyncValues } from "tslib";
|
|
4
|
+
import { odata } from "@azure/data-tables";
|
|
5
|
+
import { logErrorStackTrace, logger } from "./log.js";
|
|
29
6
|
/**
|
|
30
7
|
*
|
|
31
8
|
* Checks if the value contains a `Timestamp` field of type `string`.
|
|
@@ -36,7 +13,7 @@ function _hasTimestamp(value) {
|
|
|
36
13
|
/**
|
|
37
14
|
* An implementation of CheckpointStore that uses Azure Table Storage to persist checkpoint data.
|
|
38
15
|
*/
|
|
39
|
-
class TableCheckpointStore {
|
|
16
|
+
export class TableCheckpointStore {
|
|
40
17
|
constructor(tableClient) {
|
|
41
18
|
this._tableClient = tableClient;
|
|
42
19
|
}
|
|
@@ -59,11 +36,11 @@ class TableCheckpointStore {
|
|
|
59
36
|
const partitionKey = `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Ownership`;
|
|
60
37
|
const partitionOwnershipArray = [];
|
|
61
38
|
const entitiesIter = this._tableClient.listEntities({
|
|
62
|
-
queryOptions: { filter:
|
|
39
|
+
queryOptions: { filter: odata `PartitionKey eq ${partitionKey}` },
|
|
63
40
|
});
|
|
64
41
|
try {
|
|
65
42
|
try {
|
|
66
|
-
for (var _d = true, entitiesIter_1 =
|
|
43
|
+
for (var _d = true, entitiesIter_1 = __asyncValues(entitiesIter), entitiesIter_1_1; entitiesIter_1_1 = await entitiesIter_1.next(), _a = entitiesIter_1_1.done, !_a; _d = true) {
|
|
67
44
|
_c = entitiesIter_1_1.value;
|
|
68
45
|
_d = false;
|
|
69
46
|
const entity = _c;
|
|
@@ -181,10 +158,10 @@ class TableCheckpointStore {
|
|
|
181
158
|
const partitionKey = `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Checkpoint`;
|
|
182
159
|
const checkpoints = [];
|
|
183
160
|
const entitiesIter = this._tableClient.listEntities({
|
|
184
|
-
queryOptions: { filter:
|
|
161
|
+
queryOptions: { filter: odata `PartitionKey eq ${partitionKey}` },
|
|
185
162
|
});
|
|
186
163
|
try {
|
|
187
|
-
for (var _d = true, entitiesIter_2 =
|
|
164
|
+
for (var _d = true, entitiesIter_2 = __asyncValues(entitiesIter), entitiesIter_2_1; entitiesIter_2_1 = await entitiesIter_2.next(), _a = entitiesIter_2_1.done, !_a; _d = true) {
|
|
188
165
|
_c = entitiesIter_2_1.value;
|
|
189
166
|
_d = false;
|
|
190
167
|
const entity = _c;
|
|
@@ -230,12 +207,9 @@ class TableCheckpointStore {
|
|
|
230
207
|
return;
|
|
231
208
|
}
|
|
232
209
|
catch (err) {
|
|
233
|
-
logger.verbose(`Error occurred while
|
|
210
|
+
logger.verbose(`Error occurred while updating the checkpoint for partition: ${checkpoint.partitionId}.`, err.message);
|
|
234
211
|
throw err;
|
|
235
212
|
}
|
|
236
213
|
}
|
|
237
214
|
}
|
|
238
|
-
|
|
239
|
-
exports.TableCheckpointStore = TableCheckpointStore;
|
|
240
|
-
exports.logger = logger;
|
|
241
|
-
//# sourceMappingURL=index.js.map
|
|
215
|
+
//# sourceMappingURL=tableCheckpointStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableCheckp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AAE,EAAE,CAAC;iBACpD,CAAC,CAAC;YACL,CAAC;;;;;;;;;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,gBAAgB,CAAC,UAAsB;QAC3C,MAAM,YAAY,GAAG,GAAG,UAAU,CAAC,uBAAuB,IAAI,UAAU,CAAC,YAAY,IAAI,UAAU,CAAC,aAAa,aAAa,CAAC;QAC/H,MAAM,gBAAgB,GAAqB;YACzC,YAAY,EAAE,YAAY;YAC1B,MAAM,EAAE,UAAU,CAAC,WAAW;YAC9B,cAAc,EAAE,UAAU,CAAC,cAAc,CAAC,QAAQ,EAAE;YACpD,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE;SACrC,CAAC;QACF,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;YACvD,MAAM,CAAC,OAAO,CAAC,kDAAkD,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;YAC3F,OAAO;QACT,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,OAAO,CACZ,+DAA+D,UAAU,CAAC,WAAW,GAAG,EACxF,GAAG,CAAC,OAAO,CACZ,CAAC;YACF,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Checkpoint, CheckpointStore, PartitionOwnership } from \"@azure/event-hubs\";\nimport { TableClient, TableInsertEntityHeaders, odata } from \"@azure/data-tables\";\nimport { logErrorStackTrace, logger } from \"./log.js\";\n\n/**\n *\n * Checks if the value contains a `Timestamp` field of type `string`.\n */\nfunction _hasTimestamp<T extends TableInsertEntityHeaders>(\n value: T,\n): value is T & { Timestamp: string } {\n return typeof (value as any).Timestamp === \"string\";\n}\n\n/**\n * A checkpoint entity of type CheckpointEntity to be stored in the table\n * @internal\n *\n */\nexport interface CheckpointEntity {\n /**\n * The partitionKey is a composite key assembled in the following format:\n * `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Checkpoint`\n */\n partitionKey: string;\n /**\n * The rowKey is the partitionId\n *\n */\n rowKey: string;\n sequencenumber: string;\n offset: string;\n}\n\n/**\n * An ownership entity of type PartitionOwnership to be stored in the table\n * @internal\n */\nexport interface PartitionOwnershipEntity {\n /**\n * The partitionKey is a composite key assembled in the following format:\n * `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Ownership`\n */\n partitionKey: string;\n /**\n * The rowKey is the partitionId\n *\n */\n rowKey: string;\n ownerid: string;\n}\n\n/**\n * An implementation of CheckpointStore that uses Azure Table Storage to persist checkpoint data.\n */\nexport class TableCheckpointStore implements CheckpointStore {\n private _tableClient: TableClient;\n\n constructor(tableClient: TableClient) {\n this._tableClient = tableClient;\n }\n\n /**\n * Get the list of all existing partition ownership from the underlying data store. May return empty\n * results if there are is no existing ownership information.\n * Partition Ownership contains the information on which `EventHubConsumerClient` subscribe call is currently processing the partition.\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 Partition ownership details of all the partitions that have had an owner.\n */\n async listOwnership(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n ): Promise<PartitionOwnership[]> {\n const partitionKey = `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Ownership`;\n const partitionOwnershipArray: PartitionOwnership[] = [];\n const entitiesIter = this._tableClient.listEntities<PartitionOwnershipEntity>({\n queryOptions: { filter: odata`PartitionKey eq ${partitionKey}` },\n });\n try {\n for await (const entity of entitiesIter) {\n if (!entity.timestamp) {\n throw new Error(\n `Unable to retrieve timestamp from partitionKey \"${partitionKey}\", rowKey \"${entity.rowKey}\"`,\n );\n }\n\n const partitionOwnership: PartitionOwnership = {\n fullyQualifiedNamespace,\n eventHubName,\n consumerGroup,\n ownerId: entity.ownerid,\n partitionId: entity.rowKey,\n lastModifiedTimeInMs: new Date(entity.timestamp).getTime(),\n etag: entity.etag,\n };\n partitionOwnershipArray.push(partitionOwnership);\n }\n return partitionOwnershipArray;\n } catch (err: any) {\n logger.warning(`Error occurred while fetching the list of entities`, err.message);\n logErrorStackTrace(err);\n if (err?.name === \"AbortError\") throw err;\n\n throw new Error(`Error occurred while fetching the list of entities. \\n${err}`);\n }\n }\n\n /**\n * Claim ownership of a list of partitions. This will return the list of partitions that were\n * successfully claimed.\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 partitions this instance successfully claimed ownership.\n */\n async claimOwnership(partitionOwnership: PartitionOwnership[]): Promise<PartitionOwnership[]> {\n const partitionOwnershipArray: PartitionOwnership[] = [];\n\n for (const ownership of partitionOwnership) {\n const updatedOwnership = { ...ownership };\n const partitionKey = `${ownership.fullyQualifiedNamespace} ${ownership.eventHubName} ${ownership.consumerGroup} Ownership`;\n const ownershipEntity: PartitionOwnershipEntity = {\n partitionKey: partitionKey,\n rowKey: ownership.partitionId,\n ownerid: ownership.ownerId,\n };\n\n // When we have an etag, we know the entity existed.\n // If we encounter an error we should fail.\n try {\n if (ownership.etag) {\n const updatedMetadata = await this._tableClient.updateEntity(ownershipEntity, \"Replace\", {\n etag: ownership.etag,\n });\n const entityRetrieved = await this._tableClient.getEntity(\n ownershipEntity.partitionKey,\n ownershipEntity.rowKey,\n );\n if (!entityRetrieved.timestamp) {\n throw new Error(\n `Unable to retrieve timestamp from partitionKey \"${partitionKey}\", rowKey \"${entityRetrieved.rowKey}\"`,\n );\n }\n updatedOwnership.lastModifiedTimeInMs = new Date(entityRetrieved.timestamp).getTime();\n updatedOwnership.etag = updatedMetadata.etag;\n partitionOwnershipArray.push(updatedOwnership);\n logger.info(\n `[${ownership.ownerId}] Claimed ownership successfully for partition: ${ownership.partitionId}`,\n `LastModifiedTime: ${ownership.lastModifiedTimeInMs}, ETag: ${ownership.etag}`,\n );\n } else {\n const newOwnershipMetadata = await this._tableClient.createEntity(ownershipEntity, {\n requestOptions: {\n customHeaders: {\n Prefer: \"return-content\",\n },\n },\n });\n\n if (!_hasTimestamp(newOwnershipMetadata)) {\n throw new Error(\n `Unable to retrieve timestamp from partitionKey \"${partitionKey}\", rowKey \"${ownershipEntity.rowKey}\"`,\n );\n }\n\n updatedOwnership.lastModifiedTimeInMs = new Date(\n newOwnershipMetadata.Timestamp,\n ).getTime();\n updatedOwnership.etag = newOwnershipMetadata.etag;\n partitionOwnershipArray.push(updatedOwnership);\n }\n } catch (err: any) {\n if (err.statusCode === 412) {\n // etag failures (precondition not met) aren't fatal errors. They happen\n // as multiple consumers attempt to claim the same partition (first one wins)\n // and losers get this error.\n logger.verbose(\n `[${ownership.ownerId}] Did not claim partition ${ownership.partitionId}. Another processor has already claimed it.`,\n );\n continue;\n }\n logger.warning(\n `Error occurred while claiming ownership for partition: ${ownership.partitionId}`,\n err.message,\n );\n logErrorStackTrace(err);\n }\n }\n return partitionOwnershipArray;\n }\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 */\n async listCheckpoints(\n fullyQualifiedNamespace: string,\n eventHubName: string,\n consumerGroup: string,\n ): Promise<Checkpoint[]> {\n const partitionKey = `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Checkpoint`;\n const checkpoints: Checkpoint[] = [];\n const entitiesIter = this._tableClient.listEntities<CheckpointEntity>({\n queryOptions: { filter: odata`PartitionKey eq ${partitionKey}` },\n });\n for await (const entity of entitiesIter) {\n checkpoints.push({\n consumerGroup,\n eventHubName,\n fullyQualifiedNamespace,\n partitionId: entity.rowKey,\n offset: parseInt(entity.offset, 10),\n sequenceNumber: parseInt(entity.sequencenumber, 10),\n });\n }\n return checkpoints;\n }\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 * @returns A promise that resolves when the checkpoint has been updated.\n */\n async updateCheckpoint(checkpoint: Checkpoint): Promise<void> {\n const partitionKey = `${checkpoint.fullyQualifiedNamespace} ${checkpoint.eventHubName} ${checkpoint.consumerGroup} Checkpoint`;\n const checkpointEntity: CheckpointEntity = {\n partitionKey: partitionKey,\n rowKey: checkpoint.partitionId,\n sequencenumber: checkpoint.sequenceNumber.toString(),\n offset: checkpoint.offset.toString(),\n };\n try {\n await this._tableClient.upsertEntity(checkpointEntity);\n logger.verbose(`Updated checkpoint successfully for partition: ${checkpoint.partitionId}`);\n return;\n } catch (err: any) {\n logger.verbose(\n `Error occurred while updating the checkpoint for partition: ${checkpoint.partitionId}.`,\n err.message,\n );\n throw err;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Logs and Throws TypeError if given parameter is undefined or null
|
|
4
|
+
* @param methodName - Name of the method that was passed the parameter
|
|
5
|
+
* @param parameterName - Name of the parameter to check
|
|
6
|
+
* @param parameterValue - Value of the parameter to check
|
|
7
|
+
*/
|
|
8
|
+
export declare function throwTypeErrorIfParameterMissing(methodName: string, parameterName: string, parameterValue: unknown): void;
|
|
9
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/util/error.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,OAAO,GACtB,IAAI,CASN"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { logErrorStackTrace, logger } from "../log.js";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Logs and Throws TypeError if given parameter is undefined or null
|
|
7
|
+
* @param methodName - Name of the method that was passed the parameter
|
|
8
|
+
* @param parameterName - Name of the parameter to check
|
|
9
|
+
* @param parameterValue - Value of the parameter to check
|
|
10
|
+
*/
|
|
11
|
+
export function throwTypeErrorIfParameterMissing(methodName, parameterName, parameterValue) {
|
|
12
|
+
if (parameterValue === undefined || parameterValue === null) {
|
|
13
|
+
const error = new TypeError(`${methodName} called without required argument "${parameterName}"`);
|
|
14
|
+
logger.warning(error.message);
|
|
15
|
+
logErrorStackTrace(error);
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/util/error.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAC9C,UAAkB,EAClB,aAAqB,EACrB,cAAuB;IAEvB,IAAI,cAAc,KAAK,SAAS,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,IAAI,SAAS,CACzB,GAAG,UAAU,sCAAsC,aAAa,GAAG,CACpE,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { logErrorStackTrace, logger } from \"../log.js\";\n\n/**\n * @internal\n * Logs and Throws TypeError if given parameter is undefined or null\n * @param methodName - Name of the method that was passed the parameter\n * @param parameterName - Name of the parameter to check\n * @param parameterValue - Value of the parameter to check\n */\nexport function throwTypeErrorIfParameterMissing(\n methodName: string,\n parameterName: string,\n parameterValue: unknown,\n): void {\n if (parameterValue === undefined || parameterValue === null) {\n const error = new TypeError(\n `${methodName} called without required argument \"${parameterName}\"`,\n );\n logger.warning(error.message);\n logErrorStackTrace(error);\n throw error;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/eventhubs-checkpointstore-table",
|
|
3
3
|
"sdk-type": "client",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.20240805.2",
|
|
5
5
|
"description": "An Azure Storage Table solution to store checkpoints when using Event Hubs.",
|
|
6
6
|
"author": "Microsoft Corporation",
|
|
7
7
|
"license": "MIT",
|
|
@@ -17,89 +17,111 @@
|
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
|
19
19
|
},
|
|
20
|
-
"main": "./dist/index.js",
|
|
21
|
-
"module": "dist
|
|
22
|
-
"types": "./
|
|
20
|
+
"main": "./dist/commonjs/index.js",
|
|
21
|
+
"module": "./dist/esm/index.js",
|
|
22
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=18.0.0"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"dist/",
|
|
28
|
-
"dist-esm/src/",
|
|
29
|
-
"typings/eventhubs-checkpointstore-table.d.ts",
|
|
30
28
|
"README.md",
|
|
31
29
|
"LICENSE"
|
|
32
30
|
],
|
|
33
31
|
"scripts": {
|
|
34
32
|
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
|
|
35
|
-
"build:
|
|
36
|
-
"build:
|
|
37
|
-
"build:
|
|
38
|
-
"build:test:browser": "tsc -p . && dev-tool run bundle",
|
|
39
|
-
"build:test:node": "tsc -p . && dev-tool run bundle",
|
|
33
|
+
"build:samples": "echo Obsolete.",
|
|
34
|
+
"build:test:browser": "tshy && dev-tool run build-test",
|
|
35
|
+
"build:test:node": "tshy && dev-tool run build-test",
|
|
40
36
|
"build:test": "npm run build:test:node",
|
|
41
|
-
"build": "npm run clean &&
|
|
42
|
-
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
43
|
-
"clean": "rimraf --glob dist dist-*
|
|
44
|
-
"execute:samples": "
|
|
45
|
-
"extract-api": "
|
|
46
|
-
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
47
|
-
"integration-test:browser": "
|
|
48
|
-
"integration-test:node": "
|
|
37
|
+
"build": "npm run clean && tshy && dev-tool run extract-api",
|
|
38
|
+
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"",
|
|
39
|
+
"clean": "rimraf --glob dist dist-* temp *.tgz *.log .tshy *.xml",
|
|
40
|
+
"execute:samples": "dev-tool samples run samples-dev",
|
|
41
|
+
"extract-api": "tshy && dev-tool run extract-api",
|
|
42
|
+
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"",
|
|
43
|
+
"integration-test:browser": "tshy && dev-tool run build-test && cross-env TEST_MODE=live dev-tool run test:vitest --browser --no-test-proxy",
|
|
44
|
+
"integration-test:node": "cross-env TEST_MODE=live npm run vitest:node",
|
|
49
45
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
50
|
-
"lint:fix": "eslint package.json api-extractor.json README.md
|
|
51
|
-
"lint": "eslint package.json api-extractor.json README.md
|
|
46
|
+
"lint:fix": "eslint package.json api-extractor.json src test README.md --ext .ts --ext .cts --ext .mts --fix --fix-type [problem,suggestion]",
|
|
47
|
+
"lint": "eslint package.json api-extractor.json src test README.md --ext .ts --ext .cts --ext .mts",
|
|
52
48
|
"pack": "npm pack 2>&1",
|
|
53
49
|
"test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
|
|
54
|
-
"test:node": "npm run integration-test:node",
|
|
50
|
+
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
|
55
51
|
"test": "npm run build:test && npm run unit-test && npm run integration-test",
|
|
52
|
+
"vitest:node": "dev-tool run test:vitest --no-test-proxy",
|
|
56
53
|
"unit-test:browser": "echo skipped",
|
|
57
54
|
"unit-test:node": "echo skipped",
|
|
58
55
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
|
59
56
|
},
|
|
57
|
+
"tshy": {
|
|
58
|
+
"exports": {
|
|
59
|
+
"./package.json": "./package.json",
|
|
60
|
+
".": "./src/index.ts"
|
|
61
|
+
},
|
|
62
|
+
"dialects": [
|
|
63
|
+
"esm",
|
|
64
|
+
"commonjs"
|
|
65
|
+
],
|
|
66
|
+
"esmDialects": [
|
|
67
|
+
"browser"
|
|
68
|
+
],
|
|
69
|
+
"selfLink": false
|
|
70
|
+
},
|
|
60
71
|
"dependencies": {
|
|
61
|
-
"@azure/abort-controller": "^2.
|
|
62
|
-
"@azure/event-hubs": "^5.
|
|
72
|
+
"@azure/abort-controller": "^2.1.2",
|
|
73
|
+
"@azure/event-hubs": "^5.12.0",
|
|
63
74
|
"@azure/data-tables": "^13.2.2",
|
|
64
|
-
"@azure/logger": "^1.
|
|
65
|
-
"tslib": "^2.
|
|
75
|
+
"@azure/logger": "^1.1.4",
|
|
76
|
+
"tslib": "^2.6.3"
|
|
66
77
|
},
|
|
67
78
|
"devDependencies": {
|
|
79
|
+
"@azure-tools/test-credential": "^2.0.0",
|
|
80
|
+
"@azure-tools/test-recorder": "^4.0.0",
|
|
81
|
+
"@azure-tools/vite-plugin-browser-test-map": ">=1.0.0-alpha <1.0.0-alphb",
|
|
68
82
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
|
69
83
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
|
84
|
+
"@azure/identity": "^4.4.1",
|
|
70
85
|
"@microsoft/api-extractor": "^7.31.1",
|
|
71
|
-
"@
|
|
72
|
-
"@types/chai-as-promised": "^7.1.
|
|
73
|
-
"@types/chai-string": "^1.4.1",
|
|
86
|
+
"@rollup/plugin-inject": "5.0.5",
|
|
87
|
+
"@types/chai-as-promised": "^7.1.8",
|
|
74
88
|
"@types/debug": "^4.1.4",
|
|
75
|
-
"@types/mocha": "^10.0.0",
|
|
76
89
|
"@types/node": "^18.0.0",
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
90
|
+
"@vitest/browser": "^2.0.5",
|
|
91
|
+
"@vitest/coverage-istanbul": "^2.0.5",
|
|
92
|
+
"buffer": "^6.0.3",
|
|
93
|
+
"chai-as-promised": "^8.0.0",
|
|
94
|
+
"cross-env": "^7.0.3",
|
|
81
95
|
"debug": "^4.1.1",
|
|
82
96
|
"dotenv": "^16.0.0",
|
|
83
97
|
"eslint": "^8.0.0",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"karma-junit-reporter": "^2.0.1",
|
|
92
|
-
"karma-mocha": "^2.0.1",
|
|
93
|
-
"karma-mocha-reporter": "^2.2.5",
|
|
94
|
-
"karma-sourcemap-loader": "^0.3.8",
|
|
95
|
-
"mocha": "^10.0.0",
|
|
96
|
-
"nyc": "^17.0.0",
|
|
97
|
-
"rimraf": "^5.0.5",
|
|
98
|
-
"ts-node": "^10.0.0",
|
|
99
|
-
"typescript": "~5.5.3",
|
|
100
|
-
"util": "^0.12.1"
|
|
98
|
+
"playwright": "^1.45.3",
|
|
99
|
+
"process": "^0.11.10",
|
|
100
|
+
"rimraf": "^6.0.1",
|
|
101
|
+
"stream": "^0.0.3",
|
|
102
|
+
"tshy": "^3.0.2",
|
|
103
|
+
"typescript": "~5.5.4",
|
|
104
|
+
"vitest": "^2.0.5"
|
|
101
105
|
},
|
|
102
106
|
"//sampleConfiguration": {
|
|
103
107
|
"skipFolder": true
|
|
108
|
+
},
|
|
109
|
+
"type": "module",
|
|
110
|
+
"exports": {
|
|
111
|
+
"./package.json": "./package.json",
|
|
112
|
+
".": {
|
|
113
|
+
"browser": {
|
|
114
|
+
"types": "./dist/browser/index.d.ts",
|
|
115
|
+
"default": "./dist/browser/index.js"
|
|
116
|
+
},
|
|
117
|
+
"import": {
|
|
118
|
+
"types": "./dist/esm/index.d.ts",
|
|
119
|
+
"default": "./dist/esm/index.js"
|
|
120
|
+
},
|
|
121
|
+
"require": {
|
|
122
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
123
|
+
"default": "./dist/commonjs/index.js"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
104
126
|
}
|
|
105
127
|
}
|