@azure/storage-blob-changefeed 12.0.0-alpha.20230213.2 → 12.0.0-alpha.20230221.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/dist/index.js +30 -149
- package/dist/index.js.map +1 -1
- package/dist-esm/storage-blob-changefeed/src/ChangeFeed.js +5 -28
- package/dist-esm/storage-blob-changefeed/src/ChangeFeed.js.map +1 -1
- package/dist-esm/storage-blob-changefeed/src/ChangeFeedFactory.js +3 -15
- package/dist-esm/storage-blob-changefeed/src/ChangeFeedFactory.js.map +1 -1
- package/dist-esm/storage-blob-changefeed/src/LazyLoadingBlobStream.js +7 -29
- package/dist-esm/storage-blob-changefeed/src/LazyLoadingBlobStream.js.map +1 -1
- package/dist-esm/storage-blob-changefeed/src/Segment.js +3 -15
- package/dist-esm/storage-blob-changefeed/src/Segment.js.map +1 -1
- package/dist-esm/storage-blob-changefeed/src/SegmentFactory.js +3 -15
- package/dist-esm/storage-blob-changefeed/src/SegmentFactory.js.map +1 -1
- package/dist-esm/storage-blob-changefeed/src/Shard.js +3 -15
- package/dist-esm/storage-blob-changefeed/src/Shard.js.map +1 -1
- package/dist-esm/storage-blob-changefeed/src/ShardFactory.js +4 -16
- package/dist-esm/storage-blob-changefeed/src/ShardFactory.js.map +1 -1
- package/dist-esm/storage-blob-changefeed/src/utils/tracing.js +5 -3
- package/dist-esm/storage-blob-changefeed/src/utils/tracing.js.map +1 -1
- package/dist-esm/storage-blob-changefeed/src/utils/utils.common.js +7 -30
- package/dist-esm/storage-blob-changefeed/src/utils/utils.common.js.map +1 -1
- package/package.json +2 -2
- package/types/3.1/storage-blob-changefeed/src/utils/tracing.d.ts +1 -6
- package/types/latest/storage-blob-changefeed/src/ChangeFeed.d.ts.map +1 -1
- package/types/latest/storage-blob-changefeed/src/ChangeFeedFactory.d.ts.map +1 -1
- package/types/latest/storage-blob-changefeed/src/LazyLoadingBlobStream.d.ts.map +1 -1
- package/types/latest/storage-blob-changefeed/src/Segment.d.ts.map +1 -1
- package/types/latest/storage-blob-changefeed/src/SegmentFactory.d.ts.map +1 -1
- package/types/latest/storage-blob-changefeed/src/Shard.d.ts.map +1 -1
- package/types/latest/storage-blob-changefeed/src/ShardFactory.d.ts.map +1 -1
- package/types/latest/storage-blob-changefeed/src/utils/tracing.d.ts +1 -6
- package/types/latest/storage-blob-changefeed/src/utils/tracing.d.ts.map +1 -1
- package/types/latest/storage-blob-changefeed/src/utils/utils.common.d.ts.map +1 -1
- package/types/latest/tsdoc-metadata.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24,8 +24,9 @@ const CHANGE_FEED_CHUNK_BLOCK_DOWNLOAD_SIZE = 16 * 1024 * 1024;
|
|
|
24
24
|
* Creates a span using the global tracer.
|
|
25
25
|
* @internal
|
|
26
26
|
*/
|
|
27
|
-
const
|
|
28
|
-
|
|
27
|
+
const tracingClient = coreTracing.createTracingClient({
|
|
28
|
+
packageName: "@azure/storage-blob-changefeed",
|
|
29
|
+
packageVersion: SDK_VERSION,
|
|
29
30
|
namespace: "Microsoft.Storage",
|
|
30
31
|
});
|
|
31
32
|
|
|
@@ -53,9 +54,8 @@ function getHost(url) {
|
|
|
53
54
|
return urlParsed.hostname;
|
|
54
55
|
}
|
|
55
56
|
async function getYearsPaths(containerClient, options = {}) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
try {
|
|
57
|
+
return tracingClient.withSpan("getYearsPaths", options, async (updatedOptions) => {
|
|
58
|
+
var e_1, _a;
|
|
59
59
|
const years = [];
|
|
60
60
|
try {
|
|
61
61
|
for (var _b = tslib.__asyncValues(containerClient.listBlobsByHierarchy("/", {
|
|
@@ -78,22 +78,11 @@ async function getYearsPaths(containerClient, options = {}) {
|
|
|
78
78
|
finally { if (e_1) throw e_1.error; }
|
|
79
79
|
}
|
|
80
80
|
return years.sort((a, b) => a - b);
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
span.setStatus({
|
|
84
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
85
|
-
message: e.message,
|
|
86
|
-
});
|
|
87
|
-
throw e;
|
|
88
|
-
}
|
|
89
|
-
finally {
|
|
90
|
-
span.end();
|
|
91
|
-
}
|
|
81
|
+
});
|
|
92
82
|
}
|
|
93
83
|
async function getSegmentsInYear(containerClient, year, startTime, endTime, options = {}) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
try {
|
|
84
|
+
return tracingClient.withSpan("getSegmentsInYear", options, async (updatedOptions) => {
|
|
85
|
+
var e_2, _a;
|
|
97
86
|
const segments = [];
|
|
98
87
|
const yearBeginTime = new Date(Date.UTC(year, 0));
|
|
99
88
|
if (endTime && yearBeginTime >= endTime) {
|
|
@@ -122,17 +111,7 @@ async function getSegmentsInYear(containerClient, year, startTime, endTime, opti
|
|
|
122
111
|
finally { if (e_2) throw e_2.error; }
|
|
123
112
|
}
|
|
124
113
|
return segments;
|
|
125
|
-
}
|
|
126
|
-
catch (e) {
|
|
127
|
-
span.setStatus({
|
|
128
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
129
|
-
message: e.message,
|
|
130
|
-
});
|
|
131
|
-
throw e;
|
|
132
|
-
}
|
|
133
|
-
finally {
|
|
134
|
-
span.end();
|
|
135
|
-
}
|
|
114
|
+
});
|
|
136
115
|
}
|
|
137
116
|
function parseDateFromSegmentPath(segmentPath) {
|
|
138
117
|
const splitPath = segmentPath.split("/");
|
|
@@ -256,8 +235,7 @@ class ChangeFeed {
|
|
|
256
235
|
}
|
|
257
236
|
}
|
|
258
237
|
async advanceSegmentIfNecessary(options = {}) {
|
|
259
|
-
|
|
260
|
-
try {
|
|
238
|
+
return tracingClient.withSpan("ChangeFeed-advanceSegmentIfNecessary", options, async (updatedOptions) => {
|
|
261
239
|
if (!this.currentSegment) {
|
|
262
240
|
throw new Error("Empty Change Feed shouldn't call this function.");
|
|
263
241
|
}
|
|
@@ -289,17 +267,7 @@ class ChangeFeed {
|
|
|
289
267
|
this.currentSegment = undefined;
|
|
290
268
|
}
|
|
291
269
|
}
|
|
292
|
-
}
|
|
293
|
-
catch (e) {
|
|
294
|
-
span.setStatus({
|
|
295
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
296
|
-
message: e.message,
|
|
297
|
-
});
|
|
298
|
-
throw e;
|
|
299
|
-
}
|
|
300
|
-
finally {
|
|
301
|
-
span.end();
|
|
302
|
-
}
|
|
270
|
+
});
|
|
303
271
|
}
|
|
304
272
|
hasNext() {
|
|
305
273
|
// Empty ChangeFeed, using currentSegment as the indicator.
|
|
@@ -312,8 +280,7 @@ class ChangeFeed {
|
|
|
312
280
|
return this.currentSegment.dateTime < this.end;
|
|
313
281
|
}
|
|
314
282
|
async getChange(options = {}) {
|
|
315
|
-
|
|
316
|
-
try {
|
|
283
|
+
return tracingClient.withSpan("ChangeFeed-getChange", options, async (updatedOptions) => {
|
|
317
284
|
let event = undefined;
|
|
318
285
|
while (event === undefined && this.hasNext()) {
|
|
319
286
|
event = await this.currentSegment.getChange({
|
|
@@ -326,17 +293,7 @@ class ChangeFeed {
|
|
|
326
293
|
});
|
|
327
294
|
}
|
|
328
295
|
return event;
|
|
329
|
-
}
|
|
330
|
-
catch (e) {
|
|
331
|
-
span.setStatus({
|
|
332
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
333
|
-
message: e.message,
|
|
334
|
-
});
|
|
335
|
-
throw e;
|
|
336
|
-
}
|
|
337
|
-
finally {
|
|
338
|
-
span.end();
|
|
339
|
-
}
|
|
296
|
+
});
|
|
340
297
|
}
|
|
341
298
|
getCursor() {
|
|
342
299
|
var _a;
|
|
@@ -916,8 +873,7 @@ class Segment {
|
|
|
916
873
|
return this.shards.length > this.shardDoneCount;
|
|
917
874
|
}
|
|
918
875
|
async getChange(options = {}) {
|
|
919
|
-
|
|
920
|
-
try {
|
|
876
|
+
return tracingClient.withSpan("Segment-getChange", options, async (updatedOptions) => {
|
|
921
877
|
if (this.shardIndex >= this.shards.length || this.shardIndex < 0) {
|
|
922
878
|
throw new Error("shardIndex invalid.");
|
|
923
879
|
}
|
|
@@ -940,17 +896,7 @@ class Segment {
|
|
|
940
896
|
this.shardIndex = (this.shardIndex + 1) % this.shards.length;
|
|
941
897
|
}
|
|
942
898
|
return event;
|
|
943
|
-
}
|
|
944
|
-
catch (e) {
|
|
945
|
-
span.setStatus({
|
|
946
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
947
|
-
message: e.message,
|
|
948
|
-
});
|
|
949
|
-
throw e;
|
|
950
|
-
}
|
|
951
|
-
finally {
|
|
952
|
-
span.end();
|
|
953
|
-
}
|
|
899
|
+
});
|
|
954
900
|
}
|
|
955
901
|
getCursor() {
|
|
956
902
|
const shardCursors = [];
|
|
@@ -974,8 +920,7 @@ class SegmentFactory {
|
|
|
974
920
|
this.shardFactory = shardFactory;
|
|
975
921
|
}
|
|
976
922
|
async create(containerClient, manifestPath, cursor, options = {}) {
|
|
977
|
-
|
|
978
|
-
try {
|
|
923
|
+
return tracingClient.withSpan("SegmentFactory-create", options, async (updatedOptions) => {
|
|
979
924
|
const shards = [];
|
|
980
925
|
const dateTime = parseDateFromSegmentPath(manifestPath);
|
|
981
926
|
const blobClient = containerClient.getBlobClient(manifestPath);
|
|
@@ -1005,17 +950,7 @@ class SegmentFactory {
|
|
|
1005
950
|
}
|
|
1006
951
|
}
|
|
1007
952
|
return new Segment(shards, shardIndex, dateTime, manifestPath);
|
|
1008
|
-
}
|
|
1009
|
-
catch (e) {
|
|
1010
|
-
span.setStatus({
|
|
1011
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
1012
|
-
message: e.message,
|
|
1013
|
-
});
|
|
1014
|
-
throw e;
|
|
1015
|
-
}
|
|
1016
|
-
finally {
|
|
1017
|
-
span.end();
|
|
1018
|
-
}
|
|
953
|
+
});
|
|
1019
954
|
}
|
|
1020
955
|
}
|
|
1021
956
|
|
|
@@ -1032,8 +967,7 @@ class Shard {
|
|
|
1032
967
|
return (this.chunks.length > 0 || (this.currentChunk !== undefined && this.currentChunk.hasNext()));
|
|
1033
968
|
}
|
|
1034
969
|
async getChange(options = {}) {
|
|
1035
|
-
|
|
1036
|
-
try {
|
|
970
|
+
return tracingClient.withSpan("Shard-getChange", options, async (updatedOptions) => {
|
|
1037
971
|
let event = undefined;
|
|
1038
972
|
while (event === undefined && this.hasNext()) {
|
|
1039
973
|
event = await this.currentChunk.getChange();
|
|
@@ -1046,17 +980,7 @@ class Shard {
|
|
|
1046
980
|
}
|
|
1047
981
|
}
|
|
1048
982
|
return event;
|
|
1049
|
-
}
|
|
1050
|
-
catch (e) {
|
|
1051
|
-
span.setStatus({
|
|
1052
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
1053
|
-
message: e.message,
|
|
1054
|
-
});
|
|
1055
|
-
throw e;
|
|
1056
|
-
}
|
|
1057
|
-
finally {
|
|
1058
|
-
span.end();
|
|
1059
|
-
}
|
|
983
|
+
});
|
|
1060
984
|
}
|
|
1061
985
|
getCursor() {
|
|
1062
986
|
return this.currentChunk === undefined
|
|
@@ -1075,9 +999,8 @@ class ShardFactory {
|
|
|
1075
999
|
this.chunkFactory = chunkFactory;
|
|
1076
1000
|
}
|
|
1077
1001
|
async create(containerClient, shardPath, shardCursor, options = {}) {
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
try {
|
|
1002
|
+
return tracingClient.withSpan("ShardFactory-create", options, async (updatedOptions) => {
|
|
1003
|
+
var e_1, _a;
|
|
1081
1004
|
const chunks = [];
|
|
1082
1005
|
const blockOffset = (shardCursor === null || shardCursor === void 0 ? void 0 : shardCursor.BlockOffset) || 0;
|
|
1083
1006
|
const eventIndex = (shardCursor === null || shardCursor === void 0 ? void 0 : shardCursor.EventIndex) || 0;
|
|
@@ -1128,17 +1051,7 @@ class ShardFactory {
|
|
|
1128
1051
|
});
|
|
1129
1052
|
}
|
|
1130
1053
|
return new Shard(containerClient, this.chunkFactory, chunks, currentChunk, shardPath);
|
|
1131
|
-
}
|
|
1132
|
-
catch (e) {
|
|
1133
|
-
span.setStatus({
|
|
1134
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
1135
|
-
message: e.message,
|
|
1136
|
-
});
|
|
1137
|
-
throw e;
|
|
1138
|
-
}
|
|
1139
|
-
finally {
|
|
1140
|
-
span.end();
|
|
1141
|
-
}
|
|
1054
|
+
});
|
|
1142
1055
|
}
|
|
1143
1056
|
}
|
|
1144
1057
|
|
|
@@ -1241,8 +1154,7 @@ class LazyLoadingBlobStream extends stream.Readable {
|
|
|
1241
1154
|
this.options = options;
|
|
1242
1155
|
}
|
|
1243
1156
|
async downloadBlock(options = {}) {
|
|
1244
|
-
|
|
1245
|
-
try {
|
|
1157
|
+
return tracingClient.withSpan("LazyLoadingBlobStream-downloadBlock", options, async (updatedOptions) => {
|
|
1246
1158
|
const properties = await this.blobClient.getProperties({
|
|
1247
1159
|
abortSignal: options.abortSignal,
|
|
1248
1160
|
tracingOptions: updatedOptions.tracingOptions,
|
|
@@ -1258,17 +1170,7 @@ class LazyLoadingBlobStream extends stream.Readable {
|
|
|
1258
1170
|
tracingOptions: updatedOptions.tracingOptions,
|
|
1259
1171
|
});
|
|
1260
1172
|
this.offset += this.lastDownloadBytes;
|
|
1261
|
-
}
|
|
1262
|
-
catch (e) {
|
|
1263
|
-
span.setStatus({
|
|
1264
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
1265
|
-
message: e.message,
|
|
1266
|
-
});
|
|
1267
|
-
throw e;
|
|
1268
|
-
}
|
|
1269
|
-
finally {
|
|
1270
|
-
span.end();
|
|
1271
|
-
}
|
|
1173
|
+
});
|
|
1272
1174
|
}
|
|
1273
1175
|
/**
|
|
1274
1176
|
* Internal _read() that will be called when the stream wants to pull more data in.
|
|
@@ -1276,9 +1178,9 @@ class LazyLoadingBlobStream extends stream.Readable {
|
|
|
1276
1178
|
* @param size - Optional. The size of data to be read
|
|
1277
1179
|
*/
|
|
1278
1180
|
async _read(size) {
|
|
1279
|
-
var _a
|
|
1280
|
-
|
|
1281
|
-
|
|
1181
|
+
var _a;
|
|
1182
|
+
return tracingClient.withSpan("LazyLoadingBlobStream-read", (_a = this.options) !== null && _a !== void 0 ? _a : {}, async (updatedOptions) => {
|
|
1183
|
+
var _a, _b, _c, _d;
|
|
1282
1184
|
if (!size) {
|
|
1283
1185
|
size = this.readableHighWaterMark;
|
|
1284
1186
|
}
|
|
@@ -1306,17 +1208,7 @@ class LazyLoadingBlobStream extends stream.Readable {
|
|
|
1306
1208
|
if (count < size) {
|
|
1307
1209
|
this.push(null);
|
|
1308
1210
|
}
|
|
1309
|
-
}
|
|
1310
|
-
catch (e) {
|
|
1311
|
-
span.setStatus({
|
|
1312
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
1313
|
-
message: e.message,
|
|
1314
|
-
});
|
|
1315
|
-
this.emit("error", e);
|
|
1316
|
-
}
|
|
1317
|
-
finally {
|
|
1318
|
-
span.end();
|
|
1319
|
-
}
|
|
1211
|
+
});
|
|
1320
1212
|
}
|
|
1321
1213
|
}
|
|
1322
1214
|
|
|
@@ -1355,8 +1247,7 @@ class ChangeFeedFactory {
|
|
|
1355
1247
|
}
|
|
1356
1248
|
}
|
|
1357
1249
|
async create(blobServiceClient, continuationToken, options = {}) {
|
|
1358
|
-
|
|
1359
|
-
try {
|
|
1250
|
+
return tracingClient.withSpan("ChangeFeedFactory-create", options, async (updatedOptions) => {
|
|
1360
1251
|
const containerClient = blobServiceClient.getContainerClient(CHANGE_FEED_CONTAINER_NAME);
|
|
1361
1252
|
let cursor = undefined;
|
|
1362
1253
|
// Create cursor.
|
|
@@ -1430,17 +1321,7 @@ class ChangeFeedFactory {
|
|
|
1430
1321
|
tracingOptions: updatedOptions.tracingOptions,
|
|
1431
1322
|
});
|
|
1432
1323
|
return new ChangeFeed(containerClient, this.segmentFactory, years, segments, currentSegment, lastConsumable, options.start, options.end);
|
|
1433
|
-
}
|
|
1434
|
-
catch (e) {
|
|
1435
|
-
span.setStatus({
|
|
1436
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
1437
|
-
message: e.message,
|
|
1438
|
-
});
|
|
1439
|
-
throw e;
|
|
1440
|
-
}
|
|
1441
|
-
finally {
|
|
1442
|
-
span.end();
|
|
1443
|
-
}
|
|
1324
|
+
});
|
|
1444
1325
|
}
|
|
1445
1326
|
}
|
|
1446
1327
|
|