sqlite-executor 4.0.3 → 4.0.5
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/cjs/core/pipelineEngine.d.cts +2 -0
- package/dist/cjs/index.cjs +250 -135
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/core/pipelineEngine.d.mts +2 -0
- package/dist/esm/index.mjs +250 -135
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -135,7 +135,7 @@ function normalizeSQL(sql) {
|
|
|
135
135
|
if (void 0 !== cached) return cached;
|
|
136
136
|
var len = sql.length;
|
|
137
137
|
var needed = len + 1;
|
|
138
|
-
if (_normBuf.length < needed) _normBuf = new Uint16Array(
|
|
138
|
+
if (_normBuf.length < needed) _normBuf = new Uint16Array(needed);
|
|
139
139
|
var outCodes = _normBuf;
|
|
140
140
|
var writePos = 0;
|
|
141
141
|
var pendingSpace = false;
|
|
@@ -241,6 +241,7 @@ function createJsonValueParser(onValue) {
|
|
|
241
241
|
nesting: 0,
|
|
242
242
|
inString: false,
|
|
243
243
|
escaped: false,
|
|
244
|
+
_consumed: 0,
|
|
244
245
|
feed: function(chunk) {
|
|
245
246
|
this.buffer += chunk;
|
|
246
247
|
var consumeUntil = 0;
|
|
@@ -272,6 +273,11 @@ function createJsonValueParser(onValue) {
|
|
|
272
273
|
if (code === CHAR_CLOSE_BRACKET || code === CHAR_CLOSE_BRACE) {
|
|
273
274
|
this.nesting--;
|
|
274
275
|
if (0 === this.nesting) {
|
|
276
|
+
if (index === this.start + 1) {
|
|
277
|
+
this.start = -1;
|
|
278
|
+
consumeUntil = index + 1;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
275
281
|
var raw = this.buffer.slice(this.start, index + 1);
|
|
276
282
|
this.start = -1;
|
|
277
283
|
onValue(raw);
|
|
@@ -280,12 +286,19 @@ function createJsonValueParser(onValue) {
|
|
|
280
286
|
}
|
|
281
287
|
}
|
|
282
288
|
if (consumeUntil > 0) {
|
|
283
|
-
this.
|
|
284
|
-
this.readPos =
|
|
289
|
+
this._consumed = consumeUntil;
|
|
290
|
+
this.readPos = -1 !== this.start ? this.buffer.length : this._consumed;
|
|
291
|
+
if (this._consumed > 65536) {
|
|
292
|
+
if (-1 !== this.start) this.start -= this._consumed;
|
|
293
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
294
|
+
this.readPos = this.buffer.length;
|
|
295
|
+
this._consumed = 0;
|
|
296
|
+
}
|
|
285
297
|
} else this.readPos = this.buffer.length;
|
|
286
298
|
},
|
|
287
299
|
reset: function() {
|
|
288
300
|
this.buffer = "";
|
|
301
|
+
this._consumed = 0;
|
|
289
302
|
this.start = -1;
|
|
290
303
|
this.readPos = 0;
|
|
291
304
|
this.nesting = 0;
|
|
@@ -305,6 +318,7 @@ function createRowStreamParser(onRow) {
|
|
|
305
318
|
elementEnd: -1,
|
|
306
319
|
nesting: 0,
|
|
307
320
|
readPos: 0,
|
|
321
|
+
_consumed: 0,
|
|
308
322
|
feed: function(chunk) {
|
|
309
323
|
if (this.finished) return chunk;
|
|
310
324
|
this.buffer += chunk;
|
|
@@ -371,24 +385,38 @@ function createRowStreamParser(onRow) {
|
|
|
371
385
|
var delimiter = this.buffer.charCodeAt(lookAhead);
|
|
372
386
|
if (delimiter === CHAR_COMMA || delimiter === CHAR_CLOSE_BRACKET) {
|
|
373
387
|
onRow(this.buffer.slice(this.elementStart, this.elementEnd));
|
|
374
|
-
this.
|
|
388
|
+
this._consumed = lookAhead + 1;
|
|
375
389
|
this.elementStart = -1;
|
|
376
390
|
this.elementEnd = -1;
|
|
377
391
|
this.nesting = 0;
|
|
378
392
|
if (delimiter === CHAR_CLOSE_BRACKET) {
|
|
379
393
|
this.finished = true;
|
|
380
|
-
var tail = this.buffer;
|
|
394
|
+
var tail = this.buffer.slice(this._consumed);
|
|
381
395
|
this.buffer = "";
|
|
396
|
+
this._consumed = 0;
|
|
382
397
|
this.readPos = 0;
|
|
383
398
|
return tail;
|
|
384
399
|
}
|
|
385
|
-
index =
|
|
400
|
+
index = this._consumed;
|
|
401
|
+
if (this._consumed > 65536) {
|
|
402
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
403
|
+
index = 0;
|
|
404
|
+
this._consumed = 0;
|
|
405
|
+
}
|
|
386
406
|
continue;
|
|
387
407
|
}
|
|
388
408
|
}
|
|
389
409
|
}
|
|
390
410
|
index++;
|
|
391
411
|
}
|
|
412
|
+
if (this._consumed > 0) {
|
|
413
|
+
if (-1 !== this.elementStart) {
|
|
414
|
+
this.elementStart -= this._consumed;
|
|
415
|
+
if (-1 !== this.elementEnd) this.elementEnd -= this._consumed;
|
|
416
|
+
}
|
|
417
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
418
|
+
this._consumed = 0;
|
|
419
|
+
}
|
|
392
420
|
if (this.elementStart > 0) {
|
|
393
421
|
this.buffer = this.buffer.slice(this.elementStart);
|
|
394
422
|
if (-1 !== this.elementEnd) this.elementEnd -= this.elementStart;
|
|
@@ -399,6 +427,7 @@ function createRowStreamParser(onRow) {
|
|
|
399
427
|
},
|
|
400
428
|
reset: function() {
|
|
401
429
|
this.buffer = "";
|
|
430
|
+
this._consumed = 0;
|
|
402
431
|
this.started = false;
|
|
403
432
|
this.finished = false;
|
|
404
433
|
this.inString = false;
|
|
@@ -427,6 +456,22 @@ function stream_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
427
456
|
descriptor.value = value;
|
|
428
457
|
}
|
|
429
458
|
}
|
|
459
|
+
function _class_apply_descriptor_update(receiver, descriptor) {
|
|
460
|
+
if (descriptor.set) {
|
|
461
|
+
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
462
|
+
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
463
|
+
set value (v){
|
|
464
|
+
descriptor.set.call(receiver, v);
|
|
465
|
+
},
|
|
466
|
+
get value () {
|
|
467
|
+
return descriptor.get.call(receiver);
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
return descriptor.__destrWrapper;
|
|
471
|
+
}
|
|
472
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
473
|
+
return descriptor;
|
|
474
|
+
}
|
|
430
475
|
function stream_class_call_check(instance, Constructor) {
|
|
431
476
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
432
477
|
}
|
|
@@ -447,6 +492,10 @@ function stream_class_private_field_set(receiver, privateMap, value) {
|
|
|
447
492
|
stream_class_apply_descriptor_set(receiver, descriptor, value);
|
|
448
493
|
return value;
|
|
449
494
|
}
|
|
495
|
+
function _class_private_field_update(receiver, privateMap) {
|
|
496
|
+
var descriptor = stream_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
497
|
+
return _class_apply_descriptor_update(receiver, descriptor);
|
|
498
|
+
}
|
|
450
499
|
function stream_defineProperties(target, props) {
|
|
451
500
|
for(var i = 0; i < props.length; i++){
|
|
452
501
|
var descriptor = props[i];
|
|
@@ -483,7 +532,7 @@ function setupStreamParser(task) {
|
|
|
483
532
|
return parser;
|
|
484
533
|
}
|
|
485
534
|
_computedKey = Symbol.asyncIterator;
|
|
486
|
-
var _buffer = /*#__PURE__*/ new WeakMap(), _done = /*#__PURE__*/ new WeakMap(), _error = /*#__PURE__*/ new WeakMap(), _pending = /*#__PURE__*/ new WeakMap();
|
|
535
|
+
var _buffer = /*#__PURE__*/ new WeakMap(), _index = /*#__PURE__*/ new WeakMap(), _done = /*#__PURE__*/ new WeakMap(), _error = /*#__PURE__*/ new WeakMap(), _pending = /*#__PURE__*/ new WeakMap();
|
|
487
536
|
var _computedKey1 = _computedKey;
|
|
488
537
|
var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
489
538
|
"use strict";
|
|
@@ -493,6 +542,10 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
493
542
|
writable: true,
|
|
494
543
|
value: []
|
|
495
544
|
});
|
|
545
|
+
stream_class_private_field_init(this, _index, {
|
|
546
|
+
writable: true,
|
|
547
|
+
value: 0
|
|
548
|
+
});
|
|
496
549
|
stream_class_private_field_init(this, _done, {
|
|
497
550
|
writable: true,
|
|
498
551
|
value: false
|
|
@@ -510,6 +563,7 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
510
563
|
{
|
|
511
564
|
key: "push",
|
|
512
565
|
value: function(row) {
|
|
566
|
+
if (stream_class_private_field_get(this, _done) || stream_class_private_field_get(this, _error)) return;
|
|
513
567
|
if (stream_class_private_field_get(this, _pending)) {
|
|
514
568
|
var resolve = stream_class_private_field_get(this, _pending).resolve;
|
|
515
569
|
stream_class_private_field_set(this, _pending, null);
|
|
@@ -549,8 +603,8 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
549
603
|
key: "next",
|
|
550
604
|
value: function() {
|
|
551
605
|
var _this = this;
|
|
552
|
-
if (stream_class_private_field_get(this, _buffer).length
|
|
553
|
-
value: stream_class_private_field_get(this, _buffer)
|
|
606
|
+
if (stream_class_private_field_get(this, _index) < stream_class_private_field_get(this, _buffer).length) return Promise.resolve({
|
|
607
|
+
value: stream_class_private_field_get(this, _buffer)[_class_private_field_update(this, _index).value++],
|
|
554
608
|
done: false
|
|
555
609
|
});
|
|
556
610
|
if (stream_class_private_field_get(this, _done)) return Promise.resolve({
|
|
@@ -570,6 +624,8 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
570
624
|
key: "return",
|
|
571
625
|
value: function() {
|
|
572
626
|
stream_class_private_field_set(this, _done, true);
|
|
627
|
+
stream_class_private_field_set(this, _buffer, []);
|
|
628
|
+
stream_class_private_field_set(this, _index, 0);
|
|
573
629
|
if (stream_class_private_field_get(this, _pending)) {
|
|
574
630
|
var resolve = stream_class_private_field_get(this, _pending).resolve;
|
|
575
631
|
stream_class_private_field_set(this, _pending, null);
|
|
@@ -1102,13 +1158,14 @@ var _counter = 0;
|
|
|
1102
1158
|
var _PREFIX = "__executor_end__";
|
|
1103
1159
|
var _PID36 = process.pid.toString(36);
|
|
1104
1160
|
function generateToken() {
|
|
1105
|
-
|
|
1161
|
+
_counter = _counter + 1 >>> 0;
|
|
1162
|
+
return "".concat(_PREFIX).concat(_counter.toString(36), "_").concat(_PID36);
|
|
1106
1163
|
}
|
|
1107
1164
|
function escape_type_of(obj) {
|
|
1108
1165
|
return obj && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1109
1166
|
}
|
|
1110
1167
|
function escapeValue(value) {
|
|
1111
|
-
if ("string" == typeof value) return "'".concat(value.replace(/'/g, "''"), "'");
|
|
1168
|
+
if ("string" == typeof value) return value.includes("'") ? "'".concat(value.replace(/'/g, "''"), "'") : "'".concat(value, "'");
|
|
1112
1169
|
if (null == value) return "NULL";
|
|
1113
1170
|
if ("number" == typeof value || (void 0 === value ? "undefined" : escape_type_of(value)) === "bigint") return String(value);
|
|
1114
1171
|
if ("boolean" == typeof value) return value ? "TRUE" : "FALSE";
|
|
@@ -1237,10 +1294,11 @@ function classifySingle(stmt) {
|
|
|
1237
1294
|
return READ_ONLY_KINDS.has(kind) ? "read" : "write";
|
|
1238
1295
|
}
|
|
1239
1296
|
function classifySQL(sql) {
|
|
1240
|
-
if ("string" != typeof sql
|
|
1297
|
+
if ("string" != typeof sql) return "write";
|
|
1241
1298
|
var cached = _classifyCache.get(sql);
|
|
1242
1299
|
if (void 0 !== cached) return cached;
|
|
1243
1300
|
var trimmed = sql.trim();
|
|
1301
|
+
if (0 === trimmed.length) return "write";
|
|
1244
1302
|
var result;
|
|
1245
1303
|
if (trimmed.includes(";")) {
|
|
1246
1304
|
var stmts = trimmed.split(";");
|
|
@@ -1282,7 +1340,7 @@ function queue_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
1282
1340
|
descriptor.value = value;
|
|
1283
1341
|
}
|
|
1284
1342
|
}
|
|
1285
|
-
function
|
|
1343
|
+
function queue_class_apply_descriptor_update(receiver, descriptor) {
|
|
1286
1344
|
if (descriptor.set) {
|
|
1287
1345
|
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
1288
1346
|
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
@@ -1318,9 +1376,9 @@ function queue_class_private_field_set(receiver, privateMap, value) {
|
|
|
1318
1376
|
queue_class_apply_descriptor_set(receiver, descriptor, value);
|
|
1319
1377
|
return value;
|
|
1320
1378
|
}
|
|
1321
|
-
function
|
|
1379
|
+
function queue_class_private_field_update(receiver, privateMap) {
|
|
1322
1380
|
var descriptor = queue_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
1323
|
-
return
|
|
1381
|
+
return queue_class_apply_descriptor_update(receiver, descriptor);
|
|
1324
1382
|
}
|
|
1325
1383
|
function _class_private_method_get(receiver, privateSet, fn) {
|
|
1326
1384
|
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
@@ -1475,7 +1533,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1475
1533
|
if (queue_class_private_field_get(this, _size) === queue_class_private_field_get(this, _items).length) _class_private_method_get(this, _grow, grow).call(this);
|
|
1476
1534
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _tail)] = value;
|
|
1477
1535
|
queue_class_private_field_set(this, _tail, queue_class_private_field_get(this, _tail) + 1 & queue_class_private_field_get(this, _mask));
|
|
1478
|
-
|
|
1536
|
+
queue_class_private_field_update(this, _size).value++;
|
|
1479
1537
|
}
|
|
1480
1538
|
},
|
|
1481
1539
|
{
|
|
@@ -1485,7 +1543,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1485
1543
|
var value = queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _head)];
|
|
1486
1544
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _head)] = void 0;
|
|
1487
1545
|
queue_class_private_field_set(this, _head, queue_class_private_field_get(this, _head) + 1 & queue_class_private_field_get(this, _mask));
|
|
1488
|
-
|
|
1546
|
+
queue_class_private_field_update(this, _size).value--;
|
|
1489
1547
|
return value;
|
|
1490
1548
|
}
|
|
1491
1549
|
},
|
|
@@ -1512,7 +1570,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1512
1570
|
}
|
|
1513
1571
|
queue_class_private_field_set(this, _tail, queue_class_private_field_get(this, _tail) - 1 & queue_class_private_field_get(this, _mask));
|
|
1514
1572
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _tail)] = void 0;
|
|
1515
|
-
|
|
1573
|
+
queue_class_private_field_update(this, _size).value--;
|
|
1516
1574
|
return true;
|
|
1517
1575
|
}
|
|
1518
1576
|
}
|
|
@@ -1664,7 +1722,7 @@ function buildPayload(sql, token) {
|
|
|
1664
1722
|
return "".concat(normalized).concat(suffix, "\nSELECT '").concat(token, "' AS ").concat(TOKEN_COLUMN, ";\n");
|
|
1665
1723
|
}
|
|
1666
1724
|
function isTransactionControl(sql) {
|
|
1667
|
-
var s = sql.
|
|
1725
|
+
var s = sql.toUpperCase();
|
|
1668
1726
|
return "BEGIN" === s || "BEGIN TRANSACTION" === s || "COMMIT" === s || "COMMIT TRANSACTION" === s || "ROLLBACK" === s || "ROLLBACK TRANSACTION" === s || s.startsWith("BEGIN ") || s.startsWith("COMMIT ") || s.startsWith("ROLLBACK ");
|
|
1669
1727
|
}
|
|
1670
1728
|
function buildBatchPayload(batch) {
|
|
@@ -1731,6 +1789,10 @@ function buildBatchPayload(batch) {
|
|
|
1731
1789
|
}
|
|
1732
1790
|
return parts1.join("");
|
|
1733
1791
|
}
|
|
1792
|
+
var TC_FIRST_CHAR = TOKEN_COLUMN.charCodeAt(0);
|
|
1793
|
+
function isSentinelRaw(raw, token) {
|
|
1794
|
+
return raw.charCodeAt(3) === TC_FIRST_CHAR && raw === '[{"'.concat(TOKEN_COLUMN, '":"').concat(token, '"}]');
|
|
1795
|
+
}
|
|
1734
1796
|
function isSentinelRow(value, token) {
|
|
1735
1797
|
var _value_;
|
|
1736
1798
|
return Array.isArray(value) && 1 === value.length && (null == (_value_ = value[0]) ? void 0 : _value_[TOKEN_COLUMN]) === token;
|
|
@@ -1795,7 +1857,6 @@ function settleTask(task, error, value, metrics) {
|
|
|
1795
1857
|
var _ref = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {}, _ref_resetRowParser = _ref.resetRowParser, resetRowParser = void 0 === _ref_resetRowParser ? false : _ref_resetRowParser;
|
|
1796
1858
|
if (task.settled) return;
|
|
1797
1859
|
task.settled = true;
|
|
1798
|
-
clearTimeout(task.timer);
|
|
1799
1860
|
if (resetRowParser) {
|
|
1800
1861
|
var _task_rowParser_reset, _task_rowParser;
|
|
1801
1862
|
null == (_task_rowParser = task.rowParser) || null == (_task_rowParser_reset = _task_rowParser.reset) || _task_rowParser_reset.call(_task_rowParser);
|
|
@@ -1809,6 +1870,44 @@ function settleTask(task, error, value, metrics) {
|
|
|
1809
1870
|
null == metrics || metrics.incrementTasksSuccess(duration);
|
|
1810
1871
|
task.resolve(value);
|
|
1811
1872
|
}
|
|
1873
|
+
function finalizePendingTasks(tasks, settle, pumpQueue) {
|
|
1874
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1875
|
+
try {
|
|
1876
|
+
for(var _iterator = tasks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1877
|
+
var task = _step.value;
|
|
1878
|
+
if (task.stderrText) {
|
|
1879
|
+
settle(task, new Error(task.stderrText.trim()), void 0);
|
|
1880
|
+
continue;
|
|
1881
|
+
}
|
|
1882
|
+
if (task.consumerError) {
|
|
1883
|
+
settle(task, task.consumerError, void 0);
|
|
1884
|
+
continue;
|
|
1885
|
+
}
|
|
1886
|
+
if ("query" === task.kind) {
|
|
1887
|
+
settle(task, null, task.rows);
|
|
1888
|
+
continue;
|
|
1889
|
+
}
|
|
1890
|
+
settle(task, null, void 0);
|
|
1891
|
+
}
|
|
1892
|
+
} catch (err) {
|
|
1893
|
+
_didIteratorError = true;
|
|
1894
|
+
_iteratorError = err;
|
|
1895
|
+
} finally{
|
|
1896
|
+
try {
|
|
1897
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1898
|
+
} finally{
|
|
1899
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
tasks.clear();
|
|
1903
|
+
pumpQueue();
|
|
1904
|
+
}
|
|
1905
|
+
function prepareTaskTimeout(task, metrics) {
|
|
1906
|
+
if (task.settled) return null;
|
|
1907
|
+
task.timedout = true;
|
|
1908
|
+
null == metrics || metrics.incrementTasksTimeout();
|
|
1909
|
+
return createTimeoutError(task.timeout, task.sql);
|
|
1910
|
+
}
|
|
1812
1911
|
function taskWorker_array_like_to_array(arr, len) {
|
|
1813
1912
|
if (null == len || len > arr.length) len = arr.length;
|
|
1814
1913
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -1964,7 +2063,7 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
1964
2063
|
database: database,
|
|
1965
2064
|
initMode: initMode,
|
|
1966
2065
|
onDrain: function() {
|
|
1967
|
-
return taskWorker_class_private_method_get(_this, _pumpQueue,
|
|
2066
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
1968
2067
|
}
|
|
1969
2068
|
}));
|
|
1970
2069
|
taskWorker_class_private_field_set(this, _valueParser, createJsonValueParser(function(raw) {
|
|
@@ -2014,7 +2113,13 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2014
2113
|
};
|
|
2015
2114
|
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTotal(config.kind);
|
|
2016
2115
|
taskWorker_class_private_field_get(this, _pendingQueue).enqueue(task);
|
|
2017
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2116
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2117
|
+
}
|
|
2118
|
+
},
|
|
2119
|
+
{
|
|
2120
|
+
key: "_process",
|
|
2121
|
+
get: function() {
|
|
2122
|
+
return taskWorker_class_private_field_get(this, _processManager).process;
|
|
2018
2123
|
}
|
|
2019
2124
|
},
|
|
2020
2125
|
{
|
|
@@ -2048,7 +2153,7 @@ function startProcess() {
|
|
|
2048
2153
|
taskWorker_class_private_method_get(_this, _rejectAll, taskWorker_rejectAll).call(_this, err);
|
|
2049
2154
|
});
|
|
2050
2155
|
}
|
|
2051
|
-
function
|
|
2156
|
+
function taskWorker_pumpQueue() {
|
|
2052
2157
|
var _this = this;
|
|
2053
2158
|
var _$_class_private_field_get;
|
|
2054
2159
|
if (taskWorker_class_private_field_get(this, _processManager).draining) return;
|
|
@@ -2090,6 +2195,26 @@ function pumpQueue() {
|
|
|
2090
2195
|
function handleParsedValue(raw) {
|
|
2091
2196
|
var task = taskWorker_class_private_field_get(this, _inflightTasks)[0];
|
|
2092
2197
|
if (!task) return;
|
|
2198
|
+
if (isSentinelRaw(raw, task.token)) {
|
|
2199
|
+
clearTimeout(task.timer);
|
|
2200
|
+
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2201
|
+
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2202
|
+
if (task.stderrText) {
|
|
2203
|
+
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2204
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
if (task.consumerError) {
|
|
2208
|
+
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2209
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
2212
|
+
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2213
|
+
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2214
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
if ("[]" === raw) return;
|
|
2093
2218
|
var parsed;
|
|
2094
2219
|
try {
|
|
2095
2220
|
parsed = JSON.parse(raw);
|
|
@@ -2100,20 +2225,20 @@ function handleParsedValue(raw) {
|
|
|
2100
2225
|
if (isSentinelRow(parsed, task.token)) {
|
|
2101
2226
|
clearTimeout(task.timer);
|
|
2102
2227
|
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2103
|
-
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2228
|
+
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2104
2229
|
if (task.stderrText) {
|
|
2105
2230
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2106
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2231
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2107
2232
|
return;
|
|
2108
2233
|
}
|
|
2109
2234
|
if (task.consumerError) {
|
|
2110
2235
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2111
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2236
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2112
2237
|
return;
|
|
2113
2238
|
}
|
|
2114
2239
|
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2115
2240
|
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2116
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2241
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2117
2242
|
return;
|
|
2118
2243
|
}
|
|
2119
2244
|
if ("query" === task.kind) return void collectQueryRows(task, parsed);
|
|
@@ -2125,36 +2250,11 @@ function scheduleFinalizeCheck() {
|
|
|
2125
2250
|
taskWorker_class_private_field_set(this, _scheduledFinalize, true);
|
|
2126
2251
|
setImmediate(function() {
|
|
2127
2252
|
taskWorker_class_private_field_set(_this, _scheduledFinalize, false);
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, new Error(task.stderrText.trim()), void 0);
|
|
2134
|
-
continue;
|
|
2135
|
-
}
|
|
2136
|
-
if (task.consumerError) {
|
|
2137
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, task.consumerError, void 0);
|
|
2138
|
-
continue;
|
|
2139
|
-
}
|
|
2140
|
-
if ("query" === task.kind) {
|
|
2141
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, null, task.rows);
|
|
2142
|
-
continue;
|
|
2143
|
-
}
|
|
2144
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, null, void 0);
|
|
2145
|
-
}
|
|
2146
|
-
} catch (err) {
|
|
2147
|
-
_didIteratorError = true;
|
|
2148
|
-
_iteratorError = err;
|
|
2149
|
-
} finally{
|
|
2150
|
-
try {
|
|
2151
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2152
|
-
} finally{
|
|
2153
|
-
if (_didIteratorError) throw _iteratorError;
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
taskWorker_class_private_field_get(_this, _pendingFinalizeTasks).clear();
|
|
2157
|
-
taskWorker_class_private_method_get(_this, _pumpQueue, pumpQueue).call(_this);
|
|
2253
|
+
finalizePendingTasks(taskWorker_class_private_field_get(_this, _pendingFinalizeTasks), function(t, e, v1) {
|
|
2254
|
+
return taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, t, e, v1);
|
|
2255
|
+
}, function() {
|
|
2256
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
2257
|
+
});
|
|
2158
2258
|
});
|
|
2159
2259
|
}
|
|
2160
2260
|
function taskWorker_handleStderrChunk(chunk) {
|
|
@@ -2168,13 +2268,8 @@ function taskWorker_handleStderrChunk(chunk) {
|
|
|
2168
2268
|
task.stderrText += String(chunk);
|
|
2169
2269
|
}
|
|
2170
2270
|
function handleTaskTimeout(task) {
|
|
2171
|
-
var
|
|
2172
|
-
if (task
|
|
2173
|
-
task.timedout = true;
|
|
2174
|
-
clearTimeout(task.timer);
|
|
2175
|
-
task.timer = null;
|
|
2176
|
-
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTimeout();
|
|
2177
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, createTimeoutError(task.timeout, task.sql), void 0);
|
|
2271
|
+
var error = prepareTaskTimeout(task, taskWorker_class_private_field_get(this, _metrics));
|
|
2272
|
+
if (error) taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, error, void 0);
|
|
2178
2273
|
}
|
|
2179
2274
|
function settleTask1(task, error, value) {
|
|
2180
2275
|
settleTask(task, error, value, taskWorker_class_private_field_get(this, _metrics));
|
|
@@ -2228,21 +2323,12 @@ function readerPool_class_apply_descriptor_get(receiver, descriptor) {
|
|
|
2228
2323
|
if (descriptor.get) return descriptor.get.call(receiver);
|
|
2229
2324
|
return descriptor.value;
|
|
2230
2325
|
}
|
|
2231
|
-
function
|
|
2232
|
-
if (descriptor.set)
|
|
2233
|
-
|
|
2234
|
-
if (!("
|
|
2235
|
-
|
|
2236
|
-
descriptor.set.call(receiver, v);
|
|
2237
|
-
},
|
|
2238
|
-
get value () {
|
|
2239
|
-
return descriptor.get.call(receiver);
|
|
2240
|
-
}
|
|
2241
|
-
};
|
|
2242
|
-
return descriptor.__destrWrapper;
|
|
2326
|
+
function readerPool_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
2327
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
2328
|
+
else {
|
|
2329
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
2330
|
+
descriptor.value = value;
|
|
2243
2331
|
}
|
|
2244
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
2245
|
-
return descriptor;
|
|
2246
2332
|
}
|
|
2247
2333
|
function readerPool_class_call_check(instance, Constructor) {
|
|
2248
2334
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
@@ -2259,9 +2345,10 @@ function readerPool_class_private_field_init(obj, privateMap, value) {
|
|
|
2259
2345
|
readerPool_check_private_redeclaration(obj, privateMap);
|
|
2260
2346
|
privateMap.set(obj, value);
|
|
2261
2347
|
}
|
|
2262
|
-
function
|
|
2263
|
-
var descriptor = readerPool_class_extract_field_descriptor(receiver, privateMap, "
|
|
2264
|
-
|
|
2348
|
+
function readerPool_class_private_field_set(receiver, privateMap, value) {
|
|
2349
|
+
var descriptor = readerPool_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
2350
|
+
readerPool_class_apply_descriptor_set(receiver, descriptor, value);
|
|
2351
|
+
return value;
|
|
2265
2352
|
}
|
|
2266
2353
|
function readerPool_defineProperties(target, props) {
|
|
2267
2354
|
for(var i = 0; i < props.length; i++){
|
|
@@ -2291,6 +2378,7 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2291
2378
|
writable: true,
|
|
2292
2379
|
value: 0
|
|
2293
2380
|
});
|
|
2381
|
+
if (poolSize < 1) throw new RangeError("poolSize must be >= 1");
|
|
2294
2382
|
for(var i = 0; i < poolSize; i++){
|
|
2295
2383
|
var worker = new taskWorker_TaskWorker({
|
|
2296
2384
|
binary: binary,
|
|
@@ -2323,10 +2411,16 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2323
2411
|
key: "enqueue",
|
|
2324
2412
|
value: function(task) {
|
|
2325
2413
|
var worker = readerPool_class_private_field_get(this, _workers)[readerPool_class_private_field_get(this, _rrIndex) % readerPool_class_private_field_get(this, _workers).length];
|
|
2326
|
-
|
|
2414
|
+
readerPool_class_private_field_set(this, _rrIndex, readerPool_class_private_field_get(this, _rrIndex) + 1 >>> 0);
|
|
2327
2415
|
worker.enqueue(task);
|
|
2328
2416
|
}
|
|
2329
2417
|
},
|
|
2418
|
+
{
|
|
2419
|
+
key: "_workers",
|
|
2420
|
+
get: function() {
|
|
2421
|
+
return readerPool_class_private_field_get(this, _workers);
|
|
2422
|
+
}
|
|
2423
|
+
},
|
|
2330
2424
|
{
|
|
2331
2425
|
key: "kill",
|
|
2332
2426
|
value: function() {
|
|
@@ -2939,16 +3033,17 @@ function pipelineEngine_unsupported_iterable_to_array(o, minLen) {
|
|
|
2939
3033
|
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
2940
3034
|
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return pipelineEngine_array_like_to_array(o, minLen);
|
|
2941
3035
|
}
|
|
2942
|
-
var _queue = /*#__PURE__*/ new WeakMap(), pipelineEngine_inflightTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_pendingFinalizeTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_scheduledFinalize = /*#__PURE__*/ new WeakMap(), _sharedValueParser = /*#__PURE__*/ new WeakMap(), pipelineEngine_processManager = /*#__PURE__*/ new WeakMap(), pipelineEngine_metrics = /*#__PURE__*/ new WeakMap(), pipelineEngine_statementTimeout = /*#__PURE__*/ new WeakMap(), pipelineEngine_logger = /*#__PURE__*/ new WeakMap(), pipelineEngine_batchSize = /*#__PURE__*/ new WeakMap(), pipelineEngine_maxInflight = /*#__PURE__*/ new WeakMap(), _onTaskTimeout = /*#__PURE__*/ new WeakMap(), _active = /*#__PURE__*/ new WeakMap(), core_pipelineEngine_pumpQueue = /*#__PURE__*/ new WeakSet(), pipelineEngine_handleParsedValue = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_scheduleFinalizeCheck = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_handleTaskTimeout = /*#__PURE__*/ new WeakSet(), pipelineEngine_settleTask = /*#__PURE__*/ new WeakSet();
|
|
3036
|
+
var _queue = /*#__PURE__*/ new WeakMap(), pipelineEngine_inflightTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_pendingFinalizeTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_scheduledFinalize = /*#__PURE__*/ new WeakMap(), _sharedValueParser = /*#__PURE__*/ new WeakMap(), pipelineEngine_processManager = /*#__PURE__*/ new WeakMap(), pipelineEngine_metrics = /*#__PURE__*/ new WeakMap(), pipelineEngine_statementTimeout = /*#__PURE__*/ new WeakMap(), pipelineEngine_logger = /*#__PURE__*/ new WeakMap(), pipelineEngine_batchSize = /*#__PURE__*/ new WeakMap(), pipelineEngine_maxInflight = /*#__PURE__*/ new WeakMap(), _onTaskTimeout = /*#__PURE__*/ new WeakMap(), _active = /*#__PURE__*/ new WeakMap(), _sweepTimer = /*#__PURE__*/ new WeakMap(), _sweepIntervalMs = /*#__PURE__*/ new WeakMap(), core_pipelineEngine_pumpQueue = /*#__PURE__*/ new WeakSet(), pipelineEngine_handleParsedValue = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_scheduleFinalizeCheck = /*#__PURE__*/ new WeakSet(), _scheduleSweep = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_handleTaskTimeout = /*#__PURE__*/ new WeakSet(), pipelineEngine_settleTask = /*#__PURE__*/ new WeakSet();
|
|
2943
3037
|
var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
2944
3038
|
"use strict";
|
|
2945
3039
|
function PipelineEngine(processManager, param) {
|
|
2946
3040
|
var _this = this;
|
|
2947
|
-
var metrics = param.metrics, statementTimeout = param.statementTimeout, logger = param.logger, _param_batchSize = param.batchSize, batchSize = void 0 === _param_batchSize ? DEFAULT_BATCH_SIZE : _param_batchSize, _param_maxInflight = param.maxInflight, maxInflight = void 0 === _param_maxInflight ? DEFAULT_MAX_INFLIGHT : _param_maxInflight, onTaskTimeout = param.onTaskTimeout;
|
|
3041
|
+
var metrics = param.metrics, statementTimeout = param.statementTimeout, logger = param.logger, _param_batchSize = param.batchSize, batchSize = void 0 === _param_batchSize ? DEFAULT_BATCH_SIZE : _param_batchSize, _param_maxInflight = param.maxInflight, maxInflight = void 0 === _param_maxInflight ? DEFAULT_MAX_INFLIGHT : _param_maxInflight, onTaskTimeout = param.onTaskTimeout, _param_sweepInterval = param.sweepInterval, sweepInterval = void 0 === _param_sweepInterval ? 100 : _param_sweepInterval;
|
|
2948
3042
|
pipelineEngine_class_call_check(this, PipelineEngine);
|
|
2949
3043
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_pumpQueue);
|
|
2950
3044
|
pipelineEngine_class_private_method_init(this, pipelineEngine_handleParsedValue);
|
|
2951
3045
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_scheduleFinalizeCheck);
|
|
3046
|
+
pipelineEngine_class_private_method_init(this, _scheduleSweep);
|
|
2952
3047
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_handleTaskTimeout);
|
|
2953
3048
|
pipelineEngine_class_private_method_init(this, pipelineEngine_settleTask);
|
|
2954
3049
|
pipelineEngine_class_private_field_init(this, _queue, {
|
|
@@ -3003,6 +3098,14 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3003
3098
|
writable: true,
|
|
3004
3099
|
value: false
|
|
3005
3100
|
});
|
|
3101
|
+
pipelineEngine_class_private_field_init(this, _sweepTimer, {
|
|
3102
|
+
writable: true,
|
|
3103
|
+
value: null
|
|
3104
|
+
});
|
|
3105
|
+
pipelineEngine_class_private_field_init(this, _sweepIntervalMs, {
|
|
3106
|
+
writable: true,
|
|
3107
|
+
value: void 0
|
|
3108
|
+
});
|
|
3006
3109
|
pipelineEngine_class_private_field_set(this, pipelineEngine_processManager, processManager);
|
|
3007
3110
|
pipelineEngine_class_private_field_set(this, pipelineEngine_metrics, metrics);
|
|
3008
3111
|
pipelineEngine_class_private_field_set(this, pipelineEngine_statementTimeout, statementTimeout);
|
|
@@ -3016,8 +3119,15 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3016
3119
|
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).setOnDrainCallback(function() {
|
|
3017
3120
|
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3018
3121
|
});
|
|
3122
|
+
pipelineEngine_class_private_field_set(this, _sweepIntervalMs, sweepInterval);
|
|
3019
3123
|
}
|
|
3020
3124
|
pipelineEngine_create_class(PipelineEngine, [
|
|
3125
|
+
{
|
|
3126
|
+
key: "_sweepTimer",
|
|
3127
|
+
get: function() {
|
|
3128
|
+
return pipelineEngine_class_private_field_get(this, _sweepTimer);
|
|
3129
|
+
}
|
|
3130
|
+
},
|
|
3021
3131
|
{
|
|
3022
3132
|
key: "mainQueue",
|
|
3023
3133
|
get: function() {
|
|
@@ -3068,7 +3178,7 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3068
3178
|
value: function(chunk) {
|
|
3069
3179
|
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[0];
|
|
3070
3180
|
if (!task) return;
|
|
3071
|
-
if ("stream" === task.kind && task.rowParser && !task.rowParser.finished) {
|
|
3181
|
+
if ("stream" === task.kind && task.rowParser && !task.rowParser.finished && !task.timedout) {
|
|
3072
3182
|
var leftover = task.rowParser.feed(chunk);
|
|
3073
3183
|
if (leftover) pipelineEngine_class_private_field_get(this, _sharedValueParser).feed(leftover);
|
|
3074
3184
|
return;
|
|
@@ -3092,6 +3202,7 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3092
3202
|
{
|
|
3093
3203
|
key: "rejectAll",
|
|
3094
3204
|
value: function(error) {
|
|
3205
|
+
pipelineEngine_class_private_field_get(this, _sharedValueParser).reset();
|
|
3095
3206
|
var all = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks);
|
|
3096
3207
|
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightTasks, []);
|
|
3097
3208
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
@@ -3138,6 +3249,8 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3138
3249
|
key: "kill",
|
|
3139
3250
|
value: function() {
|
|
3140
3251
|
pipelineEngine_class_private_field_set(this, _active, false);
|
|
3252
|
+
clearTimeout(pipelineEngine_class_private_field_get(this, _sweepTimer));
|
|
3253
|
+
pipelineEngine_class_private_field_set(this, _sweepTimer, null);
|
|
3141
3254
|
this.rejectAll(new Error("PipelineEngine is killed"));
|
|
3142
3255
|
}
|
|
3143
3256
|
}
|
|
@@ -3145,7 +3258,6 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3145
3258
|
return PipelineEngine;
|
|
3146
3259
|
}();
|
|
3147
3260
|
function pipelineEngine_pumpQueue() {
|
|
3148
|
-
var _this = this;
|
|
3149
3261
|
var _$_class_private_field_get;
|
|
3150
3262
|
if (!pipelineEngine_class_private_field_get(this, _active)) return;
|
|
3151
3263
|
if (pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).draining) return;
|
|
@@ -3162,14 +3274,10 @@ function pipelineEngine_pumpQueue() {
|
|
|
3162
3274
|
var payload = buildBatchPayload(batch);
|
|
3163
3275
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
3164
3276
|
try {
|
|
3165
|
-
var
|
|
3166
|
-
var
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_handleTaskTimeout, pipelineEngine_handleTaskTimeout).call(_this, task);
|
|
3170
|
-
}, task.timeout);
|
|
3171
|
-
};
|
|
3172
|
-
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
3277
|
+
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3278
|
+
var task1 = _step.value;
|
|
3279
|
+
task1.startTime = now;
|
|
3280
|
+
}
|
|
3173
3281
|
} catch (err) {
|
|
3174
3282
|
_didIteratorError = true;
|
|
3175
3283
|
_iteratorError = err;
|
|
@@ -3181,11 +3289,26 @@ function pipelineEngine_pumpQueue() {
|
|
|
3181
3289
|
}
|
|
3182
3290
|
}
|
|
3183
3291
|
(_$_class_private_field_get = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)).push.apply(_$_class_private_field_get, pipelineEngine_to_consumable_array(batch));
|
|
3292
|
+
pipelineEngine_class_private_method_get(this, _scheduleSweep, scheduleSweep).call(this);
|
|
3184
3293
|
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).write(payload);
|
|
3185
3294
|
}
|
|
3186
3295
|
function core_pipelineEngine_handleParsedValue(raw) {
|
|
3187
3296
|
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[0];
|
|
3188
3297
|
if (!task) return;
|
|
3298
|
+
if (isSentinelRaw(raw, task.token)) {
|
|
3299
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3300
|
+
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3301
|
+
if (task.consumerError) {
|
|
3302
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
3303
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3304
|
+
return;
|
|
3305
|
+
}
|
|
3306
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).add(task);
|
|
3307
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_scheduleFinalizeCheck, pipelineEngine_scheduleFinalizeCheck).call(this);
|
|
3308
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3311
|
+
if ("[]" === raw) return;
|
|
3189
3312
|
var parsed;
|
|
3190
3313
|
try {
|
|
3191
3314
|
parsed = JSON.parse(raw);
|
|
@@ -3194,7 +3317,6 @@ function core_pipelineEngine_handleParsedValue(raw) {
|
|
|
3194
3317
|
return;
|
|
3195
3318
|
}
|
|
3196
3319
|
if (isSentinelRow(parsed, task.token)) {
|
|
3197
|
-
clearTimeout(task.timer);
|
|
3198
3320
|
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3199
3321
|
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3200
3322
|
if (task.consumerError) {
|
|
@@ -3217,44 +3339,34 @@ function pipelineEngine_scheduleFinalizeCheck() {
|
|
|
3217
3339
|
pipelineEngine_class_private_field_set(this, pipelineEngine_scheduledFinalize, true);
|
|
3218
3340
|
setImmediate(function() {
|
|
3219
3341
|
pipelineEngine_class_private_field_set(_this, pipelineEngine_scheduledFinalize, false);
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, new Error(task.stderrText.trim()), void 0);
|
|
3226
|
-
continue;
|
|
3227
|
-
}
|
|
3228
|
-
if (task.consumerError) {
|
|
3229
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, task.consumerError, void 0);
|
|
3230
|
-
continue;
|
|
3231
|
-
}
|
|
3232
|
-
if ("query" === task.kind) {
|
|
3233
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, null, task.rows);
|
|
3234
|
-
continue;
|
|
3235
|
-
}
|
|
3236
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, null, void 0);
|
|
3237
|
-
}
|
|
3238
|
-
} catch (err) {
|
|
3239
|
-
_didIteratorError = true;
|
|
3240
|
-
_iteratorError = err;
|
|
3241
|
-
} finally{
|
|
3242
|
-
try {
|
|
3243
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
3244
|
-
} finally{
|
|
3245
|
-
if (_didIteratorError) throw _iteratorError;
|
|
3246
|
-
}
|
|
3247
|
-
}
|
|
3248
|
-
pipelineEngine_class_private_field_get(_this, pipelineEngine_pendingFinalizeTasks).clear();
|
|
3342
|
+
finalizePendingTasks(pipelineEngine_class_private_field_get(_this, pipelineEngine_pendingFinalizeTasks), function(t, e, v1) {
|
|
3343
|
+
return pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, t, e, v1);
|
|
3344
|
+
}, function() {
|
|
3345
|
+
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3346
|
+
});
|
|
3249
3347
|
});
|
|
3250
3348
|
}
|
|
3349
|
+
function scheduleSweep() {
|
|
3350
|
+
var _this = this;
|
|
3351
|
+
if (pipelineEngine_class_private_field_get(this, _sweepTimer)) return;
|
|
3352
|
+
pipelineEngine_class_private_field_set(this, _sweepTimer, setTimeout(function() {
|
|
3353
|
+
pipelineEngine_class_private_field_set(_this, _sweepTimer, null);
|
|
3354
|
+
var inflight = pipelineEngine_class_private_field_get(_this, pipelineEngine_inflightTasks);
|
|
3355
|
+
var now = performance.now();
|
|
3356
|
+
for(var i = 0; i < inflight.length; i++){
|
|
3357
|
+
var task = inflight[i];
|
|
3358
|
+
if (now - task.startTime > task.timeout) pipelineEngine_class_private_method_get(_this, core_pipelineEngine_handleTaskTimeout, pipelineEngine_handleTaskTimeout).call(_this, task);
|
|
3359
|
+
}
|
|
3360
|
+
if (pipelineEngine_class_private_field_get(_this, pipelineEngine_inflightTasks).length > 0) pipelineEngine_class_private_method_get(_this, _scheduleSweep, scheduleSweep).call(_this);
|
|
3361
|
+
}, pipelineEngine_class_private_field_get(this, _sweepIntervalMs)).unref());
|
|
3362
|
+
}
|
|
3251
3363
|
function pipelineEngine_handleTaskTimeout(task) {
|
|
3252
3364
|
var _this, _this1;
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3365
|
+
var error = prepareTaskTimeout(task, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics));
|
|
3366
|
+
if (error) {
|
|
3367
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, error, void 0);
|
|
3368
|
+
null == (_this = pipelineEngine_class_private_field_get(_this1 = this, _onTaskTimeout)) || _this.call(_this1, task);
|
|
3369
|
+
}
|
|
3258
3370
|
}
|
|
3259
3371
|
function pipelineEngine_settleTask1(task, error, value) {
|
|
3260
3372
|
settleTask(task, error, value, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics), {
|
|
@@ -3483,7 +3595,6 @@ var _computedKey2 = executor_computedKey;
|
|
|
3483
3595
|
var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
3484
3596
|
"use strict";
|
|
3485
3597
|
function SQLiteExecutor() {
|
|
3486
|
-
var _this = this;
|
|
3487
3598
|
var _ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, _ref_binary = _ref.binary, binary = void 0 === _ref_binary ? "sqlite3" : _ref_binary, _ref_database = _ref.database, database = void 0 === _ref_database ? ":memory:" : _ref_database, logger = _ref.logger, _ref_statementTimeout = _ref.statementTimeout, statementTimeout = void 0 === _ref_statementTimeout ? DEFAULT_STATEMENT_TIMEOUT : _ref_statementTimeout, _ref_autoRestart = _ref.autoRestart, autoRestart = void 0 === _ref_autoRestart ? true : _ref_autoRestart, _ref_poolSize = _ref.poolSize, poolSize = void 0 === _ref_poolSize ? 0 : _ref_poolSize, metrics = _ref.metrics;
|
|
3488
3599
|
executor_class_call_check(this, SQLiteExecutor);
|
|
3489
3600
|
executor_class_private_method_init(this, _normalizeTimeout);
|
|
@@ -3563,9 +3674,7 @@ var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
|
3563
3674
|
metrics: executor_class_private_field_get(this, executor_metrics),
|
|
3564
3675
|
statementTimeout: executor_class_private_field_get(this, executor_statementTimeout),
|
|
3565
3676
|
logger: executor_class_private_field_get(this, executor_logger),
|
|
3566
|
-
onTaskTimeout: function(
|
|
3567
|
-
executor_class_private_field_get(_this, executor_metrics).incrementTasksTimeout();
|
|
3568
|
-
}
|
|
3677
|
+
onTaskTimeout: function() {}
|
|
3569
3678
|
}));
|
|
3570
3679
|
executor_class_private_method_get(this, executor_startProcess, core_executor_startProcess).call(this);
|
|
3571
3680
|
if (poolSize > 0 && ":memory:" !== database) executor_class_private_field_set(this, _readerPool, new readerPool_ReaderPool({
|
|
@@ -3592,6 +3701,12 @@ var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
|
3592
3701
|
return executor_class_private_field_get(this, _readerPool);
|
|
3593
3702
|
}
|
|
3594
3703
|
},
|
|
3704
|
+
{
|
|
3705
|
+
key: "_process",
|
|
3706
|
+
get: function() {
|
|
3707
|
+
return executor_class_private_field_get(this, executor_proc);
|
|
3708
|
+
}
|
|
3709
|
+
},
|
|
3595
3710
|
{
|
|
3596
3711
|
key: "metrics",
|
|
3597
3712
|
get: function() {
|
|
@@ -3884,9 +3999,9 @@ function enqueueWriter(kind, sql, timeout, token, onRow, scopeId) {
|
|
|
3884
3999
|
settled: false,
|
|
3885
4000
|
timer: null,
|
|
3886
4001
|
startTime: 0,
|
|
3887
|
-
rowParser: null
|
|
4002
|
+
rowParser: null,
|
|
4003
|
+
rows: "query" === kind ? [] : null
|
|
3888
4004
|
};
|
|
3889
|
-
if ("query" === kind) task.rows = [];
|
|
3890
4005
|
if ("stream" === kind) task.rowParser = setupStreamParser(task, executor_class_private_field_get(_this, _pipeline));
|
|
3891
4006
|
if (executor_class_private_field_get(_this, _txScope).isDeferred(scopeId)) executor_class_private_field_get(_this, _txScope).defer(task);
|
|
3892
4007
|
else executor_class_private_field_get(_this, _pipeline).enqueue(task);
|