@naturalcycles/datastore-lib 4.1.0 → 4.2.0
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/datastore.db.js +10 -1
- package/package.json +1 -1
- package/src/datastore.db.ts +10 -2
package/dist/datastore.db.js
CHANGED
|
@@ -14,7 +14,9 @@ const RETRY_ON = [
|
|
|
14
14
|
'UNAVAILABLE',
|
|
15
15
|
'UNKNOWN',
|
|
16
16
|
'DEADLINE_EXCEEDED',
|
|
17
|
+
'ABORTED',
|
|
17
18
|
'much contention',
|
|
19
|
+
'try again',
|
|
18
20
|
'timeout',
|
|
19
21
|
].map(s => s.toLowerCase());
|
|
20
22
|
// Examples of errors:
|
|
@@ -249,7 +251,14 @@ export class DatastoreDB extends BaseCommonDB {
|
|
|
249
251
|
async deleteByIds(table, ids, opt = {}) {
|
|
250
252
|
const ds = await this.ds();
|
|
251
253
|
const keys = ids.map(id => this.key(ds, table, id));
|
|
252
|
-
|
|
254
|
+
const retryOptions = this.getPRetryOptions(`DatastoreLib.deleteByIds(${table})`);
|
|
255
|
+
await pMap(_chunk(keys, MAX_ITEMS),
|
|
256
|
+
// async batch => await doDelete(batch),
|
|
257
|
+
async (batchOfKeys) => {
|
|
258
|
+
await pRetry(async () => {
|
|
259
|
+
await (opt.tx?.tx || ds).delete(batchOfKeys);
|
|
260
|
+
}, retryOptions);
|
|
261
|
+
}, {
|
|
253
262
|
concurrency: DATASTORE_RECOMMENDED_CONCURRENCY,
|
|
254
263
|
});
|
|
255
264
|
return ids.length;
|
package/package.json
CHANGED
package/src/datastore.db.ts
CHANGED
|
@@ -65,7 +65,9 @@ const RETRY_ON = [
|
|
|
65
65
|
'UNAVAILABLE',
|
|
66
66
|
'UNKNOWN',
|
|
67
67
|
'DEADLINE_EXCEEDED',
|
|
68
|
+
'ABORTED',
|
|
68
69
|
'much contention',
|
|
70
|
+
'try again',
|
|
69
71
|
'timeout',
|
|
70
72
|
].map(s => s.toLowerCase())
|
|
71
73
|
// Examples of errors:
|
|
@@ -416,10 +418,16 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
416
418
|
const ds = await this.ds()
|
|
417
419
|
const keys = ids.map(id => this.key(ds, table, id))
|
|
418
420
|
|
|
421
|
+
const retryOptions = this.getPRetryOptions(`DatastoreLib.deleteByIds(${table})`)
|
|
422
|
+
|
|
419
423
|
await pMap(
|
|
420
424
|
_chunk(keys, MAX_ITEMS),
|
|
421
|
-
|
|
422
|
-
async
|
|
425
|
+
// async batch => await doDelete(batch),
|
|
426
|
+
async batchOfKeys => {
|
|
427
|
+
await pRetry(async () => {
|
|
428
|
+
await ((opt.tx as DatastoreDBTransaction)?.tx || ds).delete(batchOfKeys)
|
|
429
|
+
}, retryOptions)
|
|
430
|
+
},
|
|
423
431
|
{
|
|
424
432
|
concurrency: DATASTORE_RECOMMENDED_CONCURRENCY,
|
|
425
433
|
},
|