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/cjs/index.cjs
CHANGED
|
@@ -188,7 +188,7 @@ function normalizeSQL(sql) {
|
|
|
188
188
|
if (void 0 !== cached) return cached;
|
|
189
189
|
var len = sql.length;
|
|
190
190
|
var needed = len + 1;
|
|
191
|
-
if (_normBuf.length < needed) _normBuf = new Uint16Array(
|
|
191
|
+
if (_normBuf.length < needed) _normBuf = new Uint16Array(needed);
|
|
192
192
|
var outCodes = _normBuf;
|
|
193
193
|
var writePos = 0;
|
|
194
194
|
var pendingSpace = false;
|
|
@@ -294,6 +294,7 @@ function createJsonValueParser(onValue) {
|
|
|
294
294
|
nesting: 0,
|
|
295
295
|
inString: false,
|
|
296
296
|
escaped: false,
|
|
297
|
+
_consumed: 0,
|
|
297
298
|
feed: function(chunk) {
|
|
298
299
|
this.buffer += chunk;
|
|
299
300
|
var consumeUntil = 0;
|
|
@@ -325,6 +326,11 @@ function createJsonValueParser(onValue) {
|
|
|
325
326
|
if (code === CHAR_CLOSE_BRACKET || code === CHAR_CLOSE_BRACE) {
|
|
326
327
|
this.nesting--;
|
|
327
328
|
if (0 === this.nesting) {
|
|
329
|
+
if (index === this.start + 1) {
|
|
330
|
+
this.start = -1;
|
|
331
|
+
consumeUntil = index + 1;
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
328
334
|
var raw = this.buffer.slice(this.start, index + 1);
|
|
329
335
|
this.start = -1;
|
|
330
336
|
onValue(raw);
|
|
@@ -333,12 +339,19 @@ function createJsonValueParser(onValue) {
|
|
|
333
339
|
}
|
|
334
340
|
}
|
|
335
341
|
if (consumeUntil > 0) {
|
|
336
|
-
this.
|
|
337
|
-
this.readPos =
|
|
342
|
+
this._consumed = consumeUntil;
|
|
343
|
+
this.readPos = -1 !== this.start ? this.buffer.length : this._consumed;
|
|
344
|
+
if (this._consumed > 65536) {
|
|
345
|
+
if (-1 !== this.start) this.start -= this._consumed;
|
|
346
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
347
|
+
this.readPos = this.buffer.length;
|
|
348
|
+
this._consumed = 0;
|
|
349
|
+
}
|
|
338
350
|
} else this.readPos = this.buffer.length;
|
|
339
351
|
},
|
|
340
352
|
reset: function() {
|
|
341
353
|
this.buffer = "";
|
|
354
|
+
this._consumed = 0;
|
|
342
355
|
this.start = -1;
|
|
343
356
|
this.readPos = 0;
|
|
344
357
|
this.nesting = 0;
|
|
@@ -358,6 +371,7 @@ function createRowStreamParser(onRow) {
|
|
|
358
371
|
elementEnd: -1,
|
|
359
372
|
nesting: 0,
|
|
360
373
|
readPos: 0,
|
|
374
|
+
_consumed: 0,
|
|
361
375
|
feed: function(chunk) {
|
|
362
376
|
if (this.finished) return chunk;
|
|
363
377
|
this.buffer += chunk;
|
|
@@ -424,24 +438,38 @@ function createRowStreamParser(onRow) {
|
|
|
424
438
|
var delimiter = this.buffer.charCodeAt(lookAhead);
|
|
425
439
|
if (delimiter === CHAR_COMMA || delimiter === CHAR_CLOSE_BRACKET) {
|
|
426
440
|
onRow(this.buffer.slice(this.elementStart, this.elementEnd));
|
|
427
|
-
this.
|
|
441
|
+
this._consumed = lookAhead + 1;
|
|
428
442
|
this.elementStart = -1;
|
|
429
443
|
this.elementEnd = -1;
|
|
430
444
|
this.nesting = 0;
|
|
431
445
|
if (delimiter === CHAR_CLOSE_BRACKET) {
|
|
432
446
|
this.finished = true;
|
|
433
|
-
var tail = this.buffer;
|
|
447
|
+
var tail = this.buffer.slice(this._consumed);
|
|
434
448
|
this.buffer = "";
|
|
449
|
+
this._consumed = 0;
|
|
435
450
|
this.readPos = 0;
|
|
436
451
|
return tail;
|
|
437
452
|
}
|
|
438
|
-
index =
|
|
453
|
+
index = this._consumed;
|
|
454
|
+
if (this._consumed > 65536) {
|
|
455
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
456
|
+
index = 0;
|
|
457
|
+
this._consumed = 0;
|
|
458
|
+
}
|
|
439
459
|
continue;
|
|
440
460
|
}
|
|
441
461
|
}
|
|
442
462
|
}
|
|
443
463
|
index++;
|
|
444
464
|
}
|
|
465
|
+
if (this._consumed > 0) {
|
|
466
|
+
if (-1 !== this.elementStart) {
|
|
467
|
+
this.elementStart -= this._consumed;
|
|
468
|
+
if (-1 !== this.elementEnd) this.elementEnd -= this._consumed;
|
|
469
|
+
}
|
|
470
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
471
|
+
this._consumed = 0;
|
|
472
|
+
}
|
|
445
473
|
if (this.elementStart > 0) {
|
|
446
474
|
this.buffer = this.buffer.slice(this.elementStart);
|
|
447
475
|
if (-1 !== this.elementEnd) this.elementEnd -= this.elementStart;
|
|
@@ -452,6 +480,7 @@ function createRowStreamParser(onRow) {
|
|
|
452
480
|
},
|
|
453
481
|
reset: function() {
|
|
454
482
|
this.buffer = "";
|
|
483
|
+
this._consumed = 0;
|
|
455
484
|
this.started = false;
|
|
456
485
|
this.finished = false;
|
|
457
486
|
this.inString = false;
|
|
@@ -480,6 +509,22 @@ function stream_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
480
509
|
descriptor.value = value;
|
|
481
510
|
}
|
|
482
511
|
}
|
|
512
|
+
function _class_apply_descriptor_update(receiver, descriptor) {
|
|
513
|
+
if (descriptor.set) {
|
|
514
|
+
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
515
|
+
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
516
|
+
set value (v){
|
|
517
|
+
descriptor.set.call(receiver, v);
|
|
518
|
+
},
|
|
519
|
+
get value () {
|
|
520
|
+
return descriptor.get.call(receiver);
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
return descriptor.__destrWrapper;
|
|
524
|
+
}
|
|
525
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
526
|
+
return descriptor;
|
|
527
|
+
}
|
|
483
528
|
function stream_class_call_check(instance, Constructor) {
|
|
484
529
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
485
530
|
}
|
|
@@ -500,6 +545,10 @@ function stream_class_private_field_set(receiver, privateMap, value) {
|
|
|
500
545
|
stream_class_apply_descriptor_set(receiver, descriptor, value);
|
|
501
546
|
return value;
|
|
502
547
|
}
|
|
548
|
+
function _class_private_field_update(receiver, privateMap) {
|
|
549
|
+
var descriptor = stream_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
550
|
+
return _class_apply_descriptor_update(receiver, descriptor);
|
|
551
|
+
}
|
|
503
552
|
function stream_defineProperties(target, props) {
|
|
504
553
|
for(var i = 0; i < props.length; i++){
|
|
505
554
|
var descriptor = props[i];
|
|
@@ -536,7 +585,7 @@ function setupStreamParser(task) {
|
|
|
536
585
|
return parser;
|
|
537
586
|
}
|
|
538
587
|
_computedKey = Symbol.asyncIterator;
|
|
539
|
-
var _buffer = /*#__PURE__*/ new WeakMap(), _done = /*#__PURE__*/ new WeakMap(), _error = /*#__PURE__*/ new WeakMap(), _pending = /*#__PURE__*/ new WeakMap();
|
|
588
|
+
var _buffer = /*#__PURE__*/ new WeakMap(), _index = /*#__PURE__*/ new WeakMap(), _done = /*#__PURE__*/ new WeakMap(), _error = /*#__PURE__*/ new WeakMap(), _pending = /*#__PURE__*/ new WeakMap();
|
|
540
589
|
var _computedKey1 = _computedKey;
|
|
541
590
|
var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
542
591
|
"use strict";
|
|
@@ -546,6 +595,10 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
546
595
|
writable: true,
|
|
547
596
|
value: []
|
|
548
597
|
});
|
|
598
|
+
stream_class_private_field_init(this, _index, {
|
|
599
|
+
writable: true,
|
|
600
|
+
value: 0
|
|
601
|
+
});
|
|
549
602
|
stream_class_private_field_init(this, _done, {
|
|
550
603
|
writable: true,
|
|
551
604
|
value: false
|
|
@@ -563,6 +616,7 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
563
616
|
{
|
|
564
617
|
key: "push",
|
|
565
618
|
value: function(row) {
|
|
619
|
+
if (stream_class_private_field_get(this, _done) || stream_class_private_field_get(this, _error)) return;
|
|
566
620
|
if (stream_class_private_field_get(this, _pending)) {
|
|
567
621
|
var resolve = stream_class_private_field_get(this, _pending).resolve;
|
|
568
622
|
stream_class_private_field_set(this, _pending, null);
|
|
@@ -602,8 +656,8 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
602
656
|
key: "next",
|
|
603
657
|
value: function() {
|
|
604
658
|
var _this = this;
|
|
605
|
-
if (stream_class_private_field_get(this, _buffer).length
|
|
606
|
-
value: stream_class_private_field_get(this, _buffer)
|
|
659
|
+
if (stream_class_private_field_get(this, _index) < stream_class_private_field_get(this, _buffer).length) return Promise.resolve({
|
|
660
|
+
value: stream_class_private_field_get(this, _buffer)[_class_private_field_update(this, _index).value++],
|
|
607
661
|
done: false
|
|
608
662
|
});
|
|
609
663
|
if (stream_class_private_field_get(this, _done)) return Promise.resolve({
|
|
@@ -623,6 +677,8 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
623
677
|
key: "return",
|
|
624
678
|
value: function() {
|
|
625
679
|
stream_class_private_field_set(this, _done, true);
|
|
680
|
+
stream_class_private_field_set(this, _buffer, []);
|
|
681
|
+
stream_class_private_field_set(this, _index, 0);
|
|
626
682
|
if (stream_class_private_field_get(this, _pending)) {
|
|
627
683
|
var resolve = stream_class_private_field_get(this, _pending).resolve;
|
|
628
684
|
stream_class_private_field_set(this, _pending, null);
|
|
@@ -1162,13 +1218,14 @@ var _counter = 0;
|
|
|
1162
1218
|
var _PREFIX = "__executor_end__";
|
|
1163
1219
|
var _PID36 = process.pid.toString(36);
|
|
1164
1220
|
function generateToken() {
|
|
1165
|
-
|
|
1221
|
+
_counter = _counter + 1 >>> 0;
|
|
1222
|
+
return "".concat(_PREFIX).concat(_counter.toString(36), "_").concat(_PID36);
|
|
1166
1223
|
}
|
|
1167
1224
|
function escape_type_of(obj) {
|
|
1168
1225
|
return obj && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1169
1226
|
}
|
|
1170
1227
|
function escapeValue(value) {
|
|
1171
|
-
if ("string" == typeof value) return "'".concat(value.replace(/'/g, "''"), "'");
|
|
1228
|
+
if ("string" == typeof value) return value.includes("'") ? "'".concat(value.replace(/'/g, "''"), "'") : "'".concat(value, "'");
|
|
1172
1229
|
if (null == value) return "NULL";
|
|
1173
1230
|
if ("number" == typeof value || (void 0 === value ? "undefined" : escape_type_of(value)) === "bigint") return String(value);
|
|
1174
1231
|
if ("boolean" == typeof value) return value ? "TRUE" : "FALSE";
|
|
@@ -1297,10 +1354,11 @@ function classifySingle(stmt) {
|
|
|
1297
1354
|
return READ_ONLY_KINDS.has(kind) ? "read" : "write";
|
|
1298
1355
|
}
|
|
1299
1356
|
function classifySQL(sql) {
|
|
1300
|
-
if ("string" != typeof sql
|
|
1357
|
+
if ("string" != typeof sql) return "write";
|
|
1301
1358
|
var cached = _classifyCache.get(sql);
|
|
1302
1359
|
if (void 0 !== cached) return cached;
|
|
1303
1360
|
var trimmed = sql.trim();
|
|
1361
|
+
if (0 === trimmed.length) return "write";
|
|
1304
1362
|
var result;
|
|
1305
1363
|
if (trimmed.includes(";")) {
|
|
1306
1364
|
var stmts = trimmed.split(";");
|
|
@@ -1342,7 +1400,7 @@ function queue_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
1342
1400
|
descriptor.value = value;
|
|
1343
1401
|
}
|
|
1344
1402
|
}
|
|
1345
|
-
function
|
|
1403
|
+
function queue_class_apply_descriptor_update(receiver, descriptor) {
|
|
1346
1404
|
if (descriptor.set) {
|
|
1347
1405
|
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
1348
1406
|
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
@@ -1378,9 +1436,9 @@ function queue_class_private_field_set(receiver, privateMap, value) {
|
|
|
1378
1436
|
queue_class_apply_descriptor_set(receiver, descriptor, value);
|
|
1379
1437
|
return value;
|
|
1380
1438
|
}
|
|
1381
|
-
function
|
|
1439
|
+
function queue_class_private_field_update(receiver, privateMap) {
|
|
1382
1440
|
var descriptor = queue_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
1383
|
-
return
|
|
1441
|
+
return queue_class_apply_descriptor_update(receiver, descriptor);
|
|
1384
1442
|
}
|
|
1385
1443
|
function _class_private_method_get(receiver, privateSet, fn) {
|
|
1386
1444
|
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
@@ -1535,7 +1593,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1535
1593
|
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);
|
|
1536
1594
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _tail)] = value;
|
|
1537
1595
|
queue_class_private_field_set(this, _tail, queue_class_private_field_get(this, _tail) + 1 & queue_class_private_field_get(this, _mask));
|
|
1538
|
-
|
|
1596
|
+
queue_class_private_field_update(this, _size).value++;
|
|
1539
1597
|
}
|
|
1540
1598
|
},
|
|
1541
1599
|
{
|
|
@@ -1545,7 +1603,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1545
1603
|
var value = queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _head)];
|
|
1546
1604
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _head)] = void 0;
|
|
1547
1605
|
queue_class_private_field_set(this, _head, queue_class_private_field_get(this, _head) + 1 & queue_class_private_field_get(this, _mask));
|
|
1548
|
-
|
|
1606
|
+
queue_class_private_field_update(this, _size).value--;
|
|
1549
1607
|
return value;
|
|
1550
1608
|
}
|
|
1551
1609
|
},
|
|
@@ -1572,7 +1630,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1572
1630
|
}
|
|
1573
1631
|
queue_class_private_field_set(this, _tail, queue_class_private_field_get(this, _tail) - 1 & queue_class_private_field_get(this, _mask));
|
|
1574
1632
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _tail)] = void 0;
|
|
1575
|
-
|
|
1633
|
+
queue_class_private_field_update(this, _size).value--;
|
|
1576
1634
|
return true;
|
|
1577
1635
|
}
|
|
1578
1636
|
}
|
|
@@ -1724,7 +1782,7 @@ function buildPayload(sql, token) {
|
|
|
1724
1782
|
return "".concat(normalized).concat(suffix, "\nSELECT '").concat(token, "' AS ").concat(TOKEN_COLUMN, ";\n");
|
|
1725
1783
|
}
|
|
1726
1784
|
function isTransactionControl(sql) {
|
|
1727
|
-
var s = sql.
|
|
1785
|
+
var s = sql.toUpperCase();
|
|
1728
1786
|
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 ");
|
|
1729
1787
|
}
|
|
1730
1788
|
function buildBatchPayload(batch) {
|
|
@@ -1791,6 +1849,10 @@ function buildBatchPayload(batch) {
|
|
|
1791
1849
|
}
|
|
1792
1850
|
return parts1.join("");
|
|
1793
1851
|
}
|
|
1852
|
+
var TC_FIRST_CHAR = TOKEN_COLUMN.charCodeAt(0);
|
|
1853
|
+
function isSentinelRaw(raw, token) {
|
|
1854
|
+
return raw.charCodeAt(3) === TC_FIRST_CHAR && raw === '[{"'.concat(TOKEN_COLUMN, '":"').concat(token, '"}]');
|
|
1855
|
+
}
|
|
1794
1856
|
function isSentinelRow(value, token) {
|
|
1795
1857
|
var _value_;
|
|
1796
1858
|
return Array.isArray(value) && 1 === value.length && (null == (_value_ = value[0]) ? void 0 : _value_[TOKEN_COLUMN]) === token;
|
|
@@ -1855,7 +1917,6 @@ function settleTask(task, error, value, metrics) {
|
|
|
1855
1917
|
var _ref = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {}, _ref_resetRowParser = _ref.resetRowParser, resetRowParser = void 0 === _ref_resetRowParser ? false : _ref_resetRowParser;
|
|
1856
1918
|
if (task.settled) return;
|
|
1857
1919
|
task.settled = true;
|
|
1858
|
-
clearTimeout(task.timer);
|
|
1859
1920
|
if (resetRowParser) {
|
|
1860
1921
|
var _task_rowParser_reset, _task_rowParser;
|
|
1861
1922
|
null == (_task_rowParser = task.rowParser) || null == (_task_rowParser_reset = _task_rowParser.reset) || _task_rowParser_reset.call(_task_rowParser);
|
|
@@ -1869,6 +1930,44 @@ function settleTask(task, error, value, metrics) {
|
|
|
1869
1930
|
null == metrics || metrics.incrementTasksSuccess(duration);
|
|
1870
1931
|
task.resolve(value);
|
|
1871
1932
|
}
|
|
1933
|
+
function finalizePendingTasks(tasks, settle, pumpQueue) {
|
|
1934
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1935
|
+
try {
|
|
1936
|
+
for(var _iterator = tasks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1937
|
+
var task = _step.value;
|
|
1938
|
+
if (task.stderrText) {
|
|
1939
|
+
settle(task, new Error(task.stderrText.trim()), void 0);
|
|
1940
|
+
continue;
|
|
1941
|
+
}
|
|
1942
|
+
if (task.consumerError) {
|
|
1943
|
+
settle(task, task.consumerError, void 0);
|
|
1944
|
+
continue;
|
|
1945
|
+
}
|
|
1946
|
+
if ("query" === task.kind) {
|
|
1947
|
+
settle(task, null, task.rows);
|
|
1948
|
+
continue;
|
|
1949
|
+
}
|
|
1950
|
+
settle(task, null, void 0);
|
|
1951
|
+
}
|
|
1952
|
+
} catch (err) {
|
|
1953
|
+
_didIteratorError = true;
|
|
1954
|
+
_iteratorError = err;
|
|
1955
|
+
} finally{
|
|
1956
|
+
try {
|
|
1957
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1958
|
+
} finally{
|
|
1959
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
tasks.clear();
|
|
1963
|
+
pumpQueue();
|
|
1964
|
+
}
|
|
1965
|
+
function prepareTaskTimeout(task, metrics) {
|
|
1966
|
+
if (task.settled) return null;
|
|
1967
|
+
task.timedout = true;
|
|
1968
|
+
null == metrics || metrics.incrementTasksTimeout();
|
|
1969
|
+
return createTimeoutError(task.timeout, task.sql);
|
|
1970
|
+
}
|
|
1872
1971
|
function taskWorker_array_like_to_array(arr, len) {
|
|
1873
1972
|
if (null == len || len > arr.length) len = arr.length;
|
|
1874
1973
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -2024,7 +2123,7 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2024
2123
|
database: database,
|
|
2025
2124
|
initMode: initMode,
|
|
2026
2125
|
onDrain: function() {
|
|
2027
|
-
return taskWorker_class_private_method_get(_this, _pumpQueue,
|
|
2126
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
2028
2127
|
}
|
|
2029
2128
|
}));
|
|
2030
2129
|
taskWorker_class_private_field_set(this, _valueParser, createJsonValueParser(function(raw) {
|
|
@@ -2074,7 +2173,13 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2074
2173
|
};
|
|
2075
2174
|
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTotal(config.kind);
|
|
2076
2175
|
taskWorker_class_private_field_get(this, _pendingQueue).enqueue(task);
|
|
2077
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2176
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2177
|
+
}
|
|
2178
|
+
},
|
|
2179
|
+
{
|
|
2180
|
+
key: "_process",
|
|
2181
|
+
get: function() {
|
|
2182
|
+
return taskWorker_class_private_field_get(this, _processManager).process;
|
|
2078
2183
|
}
|
|
2079
2184
|
},
|
|
2080
2185
|
{
|
|
@@ -2108,7 +2213,7 @@ function startProcess() {
|
|
|
2108
2213
|
taskWorker_class_private_method_get(_this, _rejectAll, taskWorker_rejectAll).call(_this, err);
|
|
2109
2214
|
});
|
|
2110
2215
|
}
|
|
2111
|
-
function
|
|
2216
|
+
function taskWorker_pumpQueue() {
|
|
2112
2217
|
var _this = this;
|
|
2113
2218
|
var _$_class_private_field_get;
|
|
2114
2219
|
if (taskWorker_class_private_field_get(this, _processManager).draining) return;
|
|
@@ -2150,6 +2255,26 @@ function pumpQueue() {
|
|
|
2150
2255
|
function handleParsedValue(raw) {
|
|
2151
2256
|
var task = taskWorker_class_private_field_get(this, _inflightTasks)[0];
|
|
2152
2257
|
if (!task) return;
|
|
2258
|
+
if (isSentinelRaw(raw, task.token)) {
|
|
2259
|
+
clearTimeout(task.timer);
|
|
2260
|
+
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2261
|
+
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2262
|
+
if (task.stderrText) {
|
|
2263
|
+
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2264
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2267
|
+
if (task.consumerError) {
|
|
2268
|
+
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2269
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2270
|
+
return;
|
|
2271
|
+
}
|
|
2272
|
+
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2273
|
+
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2274
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
if ("[]" === raw) return;
|
|
2153
2278
|
var parsed;
|
|
2154
2279
|
try {
|
|
2155
2280
|
parsed = JSON.parse(raw);
|
|
@@ -2160,20 +2285,20 @@ function handleParsedValue(raw) {
|
|
|
2160
2285
|
if (isSentinelRow(parsed, task.token)) {
|
|
2161
2286
|
clearTimeout(task.timer);
|
|
2162
2287
|
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2163
|
-
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2288
|
+
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2164
2289
|
if (task.stderrText) {
|
|
2165
2290
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2166
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2291
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2167
2292
|
return;
|
|
2168
2293
|
}
|
|
2169
2294
|
if (task.consumerError) {
|
|
2170
2295
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2171
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2296
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2172
2297
|
return;
|
|
2173
2298
|
}
|
|
2174
2299
|
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2175
2300
|
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2176
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2301
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2177
2302
|
return;
|
|
2178
2303
|
}
|
|
2179
2304
|
if ("query" === task.kind) return void collectQueryRows(task, parsed);
|
|
@@ -2185,36 +2310,11 @@ function scheduleFinalizeCheck() {
|
|
|
2185
2310
|
taskWorker_class_private_field_set(this, _scheduledFinalize, true);
|
|
2186
2311
|
setImmediate(function() {
|
|
2187
2312
|
taskWorker_class_private_field_set(_this, _scheduledFinalize, false);
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, new Error(task.stderrText.trim()), void 0);
|
|
2194
|
-
continue;
|
|
2195
|
-
}
|
|
2196
|
-
if (task.consumerError) {
|
|
2197
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, task.consumerError, void 0);
|
|
2198
|
-
continue;
|
|
2199
|
-
}
|
|
2200
|
-
if ("query" === task.kind) {
|
|
2201
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, null, task.rows);
|
|
2202
|
-
continue;
|
|
2203
|
-
}
|
|
2204
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, null, void 0);
|
|
2205
|
-
}
|
|
2206
|
-
} catch (err) {
|
|
2207
|
-
_didIteratorError = true;
|
|
2208
|
-
_iteratorError = err;
|
|
2209
|
-
} finally{
|
|
2210
|
-
try {
|
|
2211
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2212
|
-
} finally{
|
|
2213
|
-
if (_didIteratorError) throw _iteratorError;
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
taskWorker_class_private_field_get(_this, _pendingFinalizeTasks).clear();
|
|
2217
|
-
taskWorker_class_private_method_get(_this, _pumpQueue, pumpQueue).call(_this);
|
|
2313
|
+
finalizePendingTasks(taskWorker_class_private_field_get(_this, _pendingFinalizeTasks), function(t, e, v1) {
|
|
2314
|
+
return taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, t, e, v1);
|
|
2315
|
+
}, function() {
|
|
2316
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
2317
|
+
});
|
|
2218
2318
|
});
|
|
2219
2319
|
}
|
|
2220
2320
|
function taskWorker_handleStderrChunk(chunk) {
|
|
@@ -2228,13 +2328,8 @@ function taskWorker_handleStderrChunk(chunk) {
|
|
|
2228
2328
|
task.stderrText += String(chunk);
|
|
2229
2329
|
}
|
|
2230
2330
|
function handleTaskTimeout(task) {
|
|
2231
|
-
var
|
|
2232
|
-
if (task
|
|
2233
|
-
task.timedout = true;
|
|
2234
|
-
clearTimeout(task.timer);
|
|
2235
|
-
task.timer = null;
|
|
2236
|
-
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTimeout();
|
|
2237
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, createTimeoutError(task.timeout, task.sql), void 0);
|
|
2331
|
+
var error = prepareTaskTimeout(task, taskWorker_class_private_field_get(this, _metrics));
|
|
2332
|
+
if (error) taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, error, void 0);
|
|
2238
2333
|
}
|
|
2239
2334
|
function settleTask1(task, error, value) {
|
|
2240
2335
|
settleTask(task, error, value, taskWorker_class_private_field_get(this, _metrics));
|
|
@@ -2288,21 +2383,12 @@ function readerPool_class_apply_descriptor_get(receiver, descriptor) {
|
|
|
2288
2383
|
if (descriptor.get) return descriptor.get.call(receiver);
|
|
2289
2384
|
return descriptor.value;
|
|
2290
2385
|
}
|
|
2291
|
-
function
|
|
2292
|
-
if (descriptor.set)
|
|
2293
|
-
|
|
2294
|
-
if (!("
|
|
2295
|
-
|
|
2296
|
-
descriptor.set.call(receiver, v);
|
|
2297
|
-
},
|
|
2298
|
-
get value () {
|
|
2299
|
-
return descriptor.get.call(receiver);
|
|
2300
|
-
}
|
|
2301
|
-
};
|
|
2302
|
-
return descriptor.__destrWrapper;
|
|
2386
|
+
function readerPool_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
2387
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
2388
|
+
else {
|
|
2389
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
2390
|
+
descriptor.value = value;
|
|
2303
2391
|
}
|
|
2304
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
2305
|
-
return descriptor;
|
|
2306
2392
|
}
|
|
2307
2393
|
function readerPool_class_call_check(instance, Constructor) {
|
|
2308
2394
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
@@ -2319,9 +2405,10 @@ function readerPool_class_private_field_init(obj, privateMap, value) {
|
|
|
2319
2405
|
readerPool_check_private_redeclaration(obj, privateMap);
|
|
2320
2406
|
privateMap.set(obj, value);
|
|
2321
2407
|
}
|
|
2322
|
-
function
|
|
2323
|
-
var descriptor = readerPool_class_extract_field_descriptor(receiver, privateMap, "
|
|
2324
|
-
|
|
2408
|
+
function readerPool_class_private_field_set(receiver, privateMap, value) {
|
|
2409
|
+
var descriptor = readerPool_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
2410
|
+
readerPool_class_apply_descriptor_set(receiver, descriptor, value);
|
|
2411
|
+
return value;
|
|
2325
2412
|
}
|
|
2326
2413
|
function readerPool_defineProperties(target, props) {
|
|
2327
2414
|
for(var i = 0; i < props.length; i++){
|
|
@@ -2351,6 +2438,7 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2351
2438
|
writable: true,
|
|
2352
2439
|
value: 0
|
|
2353
2440
|
});
|
|
2441
|
+
if (poolSize < 1) throw new RangeError("poolSize must be >= 1");
|
|
2354
2442
|
for(var i = 0; i < poolSize; i++){
|
|
2355
2443
|
var worker = new taskWorker_TaskWorker({
|
|
2356
2444
|
binary: binary,
|
|
@@ -2383,10 +2471,16 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2383
2471
|
key: "enqueue",
|
|
2384
2472
|
value: function(task) {
|
|
2385
2473
|
var worker = readerPool_class_private_field_get(this, _workers)[readerPool_class_private_field_get(this, _rrIndex) % readerPool_class_private_field_get(this, _workers).length];
|
|
2386
|
-
|
|
2474
|
+
readerPool_class_private_field_set(this, _rrIndex, readerPool_class_private_field_get(this, _rrIndex) + 1 >>> 0);
|
|
2387
2475
|
worker.enqueue(task);
|
|
2388
2476
|
}
|
|
2389
2477
|
},
|
|
2478
|
+
{
|
|
2479
|
+
key: "_workers",
|
|
2480
|
+
get: function() {
|
|
2481
|
+
return readerPool_class_private_field_get(this, _workers);
|
|
2482
|
+
}
|
|
2483
|
+
},
|
|
2390
2484
|
{
|
|
2391
2485
|
key: "kill",
|
|
2392
2486
|
value: function() {
|
|
@@ -2999,16 +3093,17 @@ function pipelineEngine_unsupported_iterable_to_array(o, minLen) {
|
|
|
2999
3093
|
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
3000
3094
|
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return pipelineEngine_array_like_to_array(o, minLen);
|
|
3001
3095
|
}
|
|
3002
|
-
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();
|
|
3096
|
+
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();
|
|
3003
3097
|
var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
3004
3098
|
"use strict";
|
|
3005
3099
|
function PipelineEngine(processManager, param) {
|
|
3006
3100
|
var _this = this;
|
|
3007
|
-
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;
|
|
3101
|
+
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;
|
|
3008
3102
|
pipelineEngine_class_call_check(this, PipelineEngine);
|
|
3009
3103
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_pumpQueue);
|
|
3010
3104
|
pipelineEngine_class_private_method_init(this, pipelineEngine_handleParsedValue);
|
|
3011
3105
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_scheduleFinalizeCheck);
|
|
3106
|
+
pipelineEngine_class_private_method_init(this, _scheduleSweep);
|
|
3012
3107
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_handleTaskTimeout);
|
|
3013
3108
|
pipelineEngine_class_private_method_init(this, pipelineEngine_settleTask);
|
|
3014
3109
|
pipelineEngine_class_private_field_init(this, _queue, {
|
|
@@ -3063,6 +3158,14 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3063
3158
|
writable: true,
|
|
3064
3159
|
value: false
|
|
3065
3160
|
});
|
|
3161
|
+
pipelineEngine_class_private_field_init(this, _sweepTimer, {
|
|
3162
|
+
writable: true,
|
|
3163
|
+
value: null
|
|
3164
|
+
});
|
|
3165
|
+
pipelineEngine_class_private_field_init(this, _sweepIntervalMs, {
|
|
3166
|
+
writable: true,
|
|
3167
|
+
value: void 0
|
|
3168
|
+
});
|
|
3066
3169
|
pipelineEngine_class_private_field_set(this, pipelineEngine_processManager, processManager);
|
|
3067
3170
|
pipelineEngine_class_private_field_set(this, pipelineEngine_metrics, metrics);
|
|
3068
3171
|
pipelineEngine_class_private_field_set(this, pipelineEngine_statementTimeout, statementTimeout);
|
|
@@ -3076,8 +3179,15 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3076
3179
|
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).setOnDrainCallback(function() {
|
|
3077
3180
|
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3078
3181
|
});
|
|
3182
|
+
pipelineEngine_class_private_field_set(this, _sweepIntervalMs, sweepInterval);
|
|
3079
3183
|
}
|
|
3080
3184
|
pipelineEngine_create_class(PipelineEngine, [
|
|
3185
|
+
{
|
|
3186
|
+
key: "_sweepTimer",
|
|
3187
|
+
get: function() {
|
|
3188
|
+
return pipelineEngine_class_private_field_get(this, _sweepTimer);
|
|
3189
|
+
}
|
|
3190
|
+
},
|
|
3081
3191
|
{
|
|
3082
3192
|
key: "mainQueue",
|
|
3083
3193
|
get: function() {
|
|
@@ -3128,7 +3238,7 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3128
3238
|
value: function(chunk) {
|
|
3129
3239
|
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[0];
|
|
3130
3240
|
if (!task) return;
|
|
3131
|
-
if ("stream" === task.kind && task.rowParser && !task.rowParser.finished) {
|
|
3241
|
+
if ("stream" === task.kind && task.rowParser && !task.rowParser.finished && !task.timedout) {
|
|
3132
3242
|
var leftover = task.rowParser.feed(chunk);
|
|
3133
3243
|
if (leftover) pipelineEngine_class_private_field_get(this, _sharedValueParser).feed(leftover);
|
|
3134
3244
|
return;
|
|
@@ -3152,6 +3262,7 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3152
3262
|
{
|
|
3153
3263
|
key: "rejectAll",
|
|
3154
3264
|
value: function(error) {
|
|
3265
|
+
pipelineEngine_class_private_field_get(this, _sharedValueParser).reset();
|
|
3155
3266
|
var all = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks);
|
|
3156
3267
|
pipelineEngine_class_private_field_set(this, pipelineEngine_inflightTasks, []);
|
|
3157
3268
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
@@ -3198,6 +3309,8 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3198
3309
|
key: "kill",
|
|
3199
3310
|
value: function() {
|
|
3200
3311
|
pipelineEngine_class_private_field_set(this, _active, false);
|
|
3312
|
+
clearTimeout(pipelineEngine_class_private_field_get(this, _sweepTimer));
|
|
3313
|
+
pipelineEngine_class_private_field_set(this, _sweepTimer, null);
|
|
3201
3314
|
this.rejectAll(new Error("PipelineEngine is killed"));
|
|
3202
3315
|
}
|
|
3203
3316
|
}
|
|
@@ -3205,7 +3318,6 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3205
3318
|
return PipelineEngine;
|
|
3206
3319
|
}();
|
|
3207
3320
|
function pipelineEngine_pumpQueue() {
|
|
3208
|
-
var _this = this;
|
|
3209
3321
|
var _$_class_private_field_get;
|
|
3210
3322
|
if (!pipelineEngine_class_private_field_get(this, _active)) return;
|
|
3211
3323
|
if (pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).draining) return;
|
|
@@ -3222,14 +3334,10 @@ function pipelineEngine_pumpQueue() {
|
|
|
3222
3334
|
var payload = buildBatchPayload(batch);
|
|
3223
3335
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
3224
3336
|
try {
|
|
3225
|
-
var
|
|
3226
|
-
var
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_handleTaskTimeout, pipelineEngine_handleTaskTimeout).call(_this, task);
|
|
3230
|
-
}, task.timeout);
|
|
3231
|
-
};
|
|
3232
|
-
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
3337
|
+
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3338
|
+
var task1 = _step.value;
|
|
3339
|
+
task1.startTime = now;
|
|
3340
|
+
}
|
|
3233
3341
|
} catch (err) {
|
|
3234
3342
|
_didIteratorError = true;
|
|
3235
3343
|
_iteratorError = err;
|
|
@@ -3241,11 +3349,26 @@ function pipelineEngine_pumpQueue() {
|
|
|
3241
3349
|
}
|
|
3242
3350
|
}
|
|
3243
3351
|
(_$_class_private_field_get = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)).push.apply(_$_class_private_field_get, pipelineEngine_to_consumable_array(batch));
|
|
3352
|
+
pipelineEngine_class_private_method_get(this, _scheduleSweep, scheduleSweep).call(this);
|
|
3244
3353
|
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).write(payload);
|
|
3245
3354
|
}
|
|
3246
3355
|
function core_pipelineEngine_handleParsedValue(raw) {
|
|
3247
3356
|
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[0];
|
|
3248
3357
|
if (!task) return;
|
|
3358
|
+
if (isSentinelRaw(raw, task.token)) {
|
|
3359
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3360
|
+
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3361
|
+
if (task.consumerError) {
|
|
3362
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
3363
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3364
|
+
return;
|
|
3365
|
+
}
|
|
3366
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).add(task);
|
|
3367
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_scheduleFinalizeCheck, pipelineEngine_scheduleFinalizeCheck).call(this);
|
|
3368
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3369
|
+
return;
|
|
3370
|
+
}
|
|
3371
|
+
if ("[]" === raw) return;
|
|
3249
3372
|
var parsed;
|
|
3250
3373
|
try {
|
|
3251
3374
|
parsed = JSON.parse(raw);
|
|
@@ -3254,7 +3377,6 @@ function core_pipelineEngine_handleParsedValue(raw) {
|
|
|
3254
3377
|
return;
|
|
3255
3378
|
}
|
|
3256
3379
|
if (isSentinelRow(parsed, task.token)) {
|
|
3257
|
-
clearTimeout(task.timer);
|
|
3258
3380
|
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3259
3381
|
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3260
3382
|
if (task.consumerError) {
|
|
@@ -3277,44 +3399,34 @@ function pipelineEngine_scheduleFinalizeCheck() {
|
|
|
3277
3399
|
pipelineEngine_class_private_field_set(this, pipelineEngine_scheduledFinalize, true);
|
|
3278
3400
|
setImmediate(function() {
|
|
3279
3401
|
pipelineEngine_class_private_field_set(_this, pipelineEngine_scheduledFinalize, false);
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, new Error(task.stderrText.trim()), void 0);
|
|
3286
|
-
continue;
|
|
3287
|
-
}
|
|
3288
|
-
if (task.consumerError) {
|
|
3289
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, task.consumerError, void 0);
|
|
3290
|
-
continue;
|
|
3291
|
-
}
|
|
3292
|
-
if ("query" === task.kind) {
|
|
3293
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, null, task.rows);
|
|
3294
|
-
continue;
|
|
3295
|
-
}
|
|
3296
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, null, void 0);
|
|
3297
|
-
}
|
|
3298
|
-
} catch (err) {
|
|
3299
|
-
_didIteratorError = true;
|
|
3300
|
-
_iteratorError = err;
|
|
3301
|
-
} finally{
|
|
3302
|
-
try {
|
|
3303
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
3304
|
-
} finally{
|
|
3305
|
-
if (_didIteratorError) throw _iteratorError;
|
|
3306
|
-
}
|
|
3307
|
-
}
|
|
3308
|
-
pipelineEngine_class_private_field_get(_this, pipelineEngine_pendingFinalizeTasks).clear();
|
|
3402
|
+
finalizePendingTasks(pipelineEngine_class_private_field_get(_this, pipelineEngine_pendingFinalizeTasks), function(t, e, v1) {
|
|
3403
|
+
return pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, t, e, v1);
|
|
3404
|
+
}, function() {
|
|
3405
|
+
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3406
|
+
});
|
|
3309
3407
|
});
|
|
3310
3408
|
}
|
|
3409
|
+
function scheduleSweep() {
|
|
3410
|
+
var _this = this;
|
|
3411
|
+
if (pipelineEngine_class_private_field_get(this, _sweepTimer)) return;
|
|
3412
|
+
pipelineEngine_class_private_field_set(this, _sweepTimer, setTimeout(function() {
|
|
3413
|
+
pipelineEngine_class_private_field_set(_this, _sweepTimer, null);
|
|
3414
|
+
var inflight = pipelineEngine_class_private_field_get(_this, pipelineEngine_inflightTasks);
|
|
3415
|
+
var now = performance.now();
|
|
3416
|
+
for(var i = 0; i < inflight.length; i++){
|
|
3417
|
+
var task = inflight[i];
|
|
3418
|
+
if (now - task.startTime > task.timeout) pipelineEngine_class_private_method_get(_this, core_pipelineEngine_handleTaskTimeout, pipelineEngine_handleTaskTimeout).call(_this, task);
|
|
3419
|
+
}
|
|
3420
|
+
if (pipelineEngine_class_private_field_get(_this, pipelineEngine_inflightTasks).length > 0) pipelineEngine_class_private_method_get(_this, _scheduleSweep, scheduleSweep).call(_this);
|
|
3421
|
+
}, pipelineEngine_class_private_field_get(this, _sweepIntervalMs)).unref());
|
|
3422
|
+
}
|
|
3311
3423
|
function pipelineEngine_handleTaskTimeout(task) {
|
|
3312
3424
|
var _this, _this1;
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3425
|
+
var error = prepareTaskTimeout(task, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics));
|
|
3426
|
+
if (error) {
|
|
3427
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, error, void 0);
|
|
3428
|
+
null == (_this = pipelineEngine_class_private_field_get(_this1 = this, _onTaskTimeout)) || _this.call(_this1, task);
|
|
3429
|
+
}
|
|
3318
3430
|
}
|
|
3319
3431
|
function pipelineEngine_settleTask1(task, error, value) {
|
|
3320
3432
|
settleTask(task, error, value, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics), {
|
|
@@ -3543,7 +3655,6 @@ var _computedKey2 = executor_computedKey;
|
|
|
3543
3655
|
var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
3544
3656
|
"use strict";
|
|
3545
3657
|
function SQLiteExecutor() {
|
|
3546
|
-
var _this = this;
|
|
3547
3658
|
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;
|
|
3548
3659
|
executor_class_call_check(this, SQLiteExecutor);
|
|
3549
3660
|
executor_class_private_method_init(this, _normalizeTimeout);
|
|
@@ -3623,9 +3734,7 @@ var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
|
3623
3734
|
metrics: executor_class_private_field_get(this, executor_metrics),
|
|
3624
3735
|
statementTimeout: executor_class_private_field_get(this, executor_statementTimeout),
|
|
3625
3736
|
logger: executor_class_private_field_get(this, executor_logger),
|
|
3626
|
-
onTaskTimeout: function(
|
|
3627
|
-
executor_class_private_field_get(_this, executor_metrics).incrementTasksTimeout();
|
|
3628
|
-
}
|
|
3737
|
+
onTaskTimeout: function() {}
|
|
3629
3738
|
}));
|
|
3630
3739
|
executor_class_private_method_get(this, executor_startProcess, core_executor_startProcess).call(this);
|
|
3631
3740
|
if (poolSize > 0 && ":memory:" !== database) executor_class_private_field_set(this, _readerPool, new readerPool_ReaderPool({
|
|
@@ -3652,6 +3761,12 @@ var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
|
3652
3761
|
return executor_class_private_field_get(this, _readerPool);
|
|
3653
3762
|
}
|
|
3654
3763
|
},
|
|
3764
|
+
{
|
|
3765
|
+
key: "_process",
|
|
3766
|
+
get: function() {
|
|
3767
|
+
return executor_class_private_field_get(this, executor_proc);
|
|
3768
|
+
}
|
|
3769
|
+
},
|
|
3655
3770
|
{
|
|
3656
3771
|
key: "metrics",
|
|
3657
3772
|
get: function() {
|
|
@@ -3944,9 +4059,9 @@ function enqueueWriter(kind, sql, timeout, token, onRow, scopeId) {
|
|
|
3944
4059
|
settled: false,
|
|
3945
4060
|
timer: null,
|
|
3946
4061
|
startTime: 0,
|
|
3947
|
-
rowParser: null
|
|
4062
|
+
rowParser: null,
|
|
4063
|
+
rows: "query" === kind ? [] : null
|
|
3948
4064
|
};
|
|
3949
|
-
if ("query" === kind) task.rows = [];
|
|
3950
4065
|
if ("stream" === kind) task.rowParser = setupStreamParser(task, executor_class_private_field_get(_this, _pipeline));
|
|
3951
4066
|
if (executor_class_private_field_get(_this, _txScope).isDeferred(scopeId)) executor_class_private_field_get(_this, _txScope).defer(task);
|
|
3952
4067
|
else executor_class_private_field_get(_this, _pipeline).enqueue(task);
|