@azure/eventhubs-checkpointstore-blob 2.0.0-alpha.20250203.2 → 2.0.0-alpha.20250206.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 +53 -54
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -70,9 +70,9 @@ You also need to enable `compilerOptions.allowSyntheticDefaultImports` in your t
|
|
|
70
70
|
|
|
71
71
|
Use the below code snippet to create a `CheckpointStore`. You will need to provide the connection string to your storage account.
|
|
72
72
|
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
```ts snippet:ReadmeSampleCreateCheckpointStore
|
|
74
|
+
import { ContainerClient } from "@azure/storage-blob";
|
|
75
|
+
import { BlobCheckpointStore } from "@azure/eventhubs-checkpointstore-blob";
|
|
76
76
|
|
|
77
77
|
const containerClient = new ContainerClient("storage-connection-string", "container-name");
|
|
78
78
|
|
|
@@ -91,10 +91,10 @@ interface along with code to call the `updateCheckpoint()` method.
|
|
|
91
91
|
|
|
92
92
|
In this example, `SubscriptionHandlers` implements [SubscriptionEventHandlers](https://learn.microsoft.com/javascript/api/@azure/event-hubs/subscriptioneventhandlers) and also handles checkpointing.
|
|
93
93
|
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
```ts snippet:ReadmeSampleCheckpointEvents
|
|
95
|
+
import { ContainerClient } from "@azure/storage-blob";
|
|
96
|
+
import { BlobCheckpointStore } from "@azure/eventhubs-checkpointstore-blob";
|
|
97
|
+
import { EventHubConsumerClient } from "@azure/event-hubs";
|
|
98
98
|
|
|
99
99
|
const storageAccountConnectionString = "storage-account-connection-string";
|
|
100
100
|
const containerName = "container-name";
|
|
@@ -102,53 +102,48 @@ const eventHubConnectionString = "eventhub-connection-string";
|
|
|
102
102
|
const consumerGroup = "my-consumer-group";
|
|
103
103
|
const eventHubName = "eventHubName";
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
await blobContainerClient.create();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const checkpointStore = new BlobCheckpointStore(blobContainerClient);
|
|
113
|
-
const consumerClient = new EventHubConsumerClient(
|
|
114
|
-
consumerGroup,
|
|
115
|
-
eventHubConnectionString,
|
|
116
|
-
eventHubName,
|
|
117
|
-
checkpointStore,
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
const subscription = consumerClient.subscribe({
|
|
121
|
-
processEvents: async (events, context) => {
|
|
122
|
-
// event processing code goes here
|
|
123
|
-
if (events.length === 0) {
|
|
124
|
-
// If the wait time expires (configured via options in maxWaitTimeInSeconds) Event Hubs
|
|
125
|
-
// will pass you an empty array.
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Checkpointing will allow your service to pick up from
|
|
130
|
-
// where it left off when restarting.
|
|
131
|
-
//
|
|
132
|
-
// You'll want to balance how often you checkpoint with the
|
|
133
|
-
// performance of your underlying checkpoint store.
|
|
134
|
-
await context.updateCheckpoint(events[events.length - 1]);
|
|
135
|
-
},
|
|
136
|
-
processError: async (err, context) => {
|
|
137
|
-
// handle any errors that occur during the course of
|
|
138
|
-
// this subscription
|
|
139
|
-
console.log(`Errors in subscription to partition ${context.partitionId}: ${err}`);
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
// Wait for a few seconds to receive events before closing
|
|
144
|
-
await new Promise((resolve) => setTimeout(resolve, 10 * 1000));
|
|
145
|
-
|
|
146
|
-
await subscription.close();
|
|
147
|
-
await consumerClient.close();
|
|
148
|
-
console.log(`Exiting sample`);
|
|
105
|
+
const blobContainerClient = new ContainerClient(storageAccountConnectionString, containerName);
|
|
106
|
+
|
|
107
|
+
if (!(await blobContainerClient.exists())) {
|
|
108
|
+
await blobContainerClient.create();
|
|
149
109
|
}
|
|
150
110
|
|
|
151
|
-
|
|
111
|
+
const checkpointStore = new BlobCheckpointStore(blobContainerClient);
|
|
112
|
+
const consumerClient = new EventHubConsumerClient(
|
|
113
|
+
consumerGroup,
|
|
114
|
+
eventHubConnectionString,
|
|
115
|
+
eventHubName,
|
|
116
|
+
checkpointStore,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const subscription = consumerClient.subscribe({
|
|
120
|
+
processEvents: async (events, context) => {
|
|
121
|
+
// event processing code goes here
|
|
122
|
+
if (events.length === 0) {
|
|
123
|
+
// If the wait time expires (configured via options in maxWaitTimeInSeconds) Event Hubs
|
|
124
|
+
// will pass you an empty array.
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Checkpointing will allow your service to pick up from
|
|
129
|
+
// where it left off when restarting.
|
|
130
|
+
//
|
|
131
|
+
// You'll want to balance how often you checkpoint with the
|
|
132
|
+
// performance of your underlying checkpoint store.
|
|
133
|
+
await context.updateCheckpoint(events[events.length - 1]);
|
|
134
|
+
},
|
|
135
|
+
processError: async (err, context) => {
|
|
136
|
+
// handle any errors that occur during the course of
|
|
137
|
+
// this subscription
|
|
138
|
+
console.log(`Errors in subscription to partition ${context.partitionId}: ${err}`);
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Wait for a few seconds to receive events before closing
|
|
143
|
+
await new Promise((resolve) => setTimeout(resolve, 10 * 1000));
|
|
144
|
+
|
|
145
|
+
await subscription.close();
|
|
146
|
+
await consumerClient.close();
|
|
152
147
|
```
|
|
153
148
|
|
|
154
149
|
## Troubleshooting
|
|
@@ -166,6 +161,12 @@ You can also set the log level programatically by importing the
|
|
|
166
161
|
[@azure/logger](https://www.npmjs.com/package/@azure/logger) package and calling the
|
|
167
162
|
`setLogLevel` function with one of the log level values.
|
|
168
163
|
|
|
164
|
+
```ts snippet:SetLogLevel
|
|
165
|
+
import { setLogLevel } from "@azure/logger";
|
|
166
|
+
|
|
167
|
+
setLogLevel("info");
|
|
168
|
+
```
|
|
169
|
+
|
|
169
170
|
When setting a log level either programatically or via the `AZURE_LOG_LEVEL` environment variable,
|
|
170
171
|
any logs that are written using a log level equal to or less than the one you choose will be emitted.
|
|
171
172
|
For example, when you set the log level to `info`, the logs that are written for levels
|
|
@@ -214,5 +215,3 @@ directory for detailed example.
|
|
|
214
215
|
## Contributing
|
|
215
216
|
|
|
216
217
|
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
|
217
|
-
|
|
218
|
-

|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/eventhubs-checkpointstore-blob",
|
|
3
3
|
"sdk-type": "client",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.20250206.1",
|
|
5
5
|
"description": "An Azure Storage Blob solution to store checkpoints when using Event Hubs.",
|
|
6
6
|
"author": "Microsoft Corporation",
|
|
7
7
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
|
52
52
|
"unit-test:browser": "echo skipped",
|
|
53
53
|
"unit-test:node": "echo skipped",
|
|
54
|
-
"update-snippets": "
|
|
54
|
+
"update-snippets": "dev-tool run update-snippets",
|
|
55
55
|
"vitest:node": "dev-tool run test:vitest --no-test-proxy"
|
|
56
56
|
},
|
|
57
57
|
"tshy": {
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"@azure/abort-controller": "^2.1.2",
|
|
74
74
|
"@azure/core-paging": "^1.6.2",
|
|
75
75
|
"@azure/event-hubs": ">=6.0.0-alpha <6.0.0-alphb",
|
|
76
|
-
"@azure/logger": "^1.1.
|
|
77
|
-
"@azure/storage-blob": "
|
|
76
|
+
"@azure/logger": "^1.1.4",
|
|
77
|
+
"@azure/storage-blob": ">=12.26.0-alpha <12.26.0-alphb",
|
|
78
78
|
"tslib": "^2.6.3"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"@azure/core-util": "^1.9.1",
|
|
86
86
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
|
87
87
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
|
88
|
-
"@azure/identity": "^4.
|
|
88
|
+
"@azure/identity": "^4.6.0",
|
|
89
89
|
"@rollup/plugin-inject": "^5.0.5",
|
|
90
|
-
"@types/chai-as-promised": "^
|
|
90
|
+
"@types/chai-as-promised": "^8.0.1",
|
|
91
91
|
"@types/debug": "^4.1.12",
|
|
92
92
|
"@types/node": "^18.0.0",
|
|
93
93
|
"@vitest/browser": "^3.0.3",
|
|
@@ -101,7 +101,6 @@
|
|
|
101
101
|
"playwright": "^1.45.3",
|
|
102
102
|
"process": "^0.11.10",
|
|
103
103
|
"stream": "^0.0.3",
|
|
104
|
-
"tsx": "^4.16.2",
|
|
105
104
|
"typescript": "~5.7.2",
|
|
106
105
|
"vitest": "^3.0.3"
|
|
107
106
|
},
|