couchbase 4.7.0 → 4.7.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/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +3 -575
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
- package/deps/couchbase-cxx-client/CMakeLists.txt +3 -1
- package/deps/couchbase-cxx-client/README.md +2 -2
- package/deps/couchbase-cxx-client/core/error_context/base_error_context.hxx +32 -0
- package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +1 -0
- package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +23 -0
- package/deps/couchbase-cxx-client/core/error_context/key_value_error_context.hxx +35 -0
- package/deps/couchbase-cxx-client/core/error_context/subdocument_error_context.hxx +41 -0
- package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +123 -88
- package/deps/couchbase-cxx-client/core/impl/collection.cxx +416 -189
- package/deps/couchbase-cxx-client/core/impl/error.cxx +29 -4
- package/deps/couchbase-cxx-client/core/impl/invoke_with_node_id.hxx +44 -0
- package/deps/couchbase-cxx-client/core/impl/node_id.cxx +110 -0
- package/deps/couchbase-cxx-client/core/impl/node_id.hxx +40 -0
- package/deps/couchbase-cxx-client/core/io/configuration_belongs_to_session.hxx +67 -0
- package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +97 -57
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +7 -16
- package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +14 -4
- package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -4
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +4 -0
- package/deps/couchbase-cxx-client/core/operations/document_query.cxx +12 -12
- package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +11 -11
- package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +11 -11
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +11 -11
- package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +9 -6
- package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +5 -4
- package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +7 -6
- package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +12 -13
- package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +8 -9
- package/deps/couchbase-cxx-client/core/topology/configuration.cxx +21 -0
- package/deps/couchbase-cxx-client/core/topology/configuration.hxx +28 -0
- package/deps/couchbase-cxx-client/core/utils/contains_string.cxx +61 -0
- package/deps/couchbase-cxx-client/core/utils/contains_string.hxx +26 -0
- package/deps/couchbase-cxx-client/couchbase/collection.hxx +73 -0
- package/deps/couchbase-cxx-client/couchbase/error.hxx +16 -0
- package/deps/couchbase-cxx-client/couchbase/node_id.hxx +123 -0
- package/deps/couchbase-cxx-client/couchbase/node_id_for_options.hxx +61 -0
- package/deps/couchbase-cxx-client/couchbase/node_ids_options.hxx +62 -0
- package/deps/couchbase-cxx-client/couchbase/result.hxx +42 -0
- package/dist/binding.d.ts +1 -0
- package/dist/bucket.d.ts +9 -1
- package/dist/bucket.js +21 -0
- package/dist/cluster.d.ts +10 -1
- package/dist/cluster.js +22 -0
- package/dist/collection.d.ts +3 -3
- package/dist/collection.js +161 -123
- package/dist/diagnosticsexecutor.js +2 -2
- package/dist/diagnosticstypes.d.ts +36 -0
- package/dist/diagnosticstypes.js +22 -1
- package/dist/observability.d.ts +5 -1
- package/dist/observability.js +11 -3
- package/dist/observabilityhandler.d.ts +6 -0
- package/dist/observabilityhandler.js +51 -14
- package/dist/observabilitytypes.js +19 -42
- package/dist/observabilityutilities.js +1 -1
- package/dist/oteltracer.d.ts +5 -0
- package/dist/oteltracer.js +7 -0
- package/dist/queryindexmanager.js +15 -0
- package/dist/thresholdlogging.d.ts +5 -0
- package/dist/thresholdlogging.js +7 -0
- package/dist/tracing.d.ts +6 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/waituntilreadyexecutor.d.ts +37 -0
- package/dist/waituntilreadyexecutor.js +156 -0
- package/package.json +8 -8
- package/scripts/prebuilds.js +13 -0
- package/src/binding.cpp +1 -1
package/dist/collection.js
CHANGED
|
@@ -180,12 +180,14 @@ class Collection {
|
|
|
180
180
|
if (!options) {
|
|
181
181
|
options = {};
|
|
182
182
|
}
|
|
183
|
-
const obsReqHandler =
|
|
183
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
184
|
+
? null
|
|
185
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Get, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
184
186
|
try {
|
|
185
187
|
const cppDocId = this._cppDocId(key);
|
|
186
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
188
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
187
189
|
if (options.project || options.withExpiry) {
|
|
188
|
-
options.parentSpan = obsReqHandler.wrappedSpan;
|
|
190
|
+
options.parentSpan = obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.wrappedSpan;
|
|
189
191
|
return this._projectedGet(key, options, obsReqHandler, callback);
|
|
190
192
|
}
|
|
191
193
|
const transcoder = options.transcoder || this.transcoder;
|
|
@@ -198,11 +200,11 @@ class Collection {
|
|
|
198
200
|
opaque: 0,
|
|
199
201
|
}, obsReqHandler);
|
|
200
202
|
if (err) {
|
|
201
|
-
obsReqHandler.endWithError(err);
|
|
203
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
202
204
|
throw err;
|
|
203
205
|
}
|
|
204
206
|
const content = transcoder.decode(resp.value, resp.flags);
|
|
205
|
-
obsReqHandler.end();
|
|
207
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
206
208
|
return new crudoptypes_1.GetResult({
|
|
207
209
|
content: content,
|
|
208
210
|
cas: resp.cas,
|
|
@@ -210,7 +212,7 @@ class Collection {
|
|
|
210
212
|
}, callback);
|
|
211
213
|
}
|
|
212
214
|
catch (e) {
|
|
213
|
-
obsReqHandler.endWithError(e);
|
|
215
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
214
216
|
throw e;
|
|
215
217
|
}
|
|
216
218
|
}
|
|
@@ -255,7 +257,7 @@ class Collection {
|
|
|
255
257
|
});
|
|
256
258
|
}
|
|
257
259
|
catch (e) {
|
|
258
|
-
obsReqHandler.endWithError(e);
|
|
260
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
259
261
|
throw e;
|
|
260
262
|
}
|
|
261
263
|
let content = null;
|
|
@@ -285,7 +287,7 @@ class Collection {
|
|
|
285
287
|
}
|
|
286
288
|
}
|
|
287
289
|
// The parent span is created w/in the get() operation
|
|
288
|
-
obsReqHandler.end();
|
|
290
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
289
291
|
return new crudoptypes_1.GetResult({
|
|
290
292
|
content: content,
|
|
291
293
|
cas: res.cas,
|
|
@@ -308,11 +310,13 @@ class Collection {
|
|
|
308
310
|
if (!options) {
|
|
309
311
|
options = {};
|
|
310
312
|
}
|
|
311
|
-
const obsReqHandler =
|
|
313
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
314
|
+
? null
|
|
315
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Exists, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
312
316
|
try {
|
|
313
317
|
const cppDocId = this._cppDocId(key);
|
|
314
318
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
315
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
319
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
316
320
|
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
317
321
|
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.exists.bind(this._conn), {
|
|
318
322
|
id: cppDocId,
|
|
@@ -321,10 +325,10 @@ class Collection {
|
|
|
321
325
|
timeout,
|
|
322
326
|
}, obsReqHandler);
|
|
323
327
|
if (err) {
|
|
324
|
-
obsReqHandler.endWithError(err);
|
|
328
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
325
329
|
throw err;
|
|
326
330
|
}
|
|
327
|
-
obsReqHandler.end();
|
|
331
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
328
332
|
if (resp.deleted) {
|
|
329
333
|
return new crudoptypes_1.ExistsResult({
|
|
330
334
|
cas: undefined,
|
|
@@ -338,20 +342,20 @@ class Collection {
|
|
|
338
342
|
}, callback);
|
|
339
343
|
}
|
|
340
344
|
catch (e) {
|
|
341
|
-
obsReqHandler.endWithError(e);
|
|
345
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
342
346
|
throw e;
|
|
343
347
|
}
|
|
344
348
|
}
|
|
345
349
|
/**
|
|
346
350
|
* @internal
|
|
347
351
|
*/
|
|
348
|
-
_getReplica(key, obsReqHandler, options, callback) {
|
|
352
|
+
_getReplica(key, opType, obsReqHandler, options, callback) {
|
|
349
353
|
const cppDocId = this._cppDocId(key);
|
|
350
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
354
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
351
355
|
const emitter = new streamablepromises_1.StreamableReplicasPromise((replicas) => replicas);
|
|
352
356
|
const transcoder = options.transcoder || this.transcoder;
|
|
353
357
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
354
|
-
if (
|
|
358
|
+
if (opType == observabilitytypes_1.KeyValueOp.GetAllReplicas) {
|
|
355
359
|
utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
356
360
|
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.getAllReplicas.bind(this._conn), {
|
|
357
361
|
id: cppDocId,
|
|
@@ -359,7 +363,7 @@ class Collection {
|
|
|
359
363
|
read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
|
|
360
364
|
}, obsReqHandler);
|
|
361
365
|
if (err) {
|
|
362
|
-
obsReqHandler.endWithError(err);
|
|
366
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
363
367
|
emitter.emit('error', err);
|
|
364
368
|
emitter.emit('end');
|
|
365
369
|
return;
|
|
@@ -374,13 +378,13 @@ class Collection {
|
|
|
374
378
|
}));
|
|
375
379
|
}
|
|
376
380
|
catch (err) {
|
|
377
|
-
obsReqHandler.endWithError(err);
|
|
381
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
378
382
|
emitter.emit('error', err);
|
|
379
383
|
emitter.emit('end');
|
|
380
384
|
return;
|
|
381
385
|
}
|
|
382
386
|
});
|
|
383
|
-
obsReqHandler.end();
|
|
387
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
384
388
|
emitter.emit('end');
|
|
385
389
|
});
|
|
386
390
|
}
|
|
@@ -392,7 +396,7 @@ class Collection {
|
|
|
392
396
|
read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
|
|
393
397
|
}, obsReqHandler);
|
|
394
398
|
if (err) {
|
|
395
|
-
obsReqHandler.endWithError(err);
|
|
399
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
396
400
|
emitter.emit('error', err);
|
|
397
401
|
emitter.emit('end');
|
|
398
402
|
return;
|
|
@@ -406,10 +410,10 @@ class Collection {
|
|
|
406
410
|
}));
|
|
407
411
|
}
|
|
408
412
|
catch (err) {
|
|
409
|
-
obsReqHandler.endWithError(err);
|
|
413
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
410
414
|
emitter.emit('error', err);
|
|
411
415
|
}
|
|
412
|
-
obsReqHandler.end();
|
|
416
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
413
417
|
emitter.emit('end');
|
|
414
418
|
});
|
|
415
419
|
}
|
|
@@ -431,15 +435,17 @@ class Collection {
|
|
|
431
435
|
if (!options) {
|
|
432
436
|
options = {};
|
|
433
437
|
}
|
|
434
|
-
const obsReqHandler =
|
|
438
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
439
|
+
? null
|
|
440
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.GetAnyReplica, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
435
441
|
try {
|
|
436
442
|
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
437
|
-
const replicas = await this._getReplica(key, obsReqHandler, options);
|
|
443
|
+
const replicas = await this._getReplica(key, observabilitytypes_1.KeyValueOp.GetAnyReplica, obsReqHandler, options);
|
|
438
444
|
return replicas[0];
|
|
439
445
|
}, callback);
|
|
440
446
|
}
|
|
441
447
|
catch (e) {
|
|
442
|
-
obsReqHandler.endWithError(e);
|
|
448
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
443
449
|
throw e;
|
|
444
450
|
}
|
|
445
451
|
}
|
|
@@ -459,12 +465,14 @@ class Collection {
|
|
|
459
465
|
if (!options) {
|
|
460
466
|
options = {};
|
|
461
467
|
}
|
|
462
|
-
const obsReqHandler =
|
|
468
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
469
|
+
? null
|
|
470
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.GetAllReplicas, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
463
471
|
try {
|
|
464
|
-
return this._getReplica(key, obsReqHandler, options, callback);
|
|
472
|
+
return this._getReplica(key, observabilitytypes_1.KeyValueOp.GetAllReplicas, obsReqHandler, options, callback);
|
|
465
473
|
}
|
|
466
474
|
catch (e) {
|
|
467
|
-
obsReqHandler.endWithError(e);
|
|
475
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
468
476
|
throw e;
|
|
469
477
|
}
|
|
470
478
|
}
|
|
@@ -477,6 +485,7 @@ class Collection {
|
|
|
477
485
|
* @param callback A node-style callback to be invoked after execution.
|
|
478
486
|
*/
|
|
479
487
|
insert(key, value, options, callback) {
|
|
488
|
+
var _a;
|
|
480
489
|
if (options instanceof Function) {
|
|
481
490
|
callback = arguments[2];
|
|
482
491
|
options = undefined;
|
|
@@ -484,7 +493,9 @@ class Collection {
|
|
|
484
493
|
if (!options) {
|
|
485
494
|
options = {};
|
|
486
495
|
}
|
|
487
|
-
const obsReqHandler =
|
|
496
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
497
|
+
? null
|
|
498
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Insert, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
488
499
|
try {
|
|
489
500
|
const cppDocId = this._cppDocId(key);
|
|
490
501
|
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
@@ -493,10 +504,8 @@ class Collection {
|
|
|
493
504
|
const persistTo = options.durabilityPersistTo;
|
|
494
505
|
const replicateTo = options.durabilityReplicateTo;
|
|
495
506
|
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
496
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
497
|
-
const [bytesBuf, flags] = obsReqHandler.maybeCreateEncodingSpan(() =>
|
|
498
|
-
return transcoder.encode(value);
|
|
499
|
-
});
|
|
507
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
508
|
+
const [bytesBuf, flags] = (_a = obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.maybeCreateEncodingSpan(() => transcoder.encode(value))) !== null && _a !== void 0 ? _a : transcoder.encode(value);
|
|
500
509
|
const insertReq = {
|
|
501
510
|
id: cppDocId,
|
|
502
511
|
value: bytesBuf,
|
|
@@ -525,10 +534,10 @@ class Collection {
|
|
|
525
534
|
}, obsReqHandler);
|
|
526
535
|
}
|
|
527
536
|
if (err) {
|
|
528
|
-
obsReqHandler.endWithError(err);
|
|
537
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
529
538
|
throw err;
|
|
530
539
|
}
|
|
531
|
-
obsReqHandler.end();
|
|
540
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
532
541
|
return new crudoptypes_1.MutationResult({
|
|
533
542
|
cas: resp.cas,
|
|
534
543
|
token: resp.token,
|
|
@@ -536,7 +545,7 @@ class Collection {
|
|
|
536
545
|
}, callback);
|
|
537
546
|
}
|
|
538
547
|
catch (e) {
|
|
539
|
-
obsReqHandler.endWithError(e);
|
|
548
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
540
549
|
throw e;
|
|
541
550
|
}
|
|
542
551
|
}
|
|
@@ -550,6 +559,7 @@ class Collection {
|
|
|
550
559
|
* @param callback A node-style callback to be invoked after execution.
|
|
551
560
|
*/
|
|
552
561
|
upsert(key, value, options, callback) {
|
|
562
|
+
var _a;
|
|
553
563
|
if (options instanceof Function) {
|
|
554
564
|
callback = arguments[2];
|
|
555
565
|
options = undefined;
|
|
@@ -557,7 +567,9 @@ class Collection {
|
|
|
557
567
|
if (!options) {
|
|
558
568
|
options = {};
|
|
559
569
|
}
|
|
560
|
-
const obsReqHandler =
|
|
570
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
571
|
+
? null
|
|
572
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Upsert, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
561
573
|
try {
|
|
562
574
|
const cppDocId = this._cppDocId(key);
|
|
563
575
|
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
@@ -567,10 +579,8 @@ class Collection {
|
|
|
567
579
|
const persistTo = options.durabilityPersistTo;
|
|
568
580
|
const replicateTo = options.durabilityReplicateTo;
|
|
569
581
|
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
570
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
571
|
-
const [bytesBuf, flags] = obsReqHandler.maybeCreateEncodingSpan(() =>
|
|
572
|
-
return transcoder.encode(value);
|
|
573
|
-
});
|
|
582
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
583
|
+
const [bytesBuf, flags] = (_a = obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.maybeCreateEncodingSpan(() => transcoder.encode(value))) !== null && _a !== void 0 ? _a : transcoder.encode(value);
|
|
574
584
|
const upsertReq = {
|
|
575
585
|
id: cppDocId,
|
|
576
586
|
value: bytesBuf,
|
|
@@ -600,10 +610,10 @@ class Collection {
|
|
|
600
610
|
}, obsReqHandler);
|
|
601
611
|
}
|
|
602
612
|
if (err) {
|
|
603
|
-
obsReqHandler.endWithError(err);
|
|
613
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
604
614
|
throw err;
|
|
605
615
|
}
|
|
606
|
-
obsReqHandler.end();
|
|
616
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
607
617
|
return new crudoptypes_1.MutationResult({
|
|
608
618
|
cas: resp.cas,
|
|
609
619
|
token: resp.token,
|
|
@@ -611,7 +621,7 @@ class Collection {
|
|
|
611
621
|
}, callback);
|
|
612
622
|
}
|
|
613
623
|
catch (e) {
|
|
614
|
-
obsReqHandler.endWithError(e);
|
|
624
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
615
625
|
throw e;
|
|
616
626
|
}
|
|
617
627
|
}
|
|
@@ -624,6 +634,7 @@ class Collection {
|
|
|
624
634
|
* @param callback A node-style callback to be invoked after execution.
|
|
625
635
|
*/
|
|
626
636
|
replace(key, value, options, callback) {
|
|
637
|
+
var _a;
|
|
627
638
|
if (options instanceof Function) {
|
|
628
639
|
callback = arguments[2];
|
|
629
640
|
options = undefined;
|
|
@@ -631,7 +642,9 @@ class Collection {
|
|
|
631
642
|
if (!options) {
|
|
632
643
|
options = {};
|
|
633
644
|
}
|
|
634
|
-
const obsReqHandler =
|
|
645
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
646
|
+
? null
|
|
647
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Replace, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
635
648
|
try {
|
|
636
649
|
const cppDocId = this._cppDocId(key);
|
|
637
650
|
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
@@ -642,10 +655,8 @@ class Collection {
|
|
|
642
655
|
const persistTo = options.durabilityPersistTo;
|
|
643
656
|
const replicateTo = options.durabilityReplicateTo;
|
|
644
657
|
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
645
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
646
|
-
const [bytesBuf, flags] = obsReqHandler.maybeCreateEncodingSpan(() =>
|
|
647
|
-
return transcoder.encode(value);
|
|
648
|
-
});
|
|
658
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
659
|
+
const [bytesBuf, flags] = (_a = obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.maybeCreateEncodingSpan(() => transcoder.encode(value))) !== null && _a !== void 0 ? _a : transcoder.encode(value);
|
|
649
660
|
const replaceReq = {
|
|
650
661
|
id: cppDocId,
|
|
651
662
|
value: bytesBuf,
|
|
@@ -676,10 +687,10 @@ class Collection {
|
|
|
676
687
|
}, obsReqHandler);
|
|
677
688
|
}
|
|
678
689
|
if (err) {
|
|
679
|
-
obsReqHandler.endWithError(err);
|
|
690
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
680
691
|
throw err;
|
|
681
692
|
}
|
|
682
|
-
obsReqHandler.end();
|
|
693
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
683
694
|
return new crudoptypes_1.MutationResult({
|
|
684
695
|
cas: resp.cas,
|
|
685
696
|
token: resp.token,
|
|
@@ -687,7 +698,7 @@ class Collection {
|
|
|
687
698
|
}, callback);
|
|
688
699
|
}
|
|
689
700
|
catch (e) {
|
|
690
|
-
obsReqHandler.endWithError(e);
|
|
701
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
691
702
|
throw e;
|
|
692
703
|
}
|
|
693
704
|
}
|
|
@@ -706,7 +717,9 @@ class Collection {
|
|
|
706
717
|
if (!options) {
|
|
707
718
|
options = {};
|
|
708
719
|
}
|
|
709
|
-
const obsReqHandler =
|
|
720
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
721
|
+
? null
|
|
722
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Remove, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
710
723
|
try {
|
|
711
724
|
const cppDocId = this._cppDocId(key);
|
|
712
725
|
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
@@ -714,7 +727,7 @@ class Collection {
|
|
|
714
727
|
const persistTo = options.durabilityPersistTo;
|
|
715
728
|
const replicateTo = options.durabilityReplicateTo;
|
|
716
729
|
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
717
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
730
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
718
731
|
const removeReq = {
|
|
719
732
|
id: cppDocId,
|
|
720
733
|
cas: cas || binding_1.zeroCas,
|
|
@@ -741,10 +754,10 @@ class Collection {
|
|
|
741
754
|
}, obsReqHandler);
|
|
742
755
|
}
|
|
743
756
|
if (err) {
|
|
744
|
-
obsReqHandler.endWithError(err);
|
|
757
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
745
758
|
throw err;
|
|
746
759
|
}
|
|
747
|
-
obsReqHandler.end();
|
|
760
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
748
761
|
return new crudoptypes_1.MutationResult({
|
|
749
762
|
cas: resp.cas,
|
|
750
763
|
token: resp.token,
|
|
@@ -752,7 +765,7 @@ class Collection {
|
|
|
752
765
|
}, callback);
|
|
753
766
|
}
|
|
754
767
|
catch (e) {
|
|
755
|
-
obsReqHandler.endWithError(e);
|
|
768
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
756
769
|
throw e;
|
|
757
770
|
}
|
|
758
771
|
}
|
|
@@ -778,12 +791,14 @@ class Collection {
|
|
|
778
791
|
if (!options) {
|
|
779
792
|
options = {};
|
|
780
793
|
}
|
|
781
|
-
const obsReqHandler =
|
|
794
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
795
|
+
? null
|
|
796
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.GetAndTouch, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
782
797
|
try {
|
|
783
798
|
const cppDocId = this._cppDocId(key);
|
|
784
799
|
const transcoder = options.transcoder || this.transcoder;
|
|
785
800
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
786
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
801
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
787
802
|
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
788
803
|
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.getAndTouch.bind(this._conn), {
|
|
789
804
|
id: cppDocId,
|
|
@@ -793,11 +808,11 @@ class Collection {
|
|
|
793
808
|
opaque: 0,
|
|
794
809
|
}, obsReqHandler);
|
|
795
810
|
if (err) {
|
|
796
|
-
obsReqHandler.endWithError(err);
|
|
811
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
797
812
|
throw err;
|
|
798
813
|
}
|
|
799
814
|
const content = transcoder.decode(resp.value, resp.flags);
|
|
800
|
-
obsReqHandler.end();
|
|
815
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
801
816
|
return new crudoptypes_1.GetResult({
|
|
802
817
|
content: content,
|
|
803
818
|
cas: resp.cas,
|
|
@@ -805,7 +820,7 @@ class Collection {
|
|
|
805
820
|
}, callback);
|
|
806
821
|
}
|
|
807
822
|
catch (e) {
|
|
808
|
-
obsReqHandler.endWithError(e);
|
|
823
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
809
824
|
throw e;
|
|
810
825
|
}
|
|
811
826
|
}
|
|
@@ -830,11 +845,13 @@ class Collection {
|
|
|
830
845
|
if (!options) {
|
|
831
846
|
options = {};
|
|
832
847
|
}
|
|
833
|
-
const obsReqHandler =
|
|
848
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
849
|
+
? null
|
|
850
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Touch, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
834
851
|
try {
|
|
835
852
|
const cppDocId = this._cppDocId(key);
|
|
836
853
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
837
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
854
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
838
855
|
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
839
856
|
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.touch.bind(this._conn), {
|
|
840
857
|
id: cppDocId,
|
|
@@ -844,17 +861,17 @@ class Collection {
|
|
|
844
861
|
opaque: 0,
|
|
845
862
|
}, obsReqHandler);
|
|
846
863
|
if (err) {
|
|
847
|
-
obsReqHandler.endWithError(err);
|
|
864
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
848
865
|
throw err;
|
|
849
866
|
}
|
|
850
|
-
obsReqHandler.end();
|
|
867
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
851
868
|
return new crudoptypes_1.MutationResult({
|
|
852
869
|
cas: resp.cas,
|
|
853
870
|
});
|
|
854
871
|
}, callback);
|
|
855
872
|
}
|
|
856
873
|
catch (e) {
|
|
857
|
-
obsReqHandler.endWithError(e);
|
|
874
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
858
875
|
throw e;
|
|
859
876
|
}
|
|
860
877
|
}
|
|
@@ -874,12 +891,14 @@ class Collection {
|
|
|
874
891
|
if (!options) {
|
|
875
892
|
options = {};
|
|
876
893
|
}
|
|
877
|
-
const obsReqHandler =
|
|
894
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
895
|
+
? null
|
|
896
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.GetAndLock, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
878
897
|
try {
|
|
879
898
|
const cppDocId = this._cppDocId(key);
|
|
880
899
|
const transcoder = options.transcoder || this.transcoder;
|
|
881
900
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
882
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
901
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
883
902
|
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
884
903
|
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.getAndLock.bind(this._conn), {
|
|
885
904
|
id: cppDocId,
|
|
@@ -889,11 +908,11 @@ class Collection {
|
|
|
889
908
|
opaque: 0,
|
|
890
909
|
}, obsReqHandler);
|
|
891
910
|
if (err) {
|
|
892
|
-
obsReqHandler.endWithError(err);
|
|
911
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
893
912
|
throw err;
|
|
894
913
|
}
|
|
895
914
|
const content = transcoder.decode(resp.value, resp.flags);
|
|
896
|
-
obsReqHandler.end();
|
|
915
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
897
916
|
return new crudoptypes_1.GetResult({
|
|
898
917
|
content: content,
|
|
899
918
|
cas: resp.cas,
|
|
@@ -901,7 +920,7 @@ class Collection {
|
|
|
901
920
|
}, callback);
|
|
902
921
|
}
|
|
903
922
|
catch (e) {
|
|
904
|
-
obsReqHandler.endWithError(e);
|
|
923
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
905
924
|
throw e;
|
|
906
925
|
}
|
|
907
926
|
}
|
|
@@ -921,11 +940,13 @@ class Collection {
|
|
|
921
940
|
if (!options) {
|
|
922
941
|
options = {};
|
|
923
942
|
}
|
|
924
|
-
const obsReqHandler =
|
|
943
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
944
|
+
? null
|
|
945
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Unlock, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
925
946
|
try {
|
|
926
947
|
const cppDocId = this._cppDocId(key);
|
|
927
948
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
928
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
949
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
929
950
|
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
930
951
|
const [err, _] = await (0, observability_1.wrapObservableBindingCall)(this._conn.unlock.bind(this._conn), {
|
|
931
952
|
id: cppDocId,
|
|
@@ -935,14 +956,14 @@ class Collection {
|
|
|
935
956
|
opaque: 0,
|
|
936
957
|
}, obsReqHandler);
|
|
937
958
|
if (err) {
|
|
938
|
-
obsReqHandler.endWithError(err);
|
|
959
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
939
960
|
throw err;
|
|
940
961
|
}
|
|
941
|
-
obsReqHandler.end();
|
|
962
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
942
963
|
}, callback);
|
|
943
964
|
}
|
|
944
965
|
catch (e) {
|
|
945
|
-
obsReqHandler.endWithError(e);
|
|
966
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
946
967
|
throw e;
|
|
947
968
|
}
|
|
948
969
|
}
|
|
@@ -1067,7 +1088,9 @@ class Collection {
|
|
|
1067
1088
|
if (!options) {
|
|
1068
1089
|
options = {};
|
|
1069
1090
|
}
|
|
1070
|
-
const obsReqHandler =
|
|
1091
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
1092
|
+
? null
|
|
1093
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.LookupIn, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1071
1094
|
try {
|
|
1072
1095
|
if (specs.length === 0) {
|
|
1073
1096
|
throw new errors_1.InvalidArgumentError(new Error('At least one lookup spec must be provided.'));
|
|
@@ -1084,7 +1107,7 @@ class Collection {
|
|
|
1084
1107
|
}
|
|
1085
1108
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1086
1109
|
const accessDeleted = options.accessDeleted || false;
|
|
1087
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
1110
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
1088
1111
|
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1089
1112
|
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.lookupIn.bind(this._conn), {
|
|
1090
1113
|
id: cppDocId,
|
|
@@ -1095,7 +1118,7 @@ class Collection {
|
|
|
1095
1118
|
access_deleted: accessDeleted,
|
|
1096
1119
|
}, obsReqHandler);
|
|
1097
1120
|
if (err) {
|
|
1098
|
-
obsReqHandler.endWithError(err);
|
|
1121
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
1099
1122
|
throw err;
|
|
1100
1123
|
}
|
|
1101
1124
|
const content = [];
|
|
@@ -1114,7 +1137,7 @@ class Collection {
|
|
|
1114
1137
|
value,
|
|
1115
1138
|
}));
|
|
1116
1139
|
}
|
|
1117
|
-
obsReqHandler.end();
|
|
1140
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
1118
1141
|
return new crudoptypes_1.LookupInResult({
|
|
1119
1142
|
content: content,
|
|
1120
1143
|
cas: resp.cas,
|
|
@@ -1122,19 +1145,19 @@ class Collection {
|
|
|
1122
1145
|
}, callback);
|
|
1123
1146
|
}
|
|
1124
1147
|
catch (e) {
|
|
1125
|
-
obsReqHandler.endWithError(e);
|
|
1148
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
1126
1149
|
throw e;
|
|
1127
1150
|
}
|
|
1128
1151
|
}
|
|
1129
1152
|
/**
|
|
1130
1153
|
* @internal
|
|
1131
1154
|
*/
|
|
1132
|
-
_lookupInReplica(key, obsReqHandler, specs, options, callback) {
|
|
1155
|
+
_lookupInReplica(key, opType, obsReqHandler, specs, options, callback) {
|
|
1133
1156
|
if (specs.length === 0) {
|
|
1134
1157
|
throw new errors_1.InvalidArgumentError(new Error('At least one lookup spec must be provided.'));
|
|
1135
1158
|
}
|
|
1136
1159
|
const cppDocId = this._cppDocId(key);
|
|
1137
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
1160
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
1138
1161
|
const emitter = new streamablepromises_1.StreamableReplicasPromise((replicas) => replicas);
|
|
1139
1162
|
const cppSpecs = [];
|
|
1140
1163
|
for (let i = 0; i < specs.length; ++i) {
|
|
@@ -1146,7 +1169,7 @@ class Collection {
|
|
|
1146
1169
|
});
|
|
1147
1170
|
}
|
|
1148
1171
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1149
|
-
if (
|
|
1172
|
+
if (opType == observabilitytypes_1.KeyValueOp.LookupInAllReplicas) {
|
|
1150
1173
|
utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1151
1174
|
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.lookupInAllReplicas.bind(this._conn), {
|
|
1152
1175
|
id: cppDocId,
|
|
@@ -1156,7 +1179,7 @@ class Collection {
|
|
|
1156
1179
|
access_deleted: false, // only used in core transactions; false otherwise
|
|
1157
1180
|
}, obsReqHandler);
|
|
1158
1181
|
if (err) {
|
|
1159
|
-
obsReqHandler.endWithError(err);
|
|
1182
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
1160
1183
|
emitter.emit('error', err);
|
|
1161
1184
|
emitter.emit('end');
|
|
1162
1185
|
return;
|
|
@@ -1184,7 +1207,7 @@ class Collection {
|
|
|
1184
1207
|
isReplica: replica.is_replica,
|
|
1185
1208
|
}));
|
|
1186
1209
|
});
|
|
1187
|
-
obsReqHandler.end();
|
|
1210
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
1188
1211
|
emitter.emit('end');
|
|
1189
1212
|
});
|
|
1190
1213
|
}
|
|
@@ -1198,7 +1221,7 @@ class Collection {
|
|
|
1198
1221
|
access_deleted: false, // only used in core transactions; false otherwise
|
|
1199
1222
|
}, obsReqHandler);
|
|
1200
1223
|
if (err) {
|
|
1201
|
-
obsReqHandler.endWithError(err);
|
|
1224
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
1202
1225
|
emitter.emit('error', err);
|
|
1203
1226
|
emitter.emit('end');
|
|
1204
1227
|
return;
|
|
@@ -1224,7 +1247,7 @@ class Collection {
|
|
|
1224
1247
|
cas: resp.cas,
|
|
1225
1248
|
isReplica: resp.is_replica,
|
|
1226
1249
|
}));
|
|
1227
|
-
obsReqHandler.end();
|
|
1250
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
1228
1251
|
emitter.emit('end');
|
|
1229
1252
|
});
|
|
1230
1253
|
}
|
|
@@ -1248,15 +1271,17 @@ class Collection {
|
|
|
1248
1271
|
if (!options) {
|
|
1249
1272
|
options = {};
|
|
1250
1273
|
}
|
|
1251
|
-
const obsReqHandler =
|
|
1274
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
1275
|
+
? null
|
|
1276
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.LookupInAnyReplica, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1252
1277
|
try {
|
|
1253
1278
|
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1254
|
-
const replicas = await this._lookupInReplica(key, obsReqHandler, specs, options);
|
|
1279
|
+
const replicas = await this._lookupInReplica(key, observabilitytypes_1.KeyValueOp.LookupInAnyReplica, obsReqHandler, specs, options);
|
|
1255
1280
|
return replicas[0];
|
|
1256
1281
|
}, callback);
|
|
1257
1282
|
}
|
|
1258
1283
|
catch (e) {
|
|
1259
|
-
obsReqHandler.endWithError(e);
|
|
1284
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
1260
1285
|
throw e;
|
|
1261
1286
|
}
|
|
1262
1287
|
}
|
|
@@ -1278,12 +1303,14 @@ class Collection {
|
|
|
1278
1303
|
if (!options) {
|
|
1279
1304
|
options = {};
|
|
1280
1305
|
}
|
|
1281
|
-
const obsReqHandler =
|
|
1306
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
1307
|
+
? null
|
|
1308
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.LookupInAllReplicas, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1282
1309
|
try {
|
|
1283
|
-
return this._lookupInReplica(key, obsReqHandler, specs, options, callback);
|
|
1310
|
+
return this._lookupInReplica(key, observabilitytypes_1.KeyValueOp.LookupInAllReplicas, obsReqHandler, specs, options, callback);
|
|
1284
1311
|
}
|
|
1285
1312
|
catch (e) {
|
|
1286
|
-
obsReqHandler.endWithError(e);
|
|
1313
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
1287
1314
|
throw e;
|
|
1288
1315
|
}
|
|
1289
1316
|
}
|
|
@@ -1297,6 +1324,7 @@ class Collection {
|
|
|
1297
1324
|
* @param callback A node-style callback to be invoked after execution.
|
|
1298
1325
|
*/
|
|
1299
1326
|
mutateIn(key, specs, options, callback) {
|
|
1327
|
+
var _a;
|
|
1300
1328
|
if (options instanceof Function) {
|
|
1301
1329
|
callback = arguments[2];
|
|
1302
1330
|
options = undefined;
|
|
@@ -1304,7 +1332,9 @@ class Collection {
|
|
|
1304
1332
|
if (!options) {
|
|
1305
1333
|
options = {};
|
|
1306
1334
|
}
|
|
1307
|
-
const obsReqHandler =
|
|
1335
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
1336
|
+
? null
|
|
1337
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.MutateIn, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1308
1338
|
try {
|
|
1309
1339
|
if (specs.length === 0) {
|
|
1310
1340
|
throw new errors_1.InvalidArgumentError(new Error('At least one lookup spec must be provided.'));
|
|
@@ -1315,10 +1345,10 @@ class Collection {
|
|
|
1315
1345
|
for (let i = 0; i < specs.length; ++i) {
|
|
1316
1346
|
let value = undefined;
|
|
1317
1347
|
if (specs[i]._data) {
|
|
1318
|
-
const [bytesValue
|
|
1348
|
+
const [bytesValue] = (_a = obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.maybeAddEncodingSpan(() => {
|
|
1319
1349
|
const encoded = this._subdocEncode(specs[i]._data);
|
|
1320
|
-
return [encoded, 0];
|
|
1321
|
-
});
|
|
1350
|
+
return [encoded, 0];
|
|
1351
|
+
})) !== null && _a !== void 0 ? _a : [this._subdocEncode(specs[i]._data), 0];
|
|
1322
1352
|
value = bytesValue;
|
|
1323
1353
|
}
|
|
1324
1354
|
cppSpecs.push({
|
|
@@ -1338,7 +1368,7 @@ class Collection {
|
|
|
1338
1368
|
const persistTo = options.durabilityPersistTo;
|
|
1339
1369
|
const replicateTo = options.durabilityReplicateTo;
|
|
1340
1370
|
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
1341
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1371
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1342
1372
|
const mutateInReq = {
|
|
1343
1373
|
id: cppDocId,
|
|
1344
1374
|
store_semantics: (0, bindingutilities_1.storeSemanticToCpp)(storeSemantics),
|
|
@@ -1371,7 +1401,7 @@ class Collection {
|
|
|
1371
1401
|
}, obsReqHandler);
|
|
1372
1402
|
}
|
|
1373
1403
|
if (err) {
|
|
1374
|
-
obsReqHandler.endWithError(err);
|
|
1404
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
1375
1405
|
throw err;
|
|
1376
1406
|
}
|
|
1377
1407
|
const content = [];
|
|
@@ -1385,7 +1415,7 @@ class Collection {
|
|
|
1385
1415
|
value,
|
|
1386
1416
|
}));
|
|
1387
1417
|
}
|
|
1388
|
-
obsReqHandler.end();
|
|
1418
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
1389
1419
|
return new crudoptypes_1.MutateInResult({
|
|
1390
1420
|
content: content,
|
|
1391
1421
|
cas: resp.cas,
|
|
@@ -1394,7 +1424,7 @@ class Collection {
|
|
|
1394
1424
|
}, callback);
|
|
1395
1425
|
}
|
|
1396
1426
|
catch (e) {
|
|
1397
|
-
obsReqHandler.endWithError(e);
|
|
1427
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
1398
1428
|
throw e;
|
|
1399
1429
|
}
|
|
1400
1430
|
}
|
|
@@ -1448,7 +1478,9 @@ class Collection {
|
|
|
1448
1478
|
if (!options) {
|
|
1449
1479
|
options = {};
|
|
1450
1480
|
}
|
|
1451
|
-
const obsReqHandler =
|
|
1481
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
1482
|
+
? null
|
|
1483
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Increment, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1452
1484
|
try {
|
|
1453
1485
|
const cppDocId = this._cppDocId(key);
|
|
1454
1486
|
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
@@ -1457,7 +1489,7 @@ class Collection {
|
|
|
1457
1489
|
const persistTo = options.durabilityPersistTo;
|
|
1458
1490
|
const replicateTo = options.durabilityReplicateTo;
|
|
1459
1491
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1460
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1492
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1461
1493
|
const incrementReq = {
|
|
1462
1494
|
id: cppDocId,
|
|
1463
1495
|
delta,
|
|
@@ -1486,10 +1518,10 @@ class Collection {
|
|
|
1486
1518
|
}, obsReqHandler);
|
|
1487
1519
|
}
|
|
1488
1520
|
if (err) {
|
|
1489
|
-
obsReqHandler.endWithError(err);
|
|
1521
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
1490
1522
|
throw err;
|
|
1491
1523
|
}
|
|
1492
|
-
obsReqHandler.end();
|
|
1524
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
1493
1525
|
return new crudoptypes_1.CounterResult({
|
|
1494
1526
|
cas: resp.cas,
|
|
1495
1527
|
token: resp.token,
|
|
@@ -1498,7 +1530,7 @@ class Collection {
|
|
|
1498
1530
|
}, callback);
|
|
1499
1531
|
}
|
|
1500
1532
|
catch (e) {
|
|
1501
|
-
obsReqHandler.endWithError(e);
|
|
1533
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
1502
1534
|
throw e;
|
|
1503
1535
|
}
|
|
1504
1536
|
}
|
|
@@ -1513,7 +1545,9 @@ class Collection {
|
|
|
1513
1545
|
if (!options) {
|
|
1514
1546
|
options = {};
|
|
1515
1547
|
}
|
|
1516
|
-
const obsReqHandler =
|
|
1548
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
1549
|
+
? null
|
|
1550
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Decrement, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1517
1551
|
try {
|
|
1518
1552
|
const cppDocId = this._cppDocId(key);
|
|
1519
1553
|
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
@@ -1522,7 +1556,7 @@ class Collection {
|
|
|
1522
1556
|
const persistTo = options.durabilityPersistTo;
|
|
1523
1557
|
const replicateTo = options.durabilityReplicateTo;
|
|
1524
1558
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1525
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1559
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1526
1560
|
const decrementReq = {
|
|
1527
1561
|
id: cppDocId,
|
|
1528
1562
|
delta,
|
|
@@ -1551,10 +1585,10 @@ class Collection {
|
|
|
1551
1585
|
}, obsReqHandler);
|
|
1552
1586
|
}
|
|
1553
1587
|
if (err) {
|
|
1554
|
-
obsReqHandler.endWithError(err);
|
|
1588
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
1555
1589
|
throw err;
|
|
1556
1590
|
}
|
|
1557
|
-
obsReqHandler.end();
|
|
1591
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
1558
1592
|
return new crudoptypes_1.CounterResult({
|
|
1559
1593
|
cas: resp.cas,
|
|
1560
1594
|
token: resp.token,
|
|
@@ -1563,7 +1597,7 @@ class Collection {
|
|
|
1563
1597
|
}, callback);
|
|
1564
1598
|
}
|
|
1565
1599
|
catch (e) {
|
|
1566
|
-
obsReqHandler.endWithError(e);
|
|
1600
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
1567
1601
|
throw e;
|
|
1568
1602
|
}
|
|
1569
1603
|
}
|
|
@@ -1578,7 +1612,9 @@ class Collection {
|
|
|
1578
1612
|
if (!options) {
|
|
1579
1613
|
options = {};
|
|
1580
1614
|
}
|
|
1581
|
-
const obsReqHandler =
|
|
1615
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
1616
|
+
? null
|
|
1617
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Append, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1582
1618
|
try {
|
|
1583
1619
|
const cppDocId = this._cppDocId(key);
|
|
1584
1620
|
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
@@ -1586,7 +1622,7 @@ class Collection {
|
|
|
1586
1622
|
const replicateTo = options.durabilityReplicateTo;
|
|
1587
1623
|
const cas = options.cas;
|
|
1588
1624
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1589
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1625
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1590
1626
|
if (!Buffer.isBuffer(value)) {
|
|
1591
1627
|
value = Buffer.from(value);
|
|
1592
1628
|
}
|
|
@@ -1617,10 +1653,10 @@ class Collection {
|
|
|
1617
1653
|
}, obsReqHandler);
|
|
1618
1654
|
}
|
|
1619
1655
|
if (err) {
|
|
1620
|
-
obsReqHandler.endWithError(err);
|
|
1656
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
1621
1657
|
throw err;
|
|
1622
1658
|
}
|
|
1623
|
-
obsReqHandler.end();
|
|
1659
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
1624
1660
|
return new crudoptypes_1.MutationResult({
|
|
1625
1661
|
cas: resp.cas,
|
|
1626
1662
|
token: resp.token,
|
|
@@ -1628,7 +1664,7 @@ class Collection {
|
|
|
1628
1664
|
}, callback);
|
|
1629
1665
|
}
|
|
1630
1666
|
catch (e) {
|
|
1631
|
-
obsReqHandler.endWithError(e);
|
|
1667
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
1632
1668
|
throw e;
|
|
1633
1669
|
}
|
|
1634
1670
|
}
|
|
@@ -1643,7 +1679,9 @@ class Collection {
|
|
|
1643
1679
|
if (!options) {
|
|
1644
1680
|
options = {};
|
|
1645
1681
|
}
|
|
1646
|
-
const obsReqHandler =
|
|
1682
|
+
const obsReqHandler = (0, observabilityhandler_1.isNoopObservabilityInstruments)(this.observabilityInstruments)
|
|
1683
|
+
? null
|
|
1684
|
+
: new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Prepend, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1647
1685
|
try {
|
|
1648
1686
|
const cppDocId = this._cppDocId(key);
|
|
1649
1687
|
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
@@ -1651,7 +1689,7 @@ class Collection {
|
|
|
1651
1689
|
const replicateTo = options.durabilityReplicateTo;
|
|
1652
1690
|
const cas = options.cas;
|
|
1653
1691
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1654
|
-
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1692
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1655
1693
|
if (!Buffer.isBuffer(value)) {
|
|
1656
1694
|
value = Buffer.from(value);
|
|
1657
1695
|
}
|
|
@@ -1682,10 +1720,10 @@ class Collection {
|
|
|
1682
1720
|
}, obsReqHandler);
|
|
1683
1721
|
}
|
|
1684
1722
|
if (err) {
|
|
1685
|
-
obsReqHandler.endWithError(err);
|
|
1723
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
|
|
1686
1724
|
throw err;
|
|
1687
1725
|
}
|
|
1688
|
-
obsReqHandler.end();
|
|
1726
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
|
|
1689
1727
|
return new crudoptypes_1.MutationResult({
|
|
1690
1728
|
cas: resp.cas,
|
|
1691
1729
|
token: resp.token,
|
|
@@ -1693,7 +1731,7 @@ class Collection {
|
|
|
1693
1731
|
}, callback);
|
|
1694
1732
|
}
|
|
1695
1733
|
catch (e) {
|
|
1696
|
-
obsReqHandler.endWithError(e);
|
|
1734
|
+
obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(e);
|
|
1697
1735
|
throw e;
|
|
1698
1736
|
}
|
|
1699
1737
|
}
|