@sentio/runtime 2.57.12-rc.1 → 2.57.12-rc.aaa
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/lib/{chunk-NY5XOHBY.js → chunk-DYOBLZD3.js} +85 -227
- package/lib/{chunk-NY5XOHBY.js.map → chunk-DYOBLZD3.js.map} +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.d.ts +33 -0
- package/lib/processor-runner.js +1863 -185
- package/lib/processor-runner.js.map +1 -1
- package/package.json +29 -4
- package/src/processor-runner.ts +12 -4
- package/src/service-manager.ts +263 -0
- package/src/service-worker.ts +116 -0
- package/src/service.ts +1 -1
package/lib/processor-runner.js
CHANGED
@@ -6,16 +6,19 @@ import {
|
|
6
6
|
Endpoints,
|
7
7
|
ExecutionConfig,
|
8
8
|
GLOBAL_CONFIG,
|
9
|
+
HandlerType,
|
9
10
|
INVALID_SPAN_CONTEXT,
|
10
11
|
LRUCache,
|
11
12
|
PluginManager,
|
12
13
|
ProcessConfigResponse,
|
14
|
+
ProcessResult,
|
13
15
|
ProcessorDefinition,
|
14
16
|
ProcessorServiceImpl,
|
15
17
|
ProxyTracerProvider,
|
16
18
|
SamplingDecision,
|
17
19
|
SpanKind,
|
18
20
|
SpanStatusCode,
|
21
|
+
StoreContext,
|
19
22
|
TraceFlags,
|
20
23
|
ValueType,
|
21
24
|
__commonJS,
|
@@ -30,24 +33,30 @@ import {
|
|
30
33
|
createContextKey,
|
31
34
|
createNoopMeter,
|
32
35
|
diag,
|
36
|
+
errorString,
|
33
37
|
es_exports,
|
34
38
|
esm_exports,
|
39
|
+
from,
|
35
40
|
init_es,
|
36
41
|
init_esm,
|
37
42
|
isSpanContextValid,
|
38
43
|
isValidSpanId,
|
39
44
|
isValidTraceId,
|
45
|
+
mergeProcessResults,
|
40
46
|
metrics,
|
41
47
|
parseSemver,
|
48
|
+
processMetrics,
|
42
49
|
propagation,
|
50
|
+
require_cjs,
|
43
51
|
require_lib,
|
44
52
|
require_lib2,
|
45
53
|
require_lib3,
|
46
54
|
require_lodash,
|
47
55
|
require_minimal,
|
48
56
|
require_src,
|
49
|
-
trace
|
50
|
-
|
57
|
+
trace,
|
58
|
+
withAbort
|
59
|
+
} from "./chunk-DYOBLZD3.js";
|
51
60
|
|
52
61
|
// ../../node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js
|
53
62
|
var require_universalify = __commonJS({
|
@@ -145,15 +154,15 @@ var require_polyfills = __commonJS({
|
|
145
154
|
}
|
146
155
|
if (platform === "win32") {
|
147
156
|
fs3.rename = typeof fs3.rename !== "function" ? fs3.rename : function(fs$rename) {
|
148
|
-
function rename(
|
157
|
+
function rename(from2, to, cb) {
|
149
158
|
var start = Date.now();
|
150
159
|
var backoff = 0;
|
151
|
-
fs$rename(
|
160
|
+
fs$rename(from2, to, function CB(er) {
|
152
161
|
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
153
162
|
setTimeout(function() {
|
154
163
|
fs3.stat(to, function(stater, st) {
|
155
164
|
if (stater && stater.code === "ENOENT")
|
156
|
-
fs$rename(
|
165
|
+
fs$rename(from2, to, CB);
|
157
166
|
else
|
158
167
|
cb(er);
|
159
168
|
});
|
@@ -2040,7 +2049,7 @@ var require_move = __commonJS({
|
|
2040
2049
|
var { mkdirp } = require_mkdirs();
|
2041
2050
|
var { pathExists } = require_path_exists();
|
2042
2051
|
var stat = require_stat();
|
2043
|
-
async function
|
2052
|
+
async function move2(src, dest, opts = {}) {
|
2044
2053
|
const overwrite = opts.overwrite || opts.clobber || false;
|
2045
2054
|
const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, "move", opts);
|
2046
2055
|
await stat.checkParentPaths(src, srcStat, dest, "move");
|
@@ -2077,7 +2086,7 @@ var require_move = __commonJS({
|
|
2077
2086
|
await copy(src, dest, opts);
|
2078
2087
|
return remove(src);
|
2079
2088
|
}
|
2080
|
-
module.exports =
|
2089
|
+
module.exports = move2;
|
2081
2090
|
}
|
2082
2091
|
});
|
2083
2092
|
|
@@ -5111,10 +5120,10 @@ var require_supports_colors = __commonJS({
|
|
5111
5120
|
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
5112
5121
|
}
|
5113
5122
|
if ("TERM_PROGRAM" in env) {
|
5114
|
-
var
|
5123
|
+
var version2 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
5115
5124
|
switch (env.TERM_PROGRAM) {
|
5116
5125
|
case "iTerm.app":
|
5117
|
-
return
|
5126
|
+
return version2 >= 3 ? 3 : 2;
|
5118
5127
|
case "Hyper":
|
5119
5128
|
return 3;
|
5120
5129
|
case "Apple_Terminal":
|
@@ -8810,7 +8819,7 @@ var require_from = __commonJS({
|
|
8810
8819
|
return (hint === "string" ? String : Number)(input);
|
8811
8820
|
}
|
8812
8821
|
var ERR_INVALID_ARG_TYPE = require_errors2().codes.ERR_INVALID_ARG_TYPE;
|
8813
|
-
function
|
8822
|
+
function from2(Readable2, iterable, opts) {
|
8814
8823
|
var iterator;
|
8815
8824
|
if (iterable && typeof iterable.next === "function") {
|
8816
8825
|
iterator = iterable;
|
@@ -8849,7 +8858,7 @@ var require_from = __commonJS({
|
|
8849
8858
|
}
|
8850
8859
|
return readable;
|
8851
8860
|
}
|
8852
|
-
module.exports =
|
8861
|
+
module.exports = from2;
|
8853
8862
|
}
|
8854
8863
|
});
|
8855
8864
|
|
@@ -8893,7 +8902,7 @@ var require_stream_readable = __commonJS({
|
|
8893
8902
|
var ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
|
8894
8903
|
var StringDecoder;
|
8895
8904
|
var createReadableStreamAsyncIterator;
|
8896
|
-
var
|
8905
|
+
var from2;
|
8897
8906
|
require_inherits()(Readable2, Stream);
|
8898
8907
|
var errorOrDestroy = destroyImpl.errorOrDestroy;
|
8899
8908
|
var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
|
@@ -9571,10 +9580,10 @@ var require_stream_readable = __commonJS({
|
|
9571
9580
|
}
|
9572
9581
|
if (typeof Symbol === "function") {
|
9573
9582
|
Readable2.from = function(iterable, opts) {
|
9574
|
-
if (
|
9575
|
-
|
9583
|
+
if (from2 === void 0) {
|
9584
|
+
from2 = require_from();
|
9576
9585
|
}
|
9577
|
-
return
|
9586
|
+
return from2(Readable2, iterable, opts);
|
9578
9587
|
};
|
9579
9588
|
}
|
9580
9589
|
function indexOf(xs, x) {
|
@@ -11143,8 +11152,8 @@ var require_pipeline = __commonJS({
|
|
11143
11152
|
function call(fn) {
|
11144
11153
|
fn();
|
11145
11154
|
}
|
11146
|
-
function pipe(
|
11147
|
-
return
|
11155
|
+
function pipe(from2, to) {
|
11156
|
+
return from2.pipe(to);
|
11148
11157
|
}
|
11149
11158
|
function popCallback(streams) {
|
11150
11159
|
if (!streams.length) return noop;
|
@@ -12604,9 +12613,9 @@ var require_route = __commonJS({
|
|
12604
12613
|
}
|
12605
12614
|
return graph;
|
12606
12615
|
}
|
12607
|
-
function link(
|
12616
|
+
function link(from2, to) {
|
12608
12617
|
return function(args) {
|
12609
|
-
return to(
|
12618
|
+
return to(from2(args));
|
12610
12619
|
};
|
12611
12620
|
}
|
12612
12621
|
function wrapConversion(toModel, graph) {
|
@@ -17505,14 +17514,14 @@ var init_callback = __esm({
|
|
17505
17514
|
}
|
17506
17515
|
return ar;
|
17507
17516
|
};
|
17508
|
-
__spreadArray = function(to,
|
17509
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
17510
|
-
if (ar || !(i in
|
17511
|
-
if (!ar) ar = Array.prototype.slice.call(
|
17512
|
-
ar[i] =
|
17517
|
+
__spreadArray = function(to, from2, pack) {
|
17518
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
17519
|
+
if (ar || !(i in from2)) {
|
17520
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
17521
|
+
ar[i] = from2[i];
|
17513
17522
|
}
|
17514
17523
|
}
|
17515
|
-
return to.concat(ar || Array.prototype.slice.call(
|
17524
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
17516
17525
|
};
|
17517
17526
|
BindOnceFuture = /** @class */
|
17518
17527
|
function() {
|
@@ -18368,14 +18377,14 @@ var init_utils3 = __esm({
|
|
18368
18377
|
}
|
18369
18378
|
return ar;
|
18370
18379
|
};
|
18371
|
-
__spreadArray2 = function(to,
|
18372
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
18373
|
-
if (ar || !(i in
|
18374
|
-
if (!ar) ar = Array.prototype.slice.call(
|
18375
|
-
ar[i] =
|
18380
|
+
__spreadArray2 = function(to, from2, pack) {
|
18381
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
18382
|
+
if (ar || !(i in from2)) {
|
18383
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
18384
|
+
ar[i] = from2[i];
|
18376
18385
|
}
|
18377
18386
|
}
|
18378
|
-
return to.concat(ar || Array.prototype.slice.call(
|
18387
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
18379
18388
|
};
|
18380
18389
|
__values5 = function(o) {
|
18381
18390
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
@@ -18691,14 +18700,14 @@ var init_Buckets = __esm({
|
|
18691
18700
|
}
|
18692
18701
|
return ar;
|
18693
18702
|
};
|
18694
|
-
__spreadArray3 = function(to,
|
18695
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
18696
|
-
if (ar || !(i in
|
18697
|
-
if (!ar) ar = Array.prototype.slice.call(
|
18698
|
-
ar[i] =
|
18703
|
+
__spreadArray3 = function(to, from2, pack) {
|
18704
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
18705
|
+
if (ar || !(i in from2)) {
|
18706
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
18707
|
+
ar[i] = from2[i];
|
18699
18708
|
}
|
18700
18709
|
}
|
18701
|
-
return to.concat(ar || Array.prototype.slice.call(
|
18710
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
18702
18711
|
};
|
18703
18712
|
Buckets = /** @class */
|
18704
18713
|
function() {
|
@@ -18793,11 +18802,11 @@ var init_Buckets = __esm({
|
|
18793
18802
|
var inpos = 0;
|
18794
18803
|
var outpos = 0;
|
18795
18804
|
for (var pos = this.indexStart; pos <= this.indexEnd; ) {
|
18796
|
-
var
|
18797
|
-
if (
|
18798
|
-
|
18805
|
+
var mod2 = pos % each;
|
18806
|
+
if (mod2 < 0) {
|
18807
|
+
mod2 += each;
|
18799
18808
|
}
|
18800
|
-
for (var i =
|
18809
|
+
for (var i = mod2; i < each && inpos < size; i++) {
|
18801
18810
|
this._relocateBucket(outpos, inpos);
|
18802
18811
|
inpos++;
|
18803
18812
|
pos++;
|
@@ -18864,11 +18873,11 @@ var init_Buckets = __esm({
|
|
18864
18873
|
tmp.splice.apply(tmp, __spreadArray3([0, oldPositiveLimit], __read8(this._counts.slice(0, oldPositiveLimit)), false));
|
18865
18874
|
this._counts = tmp;
|
18866
18875
|
};
|
18867
|
-
BucketsBacking2.prototype.reverse = function(
|
18868
|
-
var num = Math.floor((
|
18876
|
+
BucketsBacking2.prototype.reverse = function(from2, limit) {
|
18877
|
+
var num = Math.floor((from2 + limit) / 2) - from2;
|
18869
18878
|
for (var i = 0; i < num; i++) {
|
18870
|
-
var tmp = this._counts[
|
18871
|
-
this._counts[
|
18879
|
+
var tmp = this._counts[from2 + i];
|
18880
|
+
this._counts[from2 + i] = this._counts[limit - i - 1];
|
18872
18881
|
this._counts[limit - i - 1] = tmp;
|
18873
18882
|
}
|
18874
18883
|
};
|
@@ -20116,14 +20125,14 @@ var init_MetricReader = __esm({
|
|
20116
20125
|
}
|
20117
20126
|
return ar;
|
20118
20127
|
};
|
20119
|
-
__spreadArray4 = function(to,
|
20120
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
20121
|
-
if (ar || !(i in
|
20122
|
-
if (!ar) ar = Array.prototype.slice.call(
|
20123
|
-
ar[i] =
|
20128
|
+
__spreadArray4 = function(to, from2, pack) {
|
20129
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
20130
|
+
if (ar || !(i in from2)) {
|
20131
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
20132
|
+
ar[i] = from2[i];
|
20124
20133
|
}
|
20125
20134
|
}
|
20126
|
-
return to.concat(ar || Array.prototype.slice.call(
|
20135
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
20127
20136
|
};
|
20128
20137
|
MetricReader = /** @class */
|
20129
20138
|
function() {
|
@@ -20404,14 +20413,14 @@ var init_PeriodicExportingMetricReader = __esm({
|
|
20404
20413
|
}
|
20405
20414
|
return ar;
|
20406
20415
|
};
|
20407
|
-
__spreadArray5 = function(to,
|
20408
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
20409
|
-
if (ar || !(i in
|
20410
|
-
if (!ar) ar = Array.prototype.slice.call(
|
20411
|
-
ar[i] =
|
20416
|
+
__spreadArray5 = function(to, from2, pack) {
|
20417
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
20418
|
+
if (ar || !(i in from2)) {
|
20419
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
20420
|
+
ar[i] = from2[i];
|
20412
20421
|
}
|
20413
20422
|
}
|
20414
|
-
return to.concat(ar || Array.prototype.slice.call(
|
20423
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
20415
20424
|
};
|
20416
20425
|
PeriodicExportingMetricReader = /** @class */
|
20417
20426
|
function(_super) {
|
@@ -21897,14 +21906,14 @@ var init_ObservableRegistry = __esm({
|
|
21897
21906
|
}
|
21898
21907
|
return ar;
|
21899
21908
|
};
|
21900
|
-
__spreadArray6 = function(to,
|
21901
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
21902
|
-
if (ar || !(i in
|
21903
|
-
if (!ar) ar = Array.prototype.slice.call(
|
21904
|
-
ar[i] =
|
21909
|
+
__spreadArray6 = function(to, from2, pack) {
|
21910
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
21911
|
+
if (ar || !(i in from2)) {
|
21912
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
21913
|
+
ar[i] = from2[i];
|
21905
21914
|
}
|
21906
21915
|
}
|
21907
|
-
return to.concat(ar || Array.prototype.slice.call(
|
21916
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
21908
21917
|
};
|
21909
21918
|
ObservableRegistry = /** @class */
|
21910
21919
|
function() {
|
@@ -22556,14 +22565,14 @@ var init_MetricCollector = __esm({
|
|
22556
22565
|
}
|
22557
22566
|
return ar;
|
22558
22567
|
};
|
22559
|
-
__spreadArray7 = function(to,
|
22560
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
22561
|
-
if (ar || !(i in
|
22562
|
-
if (!ar) ar = Array.prototype.slice.call(
|
22563
|
-
ar[i] =
|
22568
|
+
__spreadArray7 = function(to, from2, pack) {
|
22569
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
22570
|
+
if (ar || !(i in from2)) {
|
22571
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
22572
|
+
ar[i] = from2[i];
|
22564
22573
|
}
|
22565
22574
|
}
|
22566
|
-
return to.concat(ar || Array.prototype.slice.call(
|
22575
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
22567
22576
|
};
|
22568
22577
|
MetricCollector = /** @class */
|
22569
22578
|
function() {
|
@@ -22828,9 +22837,9 @@ var init_MeterProvider = __esm({
|
|
22828
22837
|
}
|
22829
22838
|
}
|
22830
22839
|
}
|
22831
|
-
MeterProvider2.prototype.getMeter = function(name,
|
22832
|
-
if (
|
22833
|
-
|
22840
|
+
MeterProvider2.prototype.getMeter = function(name, version2, options2) {
|
22841
|
+
if (version2 === void 0) {
|
22842
|
+
version2 = "";
|
22834
22843
|
}
|
22835
22844
|
if (options2 === void 0) {
|
22836
22845
|
options2 = {};
|
@@ -22841,7 +22850,7 @@ var init_MeterProvider = __esm({
|
|
22841
22850
|
}
|
22842
22851
|
return this._sharedState.getMeterSharedState({
|
22843
22852
|
name,
|
22844
|
-
version,
|
22853
|
+
version: version2,
|
22845
22854
|
schemaUrl: options2.schemaUrl
|
22846
22855
|
}).meter;
|
22847
22856
|
};
|
@@ -25970,19 +25979,19 @@ var require_root = __commonJS({
|
|
25970
25979
|
return Span2;
|
25971
25980
|
}();
|
25972
25981
|
v1.Status = function() {
|
25973
|
-
function
|
25982
|
+
function Status2(properties) {
|
25974
25983
|
if (properties) {
|
25975
25984
|
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
25976
25985
|
if (properties[keys[i]] != null)
|
25977
25986
|
this[keys[i]] = properties[keys[i]];
|
25978
25987
|
}
|
25979
25988
|
}
|
25980
|
-
|
25981
|
-
|
25982
|
-
|
25983
|
-
return new
|
25989
|
+
Status2.prototype.message = null;
|
25990
|
+
Status2.prototype.code = null;
|
25991
|
+
Status2.create = function create(properties) {
|
25992
|
+
return new Status2(properties);
|
25984
25993
|
};
|
25985
|
-
|
25994
|
+
Status2.encode = function encode(message, writer) {
|
25986
25995
|
if (!writer)
|
25987
25996
|
writer = $Writer.create();
|
25988
25997
|
if (message.message != null && Object.hasOwnProperty.call(message, "message"))
|
@@ -25997,10 +26006,10 @@ var require_root = __commonJS({
|
|
25997
26006
|
).int32(message.code);
|
25998
26007
|
return writer;
|
25999
26008
|
};
|
26000
|
-
|
26009
|
+
Status2.encodeDelimited = function encodeDelimited(message, writer) {
|
26001
26010
|
return this.encode(message, writer).ldelim();
|
26002
26011
|
};
|
26003
|
-
|
26012
|
+
Status2.decode = function decode(reader, length) {
|
26004
26013
|
if (!(reader instanceof $Reader))
|
26005
26014
|
reader = $Reader.create(reader);
|
26006
26015
|
var end = length === void 0 ? reader.len : reader.pos + length, message = new $root.opentelemetry.proto.trace.v1.Status();
|
@@ -26022,12 +26031,12 @@ var require_root = __commonJS({
|
|
26022
26031
|
}
|
26023
26032
|
return message;
|
26024
26033
|
};
|
26025
|
-
|
26034
|
+
Status2.decodeDelimited = function decodeDelimited(reader) {
|
26026
26035
|
if (!(reader instanceof $Reader))
|
26027
26036
|
reader = new $Reader(reader);
|
26028
26037
|
return this.decode(reader, reader.uint32());
|
26029
26038
|
};
|
26030
|
-
|
26039
|
+
Status2.verify = function verify(message) {
|
26031
26040
|
if (typeof message !== "object" || message === null)
|
26032
26041
|
return "object expected";
|
26033
26042
|
if (message.message != null && message.hasOwnProperty("message")) {
|
@@ -26045,7 +26054,7 @@ var require_root = __commonJS({
|
|
26045
26054
|
}
|
26046
26055
|
return null;
|
26047
26056
|
};
|
26048
|
-
|
26057
|
+
Status2.fromObject = function fromObject(object) {
|
26049
26058
|
if (object instanceof $root.opentelemetry.proto.trace.v1.Status)
|
26050
26059
|
return object;
|
26051
26060
|
var message = new $root.opentelemetry.proto.trace.v1.Status();
|
@@ -26073,7 +26082,7 @@ var require_root = __commonJS({
|
|
26073
26082
|
}
|
26074
26083
|
return message;
|
26075
26084
|
};
|
26076
|
-
|
26085
|
+
Status2.toObject = function toObject(message, options2) {
|
26077
26086
|
if (!options2)
|
26078
26087
|
options2 = {};
|
26079
26088
|
var object = {};
|
@@ -26087,23 +26096,23 @@ var require_root = __commonJS({
|
|
26087
26096
|
object.code = options2.enums === String ? $root.opentelemetry.proto.trace.v1.Status.StatusCode[message.code] === void 0 ? message.code : $root.opentelemetry.proto.trace.v1.Status.StatusCode[message.code] : message.code;
|
26088
26097
|
return object;
|
26089
26098
|
};
|
26090
|
-
|
26099
|
+
Status2.prototype.toJSON = function toJSON() {
|
26091
26100
|
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
26092
26101
|
};
|
26093
|
-
|
26102
|
+
Status2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
26094
26103
|
if (typeUrlPrefix === void 0) {
|
26095
26104
|
typeUrlPrefix = "type.googleapis.com";
|
26096
26105
|
}
|
26097
26106
|
return typeUrlPrefix + "/opentelemetry.proto.trace.v1.Status";
|
26098
26107
|
};
|
26099
|
-
|
26108
|
+
Status2.StatusCode = function() {
|
26100
26109
|
var valuesById = {}, values = Object.create(valuesById);
|
26101
26110
|
values[valuesById[0] = "STATUS_CODE_UNSET"] = 0;
|
26102
26111
|
values[valuesById[1] = "STATUS_CODE_OK"] = 1;
|
26103
26112
|
values[valuesById[2] = "STATUS_CODE_ERROR"] = 2;
|
26104
26113
|
return values;
|
26105
26114
|
}();
|
26106
|
-
return
|
26115
|
+
return Status2;
|
26107
26116
|
}();
|
26108
26117
|
return v1;
|
26109
26118
|
}();
|
@@ -31579,13 +31588,13 @@ function createResourceMap(logRecords) {
|
|
31579
31588
|
try {
|
31580
31589
|
for (var logRecords_1 = __values11(logRecords), logRecords_1_1 = logRecords_1.next(); !logRecords_1_1.done; logRecords_1_1 = logRecords_1.next()) {
|
31581
31590
|
var record = logRecords_1_1.value;
|
31582
|
-
var resource = record.resource, _b = record.instrumentationScope, name_1 = _b.name, _c = _b.version,
|
31591
|
+
var resource = record.resource, _b = record.instrumentationScope, name_1 = _b.name, _c = _b.version, version2 = _c === void 0 ? "" : _c, _d = _b.schemaUrl, schemaUrl = _d === void 0 ? "" : _d;
|
31583
31592
|
var ismMap = resourceMap.get(resource);
|
31584
31593
|
if (!ismMap) {
|
31585
31594
|
ismMap = /* @__PURE__ */ new Map();
|
31586
31595
|
resourceMap.set(resource, ismMap);
|
31587
31596
|
}
|
31588
|
-
var ismKey = name_1 + "@" +
|
31597
|
+
var ismKey = name_1 + "@" + version2 + ":" + schemaUrl;
|
31589
31598
|
var records = ismMap.get(ismKey);
|
31590
31599
|
if (!records) {
|
31591
31600
|
records = [];
|
@@ -34453,14 +34462,14 @@ var init_Span = __esm({
|
|
34453
34462
|
}
|
34454
34463
|
return ar;
|
34455
34464
|
};
|
34456
|
-
__spreadArray8 = function(to,
|
34457
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
34458
|
-
if (ar || !(i in
|
34459
|
-
if (!ar) ar = Array.prototype.slice.call(
|
34460
|
-
ar[i] =
|
34465
|
+
__spreadArray8 = function(to, from2, pack) {
|
34466
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
34467
|
+
if (ar || !(i in from2)) {
|
34468
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
34469
|
+
ar[i] = from2[i];
|
34461
34470
|
}
|
34462
34471
|
}
|
34463
|
-
return to.concat(ar || Array.prototype.slice.call(
|
34472
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
34464
34473
|
};
|
34465
34474
|
Span = /** @class */
|
34466
34475
|
function() {
|
@@ -35513,14 +35522,14 @@ var init_BasicTracerProvider = __esm({
|
|
35513
35522
|
}
|
35514
35523
|
return ar;
|
35515
35524
|
};
|
35516
|
-
__spreadArray9 = function(to,
|
35517
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
35518
|
-
if (ar || !(i in
|
35519
|
-
if (!ar) ar = Array.prototype.slice.call(
|
35520
|
-
ar[i] =
|
35525
|
+
__spreadArray9 = function(to, from2, pack) {
|
35526
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
35527
|
+
if (ar || !(i in from2)) {
|
35528
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
35529
|
+
ar[i] = from2[i];
|
35521
35530
|
}
|
35522
35531
|
}
|
35523
|
-
return to.concat(ar || Array.prototype.slice.call(
|
35532
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
35524
35533
|
};
|
35525
35534
|
(function(ForceFlushState2) {
|
35526
35535
|
ForceFlushState2[ForceFlushState2["resolved"] = 0] = "resolved";
|
@@ -35558,10 +35567,10 @@ var init_BasicTracerProvider = __esm({
|
|
35558
35567
|
}
|
35559
35568
|
}
|
35560
35569
|
}
|
35561
|
-
BasicTracerProvider2.prototype.getTracer = function(name,
|
35562
|
-
var key = name + "@" + (
|
35570
|
+
BasicTracerProvider2.prototype.getTracer = function(name, version2, options2) {
|
35571
|
+
var key = name + "@" + (version2 || "") + ":" + ((options2 === null || options2 === void 0 ? void 0 : options2.schemaUrl) || "");
|
35563
35572
|
if (!this._tracers.has(key)) {
|
35564
|
-
this._tracers.set(key, new Tracer({ name, version, schemaUrl: options2 === null || options2 === void 0 ? void 0 : options2.schemaUrl }, this._config, this));
|
35573
|
+
this._tracers.set(key, new Tracer({ name, version: version2, schemaUrl: options2 === null || options2 === void 0 ? void 0 : options2.schemaUrl }, this._config, this));
|
35565
35574
|
}
|
35566
35575
|
return this._tracers.get(key);
|
35567
35576
|
};
|
@@ -35790,14 +35799,14 @@ var init_InMemorySpanExporter = __esm({
|
|
35790
35799
|
}
|
35791
35800
|
return ar;
|
35792
35801
|
};
|
35793
|
-
__spreadArray10 = function(to,
|
35794
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
35795
|
-
if (ar || !(i in
|
35796
|
-
if (!ar) ar = Array.prototype.slice.call(
|
35797
|
-
ar[i] =
|
35802
|
+
__spreadArray10 = function(to, from2, pack) {
|
35803
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
35804
|
+
if (ar || !(i in from2)) {
|
35805
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
35806
|
+
ar[i] = from2[i];
|
35798
35807
|
}
|
35799
35808
|
}
|
35800
|
-
return to.concat(ar || Array.prototype.slice.call(
|
35809
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
35801
35810
|
};
|
35802
35811
|
InMemorySpanExporter = /** @class */
|
35803
35812
|
function() {
|
@@ -36233,31 +36242,31 @@ var require_semver = __commonJS({
|
|
36233
36242
|
var parseOptions = require_parse_options();
|
36234
36243
|
var { compareIdentifiers } = require_identifiers();
|
36235
36244
|
var SemVer = class _SemVer {
|
36236
|
-
constructor(
|
36245
|
+
constructor(version2, options2) {
|
36237
36246
|
options2 = parseOptions(options2);
|
36238
|
-
if (
|
36239
|
-
if (
|
36240
|
-
return
|
36247
|
+
if (version2 instanceof _SemVer) {
|
36248
|
+
if (version2.loose === !!options2.loose && version2.includePrerelease === !!options2.includePrerelease) {
|
36249
|
+
return version2;
|
36241
36250
|
} else {
|
36242
|
-
|
36251
|
+
version2 = version2.version;
|
36243
36252
|
}
|
36244
|
-
} else if (typeof
|
36245
|
-
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof
|
36253
|
+
} else if (typeof version2 !== "string") {
|
36254
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version2}".`);
|
36246
36255
|
}
|
36247
|
-
if (
|
36256
|
+
if (version2.length > MAX_LENGTH) {
|
36248
36257
|
throw new TypeError(
|
36249
36258
|
`version is longer than ${MAX_LENGTH} characters`
|
36250
36259
|
);
|
36251
36260
|
}
|
36252
|
-
debug("SemVer",
|
36261
|
+
debug("SemVer", version2, options2);
|
36253
36262
|
this.options = options2;
|
36254
36263
|
this.loose = !!options2.loose;
|
36255
36264
|
this.includePrerelease = !!options2.includePrerelease;
|
36256
|
-
const m =
|
36265
|
+
const m = version2.trim().match(options2.loose ? re2[t.LOOSE] : re2[t.FULL]);
|
36257
36266
|
if (!m) {
|
36258
|
-
throw new TypeError(`Invalid Version: ${
|
36267
|
+
throw new TypeError(`Invalid Version: ${version2}`);
|
36259
36268
|
}
|
36260
|
-
this.raw =
|
36269
|
+
this.raw = version2;
|
36261
36270
|
this.major = +m[1];
|
36262
36271
|
this.minor = +m[2];
|
36263
36272
|
this.patch = +m[3];
|
@@ -36475,12 +36484,12 @@ var require_parse = __commonJS({
|
|
36475
36484
|
"../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/functions/parse.js"(exports, module) {
|
36476
36485
|
"use strict";
|
36477
36486
|
var SemVer = require_semver();
|
36478
|
-
var parse2 = (
|
36479
|
-
if (
|
36480
|
-
return
|
36487
|
+
var parse2 = (version2, options2, throwErrors = false) => {
|
36488
|
+
if (version2 instanceof SemVer) {
|
36489
|
+
return version2;
|
36481
36490
|
}
|
36482
36491
|
try {
|
36483
|
-
return new SemVer(
|
36492
|
+
return new SemVer(version2, options2);
|
36484
36493
|
} catch (er) {
|
36485
36494
|
if (!throwErrors) {
|
36486
36495
|
return null;
|
@@ -36497,8 +36506,8 @@ var require_valid = __commonJS({
|
|
36497
36506
|
"../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/functions/valid.js"(exports, module) {
|
36498
36507
|
"use strict";
|
36499
36508
|
var parse2 = require_parse();
|
36500
|
-
var valid = (
|
36501
|
-
const v = parse2(
|
36509
|
+
var valid = (version2, options2) => {
|
36510
|
+
const v = parse2(version2, options2);
|
36502
36511
|
return v ? v.version : null;
|
36503
36512
|
};
|
36504
36513
|
module.exports = valid;
|
@@ -36510,8 +36519,8 @@ var require_clean = __commonJS({
|
|
36510
36519
|
"../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/functions/clean.js"(exports, module) {
|
36511
36520
|
"use strict";
|
36512
36521
|
var parse2 = require_parse();
|
36513
|
-
var clean = (
|
36514
|
-
const s = parse2(
|
36522
|
+
var clean = (version2, options2) => {
|
36523
|
+
const s = parse2(version2.trim().replace(/^[=v]+/, ""), options2);
|
36515
36524
|
return s ? s.version : null;
|
36516
36525
|
};
|
36517
36526
|
module.exports = clean;
|
@@ -36523,7 +36532,7 @@ var require_inc = __commonJS({
|
|
36523
36532
|
"../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/functions/inc.js"(exports, module) {
|
36524
36533
|
"use strict";
|
36525
36534
|
var SemVer = require_semver();
|
36526
|
-
var inc = (
|
36535
|
+
var inc = (version2, release, options2, identifier, identifierBase) => {
|
36527
36536
|
if (typeof options2 === "string") {
|
36528
36537
|
identifierBase = identifier;
|
36529
36538
|
identifier = options2;
|
@@ -36531,7 +36540,7 @@ var require_inc = __commonJS({
|
|
36531
36540
|
}
|
36532
36541
|
try {
|
36533
36542
|
return new SemVer(
|
36534
|
-
|
36543
|
+
version2 instanceof SemVer ? version2.version : version2,
|
36535
36544
|
options2
|
36536
36545
|
).inc(release, identifier, identifierBase).version;
|
36537
36546
|
} catch (er) {
|
@@ -36622,8 +36631,8 @@ var require_prerelease = __commonJS({
|
|
36622
36631
|
"../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/functions/prerelease.js"(exports, module) {
|
36623
36632
|
"use strict";
|
36624
36633
|
var parse2 = require_parse();
|
36625
|
-
var prerelease = (
|
36626
|
-
const parsed = parse2(
|
36634
|
+
var prerelease = (version2, options2) => {
|
36635
|
+
const parsed = parse2(version2, options2);
|
36627
36636
|
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
36628
36637
|
};
|
36629
36638
|
module.exports = prerelease;
|
@@ -36811,24 +36820,24 @@ var require_coerce = __commonJS({
|
|
36811
36820
|
var SemVer = require_semver();
|
36812
36821
|
var parse2 = require_parse();
|
36813
36822
|
var { safeRe: re2, t } = require_re();
|
36814
|
-
var coerce = (
|
36815
|
-
if (
|
36816
|
-
return
|
36823
|
+
var coerce = (version2, options2) => {
|
36824
|
+
if (version2 instanceof SemVer) {
|
36825
|
+
return version2;
|
36817
36826
|
}
|
36818
|
-
if (typeof
|
36819
|
-
|
36827
|
+
if (typeof version2 === "number") {
|
36828
|
+
version2 = String(version2);
|
36820
36829
|
}
|
36821
|
-
if (typeof
|
36830
|
+
if (typeof version2 !== "string") {
|
36822
36831
|
return null;
|
36823
36832
|
}
|
36824
36833
|
options2 = options2 || {};
|
36825
36834
|
let match = null;
|
36826
36835
|
if (!options2.rtl) {
|
36827
|
-
match =
|
36836
|
+
match = version2.match(options2.includePrerelease ? re2[t.COERCEFULL] : re2[t.COERCE]);
|
36828
36837
|
} else {
|
36829
36838
|
const coerceRtlRegex = options2.includePrerelease ? re2[t.COERCERTLFULL] : re2[t.COERCERTL];
|
36830
36839
|
let next;
|
36831
|
-
while ((next = coerceRtlRegex.exec(
|
36840
|
+
while ((next = coerceRtlRegex.exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
|
36832
36841
|
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
36833
36842
|
match = next;
|
36834
36843
|
}
|
@@ -37012,19 +37021,19 @@ var require_range = __commonJS({
|
|
37012
37021
|
});
|
37013
37022
|
}
|
37014
37023
|
// if ANY of the sets match ALL of its comparators, then pass
|
37015
|
-
test(
|
37016
|
-
if (!
|
37024
|
+
test(version2) {
|
37025
|
+
if (!version2) {
|
37017
37026
|
return false;
|
37018
37027
|
}
|
37019
|
-
if (typeof
|
37028
|
+
if (typeof version2 === "string") {
|
37020
37029
|
try {
|
37021
|
-
|
37030
|
+
version2 = new SemVer(version2, this.options);
|
37022
37031
|
} catch (er) {
|
37023
37032
|
return false;
|
37024
37033
|
}
|
37025
37034
|
}
|
37026
37035
|
for (let i = 0; i < this.set.length; i++) {
|
37027
|
-
if (testSet(this.set[i],
|
37036
|
+
if (testSet(this.set[i], version2, this.options)) {
|
37028
37037
|
return true;
|
37029
37038
|
}
|
37030
37039
|
}
|
@@ -37211,17 +37220,17 @@ var require_range = __commonJS({
|
|
37211
37220
|
debug("replaceGTE0", comp, options2);
|
37212
37221
|
return comp.trim().replace(re2[options2.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
37213
37222
|
};
|
37214
|
-
var hyphenReplace = (incPr) => ($0,
|
37223
|
+
var hyphenReplace = (incPr) => ($0, from2, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
37215
37224
|
if (isX(fM)) {
|
37216
|
-
|
37225
|
+
from2 = "";
|
37217
37226
|
} else if (isX(fm)) {
|
37218
|
-
|
37227
|
+
from2 = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
37219
37228
|
} else if (isX(fp)) {
|
37220
|
-
|
37229
|
+
from2 = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
37221
37230
|
} else if (fpr) {
|
37222
|
-
|
37231
|
+
from2 = `>=${from2}`;
|
37223
37232
|
} else {
|
37224
|
-
|
37233
|
+
from2 = `>=${from2}${incPr ? "-0" : ""}`;
|
37225
37234
|
}
|
37226
37235
|
if (isX(tM)) {
|
37227
37236
|
to = "";
|
@@ -37236,15 +37245,15 @@ var require_range = __commonJS({
|
|
37236
37245
|
} else {
|
37237
37246
|
to = `<=${to}`;
|
37238
37247
|
}
|
37239
|
-
return `${
|
37248
|
+
return `${from2} ${to}`.trim();
|
37240
37249
|
};
|
37241
|
-
var testSet = (set,
|
37250
|
+
var testSet = (set, version2, options2) => {
|
37242
37251
|
for (let i = 0; i < set.length; i++) {
|
37243
|
-
if (!set[i].test(
|
37252
|
+
if (!set[i].test(version2)) {
|
37244
37253
|
return false;
|
37245
37254
|
}
|
37246
37255
|
}
|
37247
|
-
if (
|
37256
|
+
if (version2.prerelease.length && !options2.includePrerelease) {
|
37248
37257
|
for (let i = 0; i < set.length; i++) {
|
37249
37258
|
debug(set[i].semver);
|
37250
37259
|
if (set[i].semver === Comparator.ANY) {
|
@@ -37252,7 +37261,7 @@ var require_range = __commonJS({
|
|
37252
37261
|
}
|
37253
37262
|
if (set[i].semver.prerelease.length > 0) {
|
37254
37263
|
const allowed = set[i].semver;
|
37255
|
-
if (allowed.major ===
|
37264
|
+
if (allowed.major === version2.major && allowed.minor === version2.minor && allowed.patch === version2.patch) {
|
37256
37265
|
return true;
|
37257
37266
|
}
|
37258
37267
|
}
|
@@ -37313,19 +37322,19 @@ var require_comparator = __commonJS({
|
|
37313
37322
|
toString() {
|
37314
37323
|
return this.value;
|
37315
37324
|
}
|
37316
|
-
test(
|
37317
|
-
debug("Comparator.test",
|
37318
|
-
if (this.semver === ANY ||
|
37325
|
+
test(version2) {
|
37326
|
+
debug("Comparator.test", version2, this.options.loose);
|
37327
|
+
if (this.semver === ANY || version2 === ANY) {
|
37319
37328
|
return true;
|
37320
37329
|
}
|
37321
|
-
if (typeof
|
37330
|
+
if (typeof version2 === "string") {
|
37322
37331
|
try {
|
37323
|
-
|
37332
|
+
version2 = new SemVer(version2, this.options);
|
37324
37333
|
} catch (er) {
|
37325
37334
|
return false;
|
37326
37335
|
}
|
37327
37336
|
}
|
37328
|
-
return cmp(
|
37337
|
+
return cmp(version2, this.operator, this.semver, this.options);
|
37329
37338
|
}
|
37330
37339
|
intersects(comp, options2) {
|
37331
37340
|
if (!(comp instanceof _Comparator)) {
|
@@ -37382,13 +37391,13 @@ var require_satisfies = __commonJS({
|
|
37382
37391
|
"../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/functions/satisfies.js"(exports, module) {
|
37383
37392
|
"use strict";
|
37384
37393
|
var Range = require_range();
|
37385
|
-
var satisfies = (
|
37394
|
+
var satisfies = (version2, range, options2) => {
|
37386
37395
|
try {
|
37387
37396
|
range = new Range(range, options2);
|
37388
37397
|
} catch (er) {
|
37389
37398
|
return false;
|
37390
37399
|
}
|
37391
|
-
return range.test(
|
37400
|
+
return range.test(version2);
|
37392
37401
|
};
|
37393
37402
|
module.exports = satisfies;
|
37394
37403
|
}
|
@@ -37550,8 +37559,8 @@ var require_outside = __commonJS({
|
|
37550
37559
|
var lt = require_lt();
|
37551
37560
|
var lte = require_lte();
|
37552
37561
|
var gte = require_gte();
|
37553
|
-
var outside = (
|
37554
|
-
|
37562
|
+
var outside = (version2, range, hilo, options2) => {
|
37563
|
+
version2 = new SemVer(version2, options2);
|
37555
37564
|
range = new Range(range, options2);
|
37556
37565
|
let gtfn, ltefn, ltfn, comp, ecomp;
|
37557
37566
|
switch (hilo) {
|
@@ -37572,7 +37581,7 @@ var require_outside = __commonJS({
|
|
37572
37581
|
default:
|
37573
37582
|
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
37574
37583
|
}
|
37575
|
-
if (satisfies(
|
37584
|
+
if (satisfies(version2, range, options2)) {
|
37576
37585
|
return false;
|
37577
37586
|
}
|
37578
37587
|
for (let i = 0; i < range.set.length; ++i) {
|
@@ -37594,9 +37603,9 @@ var require_outside = __commonJS({
|
|
37594
37603
|
if (high.operator === comp || high.operator === ecomp) {
|
37595
37604
|
return false;
|
37596
37605
|
}
|
37597
|
-
if ((!low.operator || low.operator === comp) && ltefn(
|
37606
|
+
if ((!low.operator || low.operator === comp) && ltefn(version2, low.semver)) {
|
37598
37607
|
return false;
|
37599
|
-
} else if (low.operator === ecomp && ltfn(
|
37608
|
+
} else if (low.operator === ecomp && ltfn(version2, low.semver)) {
|
37600
37609
|
return false;
|
37601
37610
|
}
|
37602
37611
|
}
|
@@ -37611,7 +37620,7 @@ var require_gtr = __commonJS({
|
|
37611
37620
|
"../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/ranges/gtr.js"(exports, module) {
|
37612
37621
|
"use strict";
|
37613
37622
|
var outside = require_outside();
|
37614
|
-
var gtr = (
|
37623
|
+
var gtr = (version2, range, options2) => outside(version2, range, ">", options2);
|
37615
37624
|
module.exports = gtr;
|
37616
37625
|
}
|
37617
37626
|
});
|
@@ -37621,7 +37630,7 @@ var require_ltr = __commonJS({
|
|
37621
37630
|
"../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/ranges/ltr.js"(exports, module) {
|
37622
37631
|
"use strict";
|
37623
37632
|
var outside = require_outside();
|
37624
|
-
var ltr = (
|
37633
|
+
var ltr = (version2, range, options2) => outside(version2, range, "<", options2);
|
37625
37634
|
module.exports = ltr;
|
37626
37635
|
}
|
37627
37636
|
});
|
@@ -37651,12 +37660,12 @@ var require_simplify = __commonJS({
|
|
37651
37660
|
let first = null;
|
37652
37661
|
let prev = null;
|
37653
37662
|
const v = versions.sort((a, b) => compare(a, b, options2));
|
37654
|
-
for (const
|
37655
|
-
const included = satisfies(
|
37663
|
+
for (const version2 of v) {
|
37664
|
+
const included = satisfies(version2, range, options2);
|
37656
37665
|
if (included) {
|
37657
|
-
prev =
|
37666
|
+
prev = version2;
|
37658
37667
|
if (!first) {
|
37659
|
-
first =
|
37668
|
+
first = version2;
|
37660
37669
|
}
|
37661
37670
|
} else {
|
37662
37671
|
if (prev) {
|
@@ -38238,6 +38247,1474 @@ var require_src7 = __commonJS({
|
|
38238
38247
|
}
|
38239
38248
|
});
|
38240
38249
|
|
38250
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/package.json
|
38251
|
+
var require_package2 = __commonJS({
|
38252
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/package.json"(exports, module) {
|
38253
|
+
module.exports = {
|
38254
|
+
name: "piscina",
|
38255
|
+
version: "5.0.0-alpha.0",
|
38256
|
+
description: "A fast, efficient Node.js Worker Thread Pool implementation",
|
38257
|
+
main: "./dist/main.js",
|
38258
|
+
types: "./dist/index.d.ts",
|
38259
|
+
exports: {
|
38260
|
+
types: "./dist/index.d.ts",
|
38261
|
+
import: "./dist/esm-wrapper.mjs",
|
38262
|
+
require: "./dist/main.js"
|
38263
|
+
},
|
38264
|
+
engines: {
|
38265
|
+
node: ">=18.x"
|
38266
|
+
},
|
38267
|
+
scripts: {
|
38268
|
+
build: "tsc && gen-esm-wrapper . dist/esm-wrapper.mjs",
|
38269
|
+
lint: "eslint",
|
38270
|
+
test: "c8 tap",
|
38271
|
+
"test:ci": "npm run lint && npm run build && npm run test:coverage",
|
38272
|
+
"test:coverage": "c8 --reporter=lcov tap --cov",
|
38273
|
+
prepack: "npm run build",
|
38274
|
+
benchmark: "npm run bench:queue && npm run benchmark:piscina",
|
38275
|
+
"benchmark:piscina": "npm run benchmark:default &&npm run benchmark:queue:fixed && npm run benchmark:default:comparison",
|
38276
|
+
"benchmark:default": "node benchmark/simple-benchmark.js",
|
38277
|
+
"benchmark:default:async": "node benchmark/simple-benchmark.js",
|
38278
|
+
"benchmark:default:comparison": "node benchmark/piscina-queue-comparison.js",
|
38279
|
+
"benchmark:queue": "npm run benchmark:queue-comparison",
|
38280
|
+
"benchmark:queue:fixed": "node benchmark/simple-benchmark-fixed-queue.js",
|
38281
|
+
"benchmark:queue:comparison": "node benchmark/queue-comparison.js"
|
38282
|
+
},
|
38283
|
+
repository: {
|
38284
|
+
type: "git",
|
38285
|
+
url: "git+https://github.com/piscinajs/piscina.git"
|
38286
|
+
},
|
38287
|
+
keywords: [
|
38288
|
+
"fast",
|
38289
|
+
"worker threads",
|
38290
|
+
"thread pool",
|
38291
|
+
"wade wilson"
|
38292
|
+
],
|
38293
|
+
author: "James M Snell <jasnell@gmail.com>",
|
38294
|
+
contributors: [
|
38295
|
+
"Anna Henningsen <anna@addaleax.net>",
|
38296
|
+
"Matteo Collina <matteo.collina@gmail.com>",
|
38297
|
+
"Carlos Fuentes <me@metcoder.dev>"
|
38298
|
+
],
|
38299
|
+
license: "MIT",
|
38300
|
+
devDependencies: {
|
38301
|
+
"@types/node": "^22.4.1",
|
38302
|
+
"abort-controller": "^3.0.0",
|
38303
|
+
c8: "^10.1.2",
|
38304
|
+
"concat-stream": "^2.0.0",
|
38305
|
+
eslint: "^9.16.0",
|
38306
|
+
"gen-esm-wrapper": "^1.1.1",
|
38307
|
+
neostandard: "^0.11.9",
|
38308
|
+
tap: "^16.3.7",
|
38309
|
+
tinybench: "^3.0.0",
|
38310
|
+
"ts-node": "^10.9.2",
|
38311
|
+
typescript: "5.7.2"
|
38312
|
+
},
|
38313
|
+
optionalDependencies: {
|
38314
|
+
"@napi-rs/nice": "^1.0.1"
|
38315
|
+
},
|
38316
|
+
bugs: {
|
38317
|
+
url: "https://github.com/piscinajs/piscina/issues"
|
38318
|
+
},
|
38319
|
+
homepage: "https://github.com/piscinajs/piscina#readme",
|
38320
|
+
directories: {
|
38321
|
+
example: "examples",
|
38322
|
+
test: "test"
|
38323
|
+
}
|
38324
|
+
};
|
38325
|
+
}
|
38326
|
+
});
|
38327
|
+
|
38328
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/symbols.js
|
38329
|
+
var require_symbols = __commonJS({
|
38330
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/symbols.js"(exports) {
|
38331
|
+
"use strict";
|
38332
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38333
|
+
exports.kFieldCount = exports.kResponseCountField = exports.kRequestCountField = exports.kQueueOptions = exports.kValue = exports.kTransferable = exports.kWorkerData = exports.kMovable = void 0;
|
38334
|
+
exports.kMovable = Symbol("Piscina.kMovable");
|
38335
|
+
exports.kWorkerData = Symbol("Piscina.kWorkerData");
|
38336
|
+
exports.kTransferable = Symbol.for("Piscina.transferable");
|
38337
|
+
exports.kValue = Symbol.for("Piscina.valueOf");
|
38338
|
+
exports.kQueueOptions = Symbol.for("Piscina.queueOptions");
|
38339
|
+
exports.kRequestCountField = 0;
|
38340
|
+
exports.kResponseCountField = 1;
|
38341
|
+
exports.kFieldCount = 2;
|
38342
|
+
}
|
38343
|
+
});
|
38344
|
+
|
38345
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/common.js
|
38346
|
+
var require_common2 = __commonJS({
|
38347
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/common.js"(exports) {
|
38348
|
+
"use strict";
|
38349
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38350
|
+
exports.commonState = exports.READY = void 0;
|
38351
|
+
exports.isTransferable = isTransferable;
|
38352
|
+
exports.isMovable = isMovable;
|
38353
|
+
exports.markMovable = markMovable;
|
38354
|
+
exports.createHistogramSummary = createHistogramSummary;
|
38355
|
+
exports.toHistogramIntegerNano = toHistogramIntegerNano;
|
38356
|
+
exports.maybeFileURLToPath = maybeFileURLToPath;
|
38357
|
+
exports.getAvailableParallelism = getAvailableParallelism;
|
38358
|
+
var node_url_1 = __require("node:url");
|
38359
|
+
var node_os_1 = __require("node:os");
|
38360
|
+
var symbols_1 = require_symbols();
|
38361
|
+
exports.READY = "_WORKER_READY";
|
38362
|
+
function isTransferable(value) {
|
38363
|
+
return value != null && typeof value === "object" && symbols_1.kTransferable in value && symbols_1.kValue in value;
|
38364
|
+
}
|
38365
|
+
function isMovable(value) {
|
38366
|
+
return isTransferable(value) && value[symbols_1.kMovable] === true;
|
38367
|
+
}
|
38368
|
+
function markMovable(value) {
|
38369
|
+
Object.defineProperty(value, symbols_1.kMovable, {
|
38370
|
+
enumerable: false,
|
38371
|
+
configurable: true,
|
38372
|
+
writable: true,
|
38373
|
+
value: true
|
38374
|
+
});
|
38375
|
+
}
|
38376
|
+
exports.commonState = {
|
38377
|
+
isWorkerThread: false,
|
38378
|
+
workerData: void 0
|
38379
|
+
};
|
38380
|
+
function createHistogramSummary(histogram) {
|
38381
|
+
const { mean, stddev, min, max } = histogram;
|
38382
|
+
return {
|
38383
|
+
average: mean / 1e3,
|
38384
|
+
mean: mean / 1e3,
|
38385
|
+
stddev,
|
38386
|
+
min: min / 1e3,
|
38387
|
+
max: max / 1e3,
|
38388
|
+
p0_001: histogram.percentile(1e-3) / 1e3,
|
38389
|
+
p0_01: histogram.percentile(0.01) / 1e3,
|
38390
|
+
p0_1: histogram.percentile(0.1) / 1e3,
|
38391
|
+
p1: histogram.percentile(1) / 1e3,
|
38392
|
+
p2_5: histogram.percentile(2.5) / 1e3,
|
38393
|
+
p10: histogram.percentile(10) / 1e3,
|
38394
|
+
p25: histogram.percentile(25) / 1e3,
|
38395
|
+
p50: histogram.percentile(50) / 1e3,
|
38396
|
+
p75: histogram.percentile(75) / 1e3,
|
38397
|
+
p90: histogram.percentile(90) / 1e3,
|
38398
|
+
p97_5: histogram.percentile(97.5) / 1e3,
|
38399
|
+
p99: histogram.percentile(99) / 1e3,
|
38400
|
+
p99_9: histogram.percentile(99.9) / 1e3,
|
38401
|
+
p99_99: histogram.percentile(99.99) / 1e3,
|
38402
|
+
p99_999: histogram.percentile(99.999) / 1e3
|
38403
|
+
};
|
38404
|
+
}
|
38405
|
+
function toHistogramIntegerNano(milliseconds) {
|
38406
|
+
return Math.max(1, Math.trunc(milliseconds * 1e3));
|
38407
|
+
}
|
38408
|
+
function maybeFileURLToPath(filename) {
|
38409
|
+
return filename.startsWith("file:") ? (0, node_url_1.fileURLToPath)(new node_url_1.URL(filename)) : filename;
|
38410
|
+
}
|
38411
|
+
function getAvailableParallelism() {
|
38412
|
+
return (0, node_os_1.availableParallelism)();
|
38413
|
+
}
|
38414
|
+
}
|
38415
|
+
});
|
38416
|
+
|
38417
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/task_queue/array_queue.js
|
38418
|
+
var require_array_queue = __commonJS({
|
38419
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/task_queue/array_queue.js"(exports) {
|
38420
|
+
"use strict";
|
38421
|
+
var __importDefault = exports && exports.__importDefault || function(mod2) {
|
38422
|
+
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
38423
|
+
};
|
38424
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38425
|
+
exports.ArrayTaskQueue = void 0;
|
38426
|
+
var node_assert_1 = __importDefault(__require("node:assert"));
|
38427
|
+
var ArrayTaskQueue2 = class {
|
38428
|
+
constructor() {
|
38429
|
+
this.tasks = [];
|
38430
|
+
}
|
38431
|
+
get size() {
|
38432
|
+
return this.tasks.length;
|
38433
|
+
}
|
38434
|
+
shift() {
|
38435
|
+
var _a2;
|
38436
|
+
return (_a2 = this.tasks.shift()) !== null && _a2 !== void 0 ? _a2 : null;
|
38437
|
+
}
|
38438
|
+
push(task) {
|
38439
|
+
this.tasks.push(task);
|
38440
|
+
}
|
38441
|
+
remove(task) {
|
38442
|
+
const index = this.tasks.indexOf(task);
|
38443
|
+
node_assert_1.default.notStrictEqual(index, -1);
|
38444
|
+
this.tasks.splice(index, 1);
|
38445
|
+
}
|
38446
|
+
};
|
38447
|
+
exports.ArrayTaskQueue = ArrayTaskQueue2;
|
38448
|
+
}
|
38449
|
+
});
|
38450
|
+
|
38451
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/task_queue/fixed_queue.js
|
38452
|
+
var require_fixed_queue = __commonJS({
|
38453
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/task_queue/fixed_queue.js"(exports) {
|
38454
|
+
"use strict";
|
38455
|
+
var __importDefault = exports && exports.__importDefault || function(mod2) {
|
38456
|
+
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
38457
|
+
};
|
38458
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38459
|
+
exports.FixedQueue = void 0;
|
38460
|
+
var node_assert_1 = __importDefault(__require("node:assert"));
|
38461
|
+
var kSize = 2048;
|
38462
|
+
var kMask = kSize - 1;
|
38463
|
+
var FixedCircularBuffer = class {
|
38464
|
+
constructor() {
|
38465
|
+
this.bottom = 0;
|
38466
|
+
this.top = 0;
|
38467
|
+
this.list = new Array(kSize);
|
38468
|
+
this.next = null;
|
38469
|
+
}
|
38470
|
+
isEmpty() {
|
38471
|
+
return this.top === this.bottom;
|
38472
|
+
}
|
38473
|
+
isFull() {
|
38474
|
+
return (this.top + 1 & kMask) === this.bottom;
|
38475
|
+
}
|
38476
|
+
push(data) {
|
38477
|
+
this.list[this.top] = data;
|
38478
|
+
this.top = this.top + 1 & kMask;
|
38479
|
+
}
|
38480
|
+
shift() {
|
38481
|
+
const nextItem = this.list[this.bottom];
|
38482
|
+
if (nextItem === void 0) {
|
38483
|
+
return null;
|
38484
|
+
}
|
38485
|
+
this.list[this.bottom] = void 0;
|
38486
|
+
this.bottom = this.bottom + 1 & kMask;
|
38487
|
+
return nextItem;
|
38488
|
+
}
|
38489
|
+
remove(task) {
|
38490
|
+
const indexToRemove = this.list.indexOf(task);
|
38491
|
+
node_assert_1.default.notStrictEqual(indexToRemove, -1);
|
38492
|
+
let curr = indexToRemove;
|
38493
|
+
while (true) {
|
38494
|
+
const next = curr + 1 & kMask;
|
38495
|
+
this.list[curr] = this.list[next];
|
38496
|
+
if (this.list[curr] === void 0) {
|
38497
|
+
break;
|
38498
|
+
}
|
38499
|
+
if (next === indexToRemove) {
|
38500
|
+
this.list[curr] = void 0;
|
38501
|
+
break;
|
38502
|
+
}
|
38503
|
+
curr = next;
|
38504
|
+
}
|
38505
|
+
this.top = this.top - 1 & kMask;
|
38506
|
+
}
|
38507
|
+
};
|
38508
|
+
var FixedQueue2 = class {
|
38509
|
+
constructor() {
|
38510
|
+
this._size = 0;
|
38511
|
+
this.head = this.tail = new FixedCircularBuffer();
|
38512
|
+
}
|
38513
|
+
isEmpty() {
|
38514
|
+
return this.head.isEmpty();
|
38515
|
+
}
|
38516
|
+
push(data) {
|
38517
|
+
if (this.head.isFull()) {
|
38518
|
+
this.head = this.head.next = new FixedCircularBuffer();
|
38519
|
+
}
|
38520
|
+
this.head.push(data);
|
38521
|
+
this._size++;
|
38522
|
+
}
|
38523
|
+
shift() {
|
38524
|
+
const tail = this.tail;
|
38525
|
+
const next = tail.shift();
|
38526
|
+
if (next !== null)
|
38527
|
+
this._size--;
|
38528
|
+
if (tail.isEmpty() && tail.next !== null) {
|
38529
|
+
this.tail = tail.next;
|
38530
|
+
tail.next = null;
|
38531
|
+
}
|
38532
|
+
return next;
|
38533
|
+
}
|
38534
|
+
remove(task) {
|
38535
|
+
let prev = null;
|
38536
|
+
let buffer = this.tail;
|
38537
|
+
while (true) {
|
38538
|
+
if (buffer.list.includes(task)) {
|
38539
|
+
buffer.remove(task);
|
38540
|
+
this._size--;
|
38541
|
+
break;
|
38542
|
+
}
|
38543
|
+
if (buffer.next === null)
|
38544
|
+
break;
|
38545
|
+
prev = buffer;
|
38546
|
+
buffer = buffer.next;
|
38547
|
+
}
|
38548
|
+
if (buffer.isEmpty()) {
|
38549
|
+
if (prev === null) {
|
38550
|
+
if (buffer.next !== null)
|
38551
|
+
this.tail = buffer.next;
|
38552
|
+
} else {
|
38553
|
+
if (buffer.next === null) {
|
38554
|
+
this.head = prev;
|
38555
|
+
} else {
|
38556
|
+
prev.next = buffer.next;
|
38557
|
+
}
|
38558
|
+
}
|
38559
|
+
}
|
38560
|
+
}
|
38561
|
+
get size() {
|
38562
|
+
return this._size;
|
38563
|
+
}
|
38564
|
+
};
|
38565
|
+
exports.FixedQueue = FixedQueue2;
|
38566
|
+
}
|
38567
|
+
});
|
38568
|
+
|
38569
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/task_queue/index.js
|
38570
|
+
var require_task_queue = __commonJS({
|
38571
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/task_queue/index.js"(exports) {
|
38572
|
+
"use strict";
|
38573
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38574
|
+
exports.TaskInfo = exports.FixedQueue = exports.ArrayTaskQueue = void 0;
|
38575
|
+
exports.isTaskQueue = isTaskQueue;
|
38576
|
+
var node_perf_hooks_1 = __require("node:perf_hooks");
|
38577
|
+
var node_async_hooks_1 = __require("node:async_hooks");
|
38578
|
+
var common_1 = require_common2();
|
38579
|
+
var symbols_1 = require_symbols();
|
38580
|
+
var array_queue_1 = require_array_queue();
|
38581
|
+
Object.defineProperty(exports, "ArrayTaskQueue", { enumerable: true, get: function() {
|
38582
|
+
return array_queue_1.ArrayTaskQueue;
|
38583
|
+
} });
|
38584
|
+
var fixed_queue_1 = require_fixed_queue();
|
38585
|
+
Object.defineProperty(exports, "FixedQueue", { enumerable: true, get: function() {
|
38586
|
+
return fixed_queue_1.FixedQueue;
|
38587
|
+
} });
|
38588
|
+
function isTaskQueue(value) {
|
38589
|
+
return typeof value === "object" && value !== null && "size" in value && typeof value.shift === "function" && typeof value.remove === "function" && typeof value.push === "function";
|
38590
|
+
}
|
38591
|
+
var taskIdCounter = 0;
|
38592
|
+
var TaskInfo = class extends node_async_hooks_1.AsyncResource {
|
38593
|
+
constructor(task, transferList, filename, name, callback, abortSignal, triggerAsyncId) {
|
38594
|
+
super("Piscina.Task", { requireManualDestroy: true, triggerAsyncId });
|
38595
|
+
this.workerInfo = null;
|
38596
|
+
this.aborted = false;
|
38597
|
+
this._abortListener = null;
|
38598
|
+
this.callback = callback;
|
38599
|
+
this.task = task;
|
38600
|
+
this.transferList = transferList;
|
38601
|
+
if ((0, common_1.isMovable)(task)) {
|
38602
|
+
if (this.transferList == null) {
|
38603
|
+
this.transferList = [];
|
38604
|
+
}
|
38605
|
+
this.transferList = this.transferList.concat(task[symbols_1.kTransferable]);
|
38606
|
+
this.task = task[symbols_1.kValue];
|
38607
|
+
}
|
38608
|
+
this.filename = filename;
|
38609
|
+
this.name = name;
|
38610
|
+
this.taskId = taskIdCounter++;
|
38611
|
+
this.abortSignal = abortSignal;
|
38612
|
+
this.created = node_perf_hooks_1.performance.now();
|
38613
|
+
this.started = 0;
|
38614
|
+
}
|
38615
|
+
// TODO: improve this handling - ideally should be extended
|
38616
|
+
set abortListener(value) {
|
38617
|
+
this._abortListener = () => {
|
38618
|
+
this.aborted = true;
|
38619
|
+
value();
|
38620
|
+
};
|
38621
|
+
}
|
38622
|
+
get abortListener() {
|
38623
|
+
return this._abortListener;
|
38624
|
+
}
|
38625
|
+
releaseTask() {
|
38626
|
+
const ret = this.task;
|
38627
|
+
this.task = null;
|
38628
|
+
return ret;
|
38629
|
+
}
|
38630
|
+
done(err, result) {
|
38631
|
+
this.runInAsyncScope(this.callback, null, err, result);
|
38632
|
+
this.emitDestroy();
|
38633
|
+
if (this.abortSignal && this.abortListener) {
|
38634
|
+
if ("removeEventListener" in this.abortSignal && this.abortListener) {
|
38635
|
+
this.abortSignal.removeEventListener("abort", this.abortListener);
|
38636
|
+
} else {
|
38637
|
+
this.abortSignal.off("abort", this.abortListener);
|
38638
|
+
}
|
38639
|
+
}
|
38640
|
+
}
|
38641
|
+
get [symbols_1.kQueueOptions]() {
|
38642
|
+
var _a2, _b;
|
38643
|
+
return (_b = (_a2 = this.task) === null || _a2 === void 0 ? void 0 : _a2[symbols_1.kQueueOptions]) !== null && _b !== void 0 ? _b : null;
|
38644
|
+
}
|
38645
|
+
get interface() {
|
38646
|
+
return {
|
38647
|
+
taskId: this.taskId,
|
38648
|
+
filename: this.filename,
|
38649
|
+
name: this.name,
|
38650
|
+
created: this.created,
|
38651
|
+
isAbortable: this.abortSignal !== null,
|
38652
|
+
[symbols_1.kQueueOptions]: this[symbols_1.kQueueOptions]
|
38653
|
+
};
|
38654
|
+
}
|
38655
|
+
};
|
38656
|
+
exports.TaskInfo = TaskInfo;
|
38657
|
+
}
|
38658
|
+
});
|
38659
|
+
|
38660
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/errors.js
|
38661
|
+
var require_errors3 = __commonJS({
|
38662
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/errors.js"(exports) {
|
38663
|
+
"use strict";
|
38664
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38665
|
+
exports.Errors = void 0;
|
38666
|
+
exports.Errors = {
|
38667
|
+
ThreadTermination: () => new Error("Terminating worker thread"),
|
38668
|
+
FilenameNotProvided: () => new Error("filename must be provided to run() or in options object"),
|
38669
|
+
TaskQueueAtLimit: () => new Error("Task queue is at limit"),
|
38670
|
+
NoTaskQueueAvailable: () => new Error("No task queue available and all Workers are busy"),
|
38671
|
+
CloseTimeout: () => new Error("Close operation timed out")
|
38672
|
+
};
|
38673
|
+
}
|
38674
|
+
});
|
38675
|
+
|
38676
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/worker_pool/base.js
|
38677
|
+
var require_base = __commonJS({
|
38678
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/worker_pool/base.js"(exports) {
|
38679
|
+
"use strict";
|
38680
|
+
var __importDefault = exports && exports.__importDefault || function(mod2) {
|
38681
|
+
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
38682
|
+
};
|
38683
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38684
|
+
exports.AsynchronouslyCreatedResourcePool = exports.AsynchronouslyCreatedResource = void 0;
|
38685
|
+
var node_assert_1 = __importDefault(__require("node:assert"));
|
38686
|
+
var AsynchronouslyCreatedResource = class {
|
38687
|
+
constructor() {
|
38688
|
+
this.onreadyListeners = [];
|
38689
|
+
this.ondestroyListeners = [];
|
38690
|
+
}
|
38691
|
+
markAsReady() {
|
38692
|
+
const listeners = this.onreadyListeners;
|
38693
|
+
(0, node_assert_1.default)(listeners !== null);
|
38694
|
+
this.onreadyListeners = null;
|
38695
|
+
for (const listener of listeners) {
|
38696
|
+
listener();
|
38697
|
+
}
|
38698
|
+
}
|
38699
|
+
isReady() {
|
38700
|
+
return this.onreadyListeners === null;
|
38701
|
+
}
|
38702
|
+
onReady(fn) {
|
38703
|
+
if (this.onreadyListeners === null) {
|
38704
|
+
fn();
|
38705
|
+
return;
|
38706
|
+
}
|
38707
|
+
this.onreadyListeners.push(fn);
|
38708
|
+
}
|
38709
|
+
onDestroy(fn) {
|
38710
|
+
if (this.ondestroyListeners === null) {
|
38711
|
+
return;
|
38712
|
+
}
|
38713
|
+
this.ondestroyListeners.push(fn);
|
38714
|
+
}
|
38715
|
+
markAsDestroyed() {
|
38716
|
+
const listeners = this.ondestroyListeners;
|
38717
|
+
(0, node_assert_1.default)(listeners !== null);
|
38718
|
+
this.ondestroyListeners = null;
|
38719
|
+
for (const listener of listeners) {
|
38720
|
+
listener();
|
38721
|
+
}
|
38722
|
+
}
|
38723
|
+
isDestroyed() {
|
38724
|
+
return this.ondestroyListeners === null;
|
38725
|
+
}
|
38726
|
+
};
|
38727
|
+
exports.AsynchronouslyCreatedResource = AsynchronouslyCreatedResource;
|
38728
|
+
var AsynchronouslyCreatedResourcePool = class {
|
38729
|
+
constructor(maximumUsage) {
|
38730
|
+
this.pendingItems = /* @__PURE__ */ new Set();
|
38731
|
+
this.readyItems = /* @__PURE__ */ new Set();
|
38732
|
+
this.maximumUsage = maximumUsage;
|
38733
|
+
this.onAvailableListeners = [];
|
38734
|
+
this.onTaskDoneListeners = [];
|
38735
|
+
}
|
38736
|
+
add(item) {
|
38737
|
+
this.pendingItems.add(item);
|
38738
|
+
item.onReady(() => {
|
38739
|
+
if (this.pendingItems.has(item)) {
|
38740
|
+
this.pendingItems.delete(item);
|
38741
|
+
this.readyItems.add(item);
|
38742
|
+
this.maybeAvailable(item);
|
38743
|
+
}
|
38744
|
+
});
|
38745
|
+
}
|
38746
|
+
delete(item) {
|
38747
|
+
this.pendingItems.delete(item);
|
38748
|
+
this.readyItems.delete(item);
|
38749
|
+
}
|
38750
|
+
*[Symbol.iterator]() {
|
38751
|
+
yield* this.pendingItems;
|
38752
|
+
yield* this.readyItems;
|
38753
|
+
}
|
38754
|
+
get size() {
|
38755
|
+
return this.pendingItems.size + this.readyItems.size;
|
38756
|
+
}
|
38757
|
+
maybeAvailable(item) {
|
38758
|
+
if (item.currentUsage() < this.maximumUsage) {
|
38759
|
+
for (const listener of this.onAvailableListeners) {
|
38760
|
+
listener(item);
|
38761
|
+
}
|
38762
|
+
}
|
38763
|
+
}
|
38764
|
+
onAvailable(fn) {
|
38765
|
+
this.onAvailableListeners.push(fn);
|
38766
|
+
}
|
38767
|
+
taskDone(item) {
|
38768
|
+
for (let i = 0; i < this.onTaskDoneListeners.length; i++) {
|
38769
|
+
this.onTaskDoneListeners[i](item);
|
38770
|
+
}
|
38771
|
+
}
|
38772
|
+
onTaskDone(fn) {
|
38773
|
+
this.onTaskDoneListeners.push(fn);
|
38774
|
+
}
|
38775
|
+
getCurrentUsage() {
|
38776
|
+
let inFlight = 0;
|
38777
|
+
for (const worker of this.readyItems) {
|
38778
|
+
const currentUsage = worker.currentUsage();
|
38779
|
+
if (Number.isFinite(currentUsage))
|
38780
|
+
inFlight += currentUsage;
|
38781
|
+
}
|
38782
|
+
return inFlight;
|
38783
|
+
}
|
38784
|
+
};
|
38785
|
+
exports.AsynchronouslyCreatedResourcePool = AsynchronouslyCreatedResourcePool;
|
38786
|
+
}
|
38787
|
+
});
|
38788
|
+
|
38789
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/worker_pool/balancer/index.js
|
38790
|
+
var require_balancer = __commonJS({
|
38791
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/worker_pool/balancer/index.js"(exports) {
|
38792
|
+
"use strict";
|
38793
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38794
|
+
exports.LeastBusyBalancer = LeastBusyBalancer;
|
38795
|
+
function LeastBusyBalancer(opts) {
|
38796
|
+
const { maximumUsage } = opts;
|
38797
|
+
return (task, workers) => {
|
38798
|
+
let candidate = null;
|
38799
|
+
let checkpoint = maximumUsage;
|
38800
|
+
for (const worker of workers) {
|
38801
|
+
if (worker.currentUsage === 0) {
|
38802
|
+
candidate = worker;
|
38803
|
+
break;
|
38804
|
+
}
|
38805
|
+
if (worker.isRunningAbortableTask)
|
38806
|
+
continue;
|
38807
|
+
if (!task.isAbortable && worker.currentUsage < checkpoint) {
|
38808
|
+
candidate = worker;
|
38809
|
+
checkpoint = worker.currentUsage;
|
38810
|
+
}
|
38811
|
+
}
|
38812
|
+
return candidate;
|
38813
|
+
};
|
38814
|
+
}
|
38815
|
+
}
|
38816
|
+
});
|
38817
|
+
|
38818
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/worker_pool/index.js
|
38819
|
+
var require_worker_pool = __commonJS({
|
38820
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/worker_pool/index.js"(exports) {
|
38821
|
+
"use strict";
|
38822
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
38823
|
+
if (k2 === void 0) k2 = k;
|
38824
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
38825
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
38826
|
+
desc = { enumerable: true, get: function() {
|
38827
|
+
return m[k];
|
38828
|
+
} };
|
38829
|
+
}
|
38830
|
+
Object.defineProperty(o, k2, desc);
|
38831
|
+
} : function(o, m, k, k2) {
|
38832
|
+
if (k2 === void 0) k2 = k;
|
38833
|
+
o[k2] = m[k];
|
38834
|
+
});
|
38835
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
38836
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
38837
|
+
};
|
38838
|
+
var __importDefault = exports && exports.__importDefault || function(mod2) {
|
38839
|
+
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
38840
|
+
};
|
38841
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38842
|
+
exports.AsynchronouslyCreatedResourcePool = exports.WorkerInfo = void 0;
|
38843
|
+
var node_worker_threads_1 = __require("node:worker_threads");
|
38844
|
+
var node_perf_hooks_1 = __require("node:perf_hooks");
|
38845
|
+
var node_assert_1 = __importDefault(__require("node:assert"));
|
38846
|
+
var errors_1 = require_errors3();
|
38847
|
+
var symbols_1 = require_symbols();
|
38848
|
+
var common_1 = require_common2();
|
38849
|
+
var base_1 = require_base();
|
38850
|
+
Object.defineProperty(exports, "AsynchronouslyCreatedResourcePool", { enumerable: true, get: function() {
|
38851
|
+
return base_1.AsynchronouslyCreatedResourcePool;
|
38852
|
+
} });
|
38853
|
+
__exportStar(require_balancer(), exports);
|
38854
|
+
var WorkerInfo = class extends base_1.AsynchronouslyCreatedResource {
|
38855
|
+
constructor(worker, port, onMessage, enableHistogram) {
|
38856
|
+
super();
|
38857
|
+
this.idleTimeout = null;
|
38858
|
+
this.lastSeenResponseCount = 0;
|
38859
|
+
this.terminating = false;
|
38860
|
+
this.destroyed = false;
|
38861
|
+
this.worker = worker;
|
38862
|
+
this.port = port;
|
38863
|
+
this.port.on("message", (message) => this._handleResponse(message));
|
38864
|
+
this.onMessage = onMessage;
|
38865
|
+
this.taskInfos = /* @__PURE__ */ new Map();
|
38866
|
+
this.sharedBuffer = new Int32Array(new SharedArrayBuffer(symbols_1.kFieldCount * Int32Array.BYTES_PER_ELEMENT));
|
38867
|
+
this.histogram = enableHistogram ? (0, node_perf_hooks_1.createHistogram)() : null;
|
38868
|
+
}
|
38869
|
+
get id() {
|
38870
|
+
return this.worker.threadId;
|
38871
|
+
}
|
38872
|
+
destroy() {
|
38873
|
+
if (this.terminating || this.destroyed)
|
38874
|
+
return;
|
38875
|
+
this.terminating = true;
|
38876
|
+
this.worker.terminate();
|
38877
|
+
this.port.close();
|
38878
|
+
this.clearIdleTimeout();
|
38879
|
+
for (const taskInfo of this.taskInfos.values()) {
|
38880
|
+
taskInfo.done(errors_1.Errors.ThreadTermination());
|
38881
|
+
}
|
38882
|
+
this.taskInfos.clear();
|
38883
|
+
this.terminating = false;
|
38884
|
+
this.destroyed = true;
|
38885
|
+
this.markAsDestroyed();
|
38886
|
+
}
|
38887
|
+
clearIdleTimeout() {
|
38888
|
+
if (this.idleTimeout != null) {
|
38889
|
+
clearTimeout(this.idleTimeout);
|
38890
|
+
this.idleTimeout = null;
|
38891
|
+
}
|
38892
|
+
}
|
38893
|
+
ref() {
|
38894
|
+
this.port.ref();
|
38895
|
+
return this;
|
38896
|
+
}
|
38897
|
+
unref() {
|
38898
|
+
this.port.unref();
|
38899
|
+
return this;
|
38900
|
+
}
|
38901
|
+
_handleResponse(message) {
|
38902
|
+
var _a2;
|
38903
|
+
if (message.time != null) {
|
38904
|
+
(_a2 = this.histogram) === null || _a2 === void 0 ? void 0 : _a2.record((0, common_1.toHistogramIntegerNano)(message.time));
|
38905
|
+
}
|
38906
|
+
this.onMessage(message);
|
38907
|
+
if (this.taskInfos.size === 0) {
|
38908
|
+
this.unref();
|
38909
|
+
}
|
38910
|
+
}
|
38911
|
+
postTask(taskInfo) {
|
38912
|
+
(0, node_assert_1.default)(!this.taskInfos.has(taskInfo.taskId));
|
38913
|
+
(0, node_assert_1.default)(!this.terminating && !this.destroyed);
|
38914
|
+
const message = {
|
38915
|
+
task: taskInfo.releaseTask(),
|
38916
|
+
taskId: taskInfo.taskId,
|
38917
|
+
filename: taskInfo.filename,
|
38918
|
+
name: taskInfo.name,
|
38919
|
+
histogramEnabled: this.histogram != null ? 1 : 0
|
38920
|
+
};
|
38921
|
+
try {
|
38922
|
+
this.port.postMessage(message, taskInfo.transferList);
|
38923
|
+
} catch (err) {
|
38924
|
+
taskInfo.done(err);
|
38925
|
+
return;
|
38926
|
+
}
|
38927
|
+
taskInfo.workerInfo = this;
|
38928
|
+
this.taskInfos.set(taskInfo.taskId, taskInfo);
|
38929
|
+
this.ref();
|
38930
|
+
this.clearIdleTimeout();
|
38931
|
+
Atomics.add(this.sharedBuffer, symbols_1.kRequestCountField, 1);
|
38932
|
+
Atomics.notify(this.sharedBuffer, symbols_1.kRequestCountField, 1);
|
38933
|
+
}
|
38934
|
+
processPendingMessages() {
|
38935
|
+
if (this.destroyed)
|
38936
|
+
return;
|
38937
|
+
const actualResponseCount = Atomics.load(this.sharedBuffer, symbols_1.kResponseCountField);
|
38938
|
+
if (actualResponseCount !== this.lastSeenResponseCount) {
|
38939
|
+
this.lastSeenResponseCount = actualResponseCount;
|
38940
|
+
let entry;
|
38941
|
+
while ((entry = (0, node_worker_threads_1.receiveMessageOnPort)(this.port)) !== void 0) {
|
38942
|
+
this._handleResponse(entry.message);
|
38943
|
+
}
|
38944
|
+
}
|
38945
|
+
}
|
38946
|
+
isRunningAbortableTask() {
|
38947
|
+
if (this.taskInfos.size !== 1)
|
38948
|
+
return false;
|
38949
|
+
const [[, task]] = this.taskInfos;
|
38950
|
+
return task.abortSignal !== null;
|
38951
|
+
}
|
38952
|
+
currentUsage() {
|
38953
|
+
if (this.isRunningAbortableTask())
|
38954
|
+
return Infinity;
|
38955
|
+
return this.taskInfos.size;
|
38956
|
+
}
|
38957
|
+
get interface() {
|
38958
|
+
const worker = this;
|
38959
|
+
return {
|
38960
|
+
get id() {
|
38961
|
+
return worker.worker.threadId;
|
38962
|
+
},
|
38963
|
+
get currentUsage() {
|
38964
|
+
return worker.currentUsage();
|
38965
|
+
},
|
38966
|
+
get isRunningAbortableTask() {
|
38967
|
+
return worker.isRunningAbortableTask();
|
38968
|
+
},
|
38969
|
+
get histogram() {
|
38970
|
+
return worker.histogram != null ? (0, common_1.createHistogramSummary)(worker.histogram) : null;
|
38971
|
+
},
|
38972
|
+
get terminating() {
|
38973
|
+
return worker.terminating;
|
38974
|
+
},
|
38975
|
+
get destroyed() {
|
38976
|
+
return worker.destroyed;
|
38977
|
+
},
|
38978
|
+
[symbols_1.kWorkerData]: worker
|
38979
|
+
};
|
38980
|
+
}
|
38981
|
+
};
|
38982
|
+
exports.WorkerInfo = WorkerInfo;
|
38983
|
+
}
|
38984
|
+
});
|
38985
|
+
|
38986
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/abort.js
|
38987
|
+
var require_abort = __commonJS({
|
38988
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/abort.js"(exports) {
|
38989
|
+
"use strict";
|
38990
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38991
|
+
exports.AbortError = void 0;
|
38992
|
+
exports.onabort = onabort;
|
38993
|
+
var AbortError = class extends Error {
|
38994
|
+
constructor(reason) {
|
38995
|
+
super("The task has been aborted", { cause: reason });
|
38996
|
+
}
|
38997
|
+
get name() {
|
38998
|
+
return "AbortError";
|
38999
|
+
}
|
39000
|
+
};
|
39001
|
+
exports.AbortError = AbortError;
|
39002
|
+
function onabort(abortSignal, listener) {
|
39003
|
+
if ("addEventListener" in abortSignal) {
|
39004
|
+
abortSignal.addEventListener("abort", listener, { once: true });
|
39005
|
+
} else {
|
39006
|
+
abortSignal.once("abort", listener);
|
39007
|
+
}
|
39008
|
+
}
|
39009
|
+
}
|
39010
|
+
});
|
39011
|
+
|
39012
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/index.js
|
39013
|
+
var require_dist = __commonJS({
|
39014
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/index.js"(exports) {
|
39015
|
+
"use strict";
|
39016
|
+
var __classPrivateFieldSet = exports && exports.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
|
39017
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
39018
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
39019
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
39020
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
39021
|
+
};
|
39022
|
+
var __classPrivateFieldGet = exports && exports.__classPrivateFieldGet || function(receiver, state, kind, f) {
|
39023
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
39024
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
39025
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
39026
|
+
};
|
39027
|
+
var __importDefault = exports && exports.__importDefault || function(mod2) {
|
39028
|
+
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
39029
|
+
};
|
39030
|
+
var _DirectlyTransferable_value;
|
39031
|
+
var _ArrayBufferViewTransferable_view;
|
39032
|
+
var _Piscina_pool;
|
39033
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39034
|
+
exports.FixedQueue = exports.version = exports.queueOptionsSymbol = exports.valueSymbol = exports.transferableSymbol = exports.Piscina = exports.workerData = exports.isWorkerThread = exports.move = void 0;
|
39035
|
+
var node_worker_threads_1 = __require("node:worker_threads");
|
39036
|
+
var node_events_1 = __require("node:events");
|
39037
|
+
var node_path_1 = __require("node:path");
|
39038
|
+
var node_util_1 = __require("node:util");
|
39039
|
+
var node_perf_hooks_1 = __require("node:perf_hooks");
|
39040
|
+
var promises_1 = __require("node:timers/promises");
|
39041
|
+
var node_assert_1 = __importDefault(__require("node:assert"));
|
39042
|
+
var package_json_1 = require_package2();
|
39043
|
+
Object.defineProperty(exports, "version", { enumerable: true, get: function() {
|
39044
|
+
return package_json_1.version;
|
39045
|
+
} });
|
39046
|
+
var symbols_1 = require_symbols();
|
39047
|
+
Object.defineProperty(exports, "queueOptionsSymbol", { enumerable: true, get: function() {
|
39048
|
+
return symbols_1.kQueueOptions;
|
39049
|
+
} });
|
39050
|
+
Object.defineProperty(exports, "transferableSymbol", { enumerable: true, get: function() {
|
39051
|
+
return symbols_1.kTransferable;
|
39052
|
+
} });
|
39053
|
+
Object.defineProperty(exports, "valueSymbol", { enumerable: true, get: function() {
|
39054
|
+
return symbols_1.kValue;
|
39055
|
+
} });
|
39056
|
+
var task_queue_1 = require_task_queue();
|
39057
|
+
Object.defineProperty(exports, "FixedQueue", { enumerable: true, get: function() {
|
39058
|
+
return task_queue_1.FixedQueue;
|
39059
|
+
} });
|
39060
|
+
var worker_pool_1 = require_worker_pool();
|
39061
|
+
var abort_1 = require_abort();
|
39062
|
+
var errors_1 = require_errors3();
|
39063
|
+
var common_1 = require_common2();
|
39064
|
+
var cpuParallelism = (0, common_1.getAvailableParallelism)();
|
39065
|
+
var kDefaultOptions = {
|
39066
|
+
filename: null,
|
39067
|
+
name: "default",
|
39068
|
+
minThreads: Math.max(Math.floor(cpuParallelism / 2), 1),
|
39069
|
+
maxThreads: cpuParallelism * 1.5,
|
39070
|
+
idleTimeout: 0,
|
39071
|
+
maxQueue: Infinity,
|
39072
|
+
concurrentTasksPerWorker: 1,
|
39073
|
+
atomics: "sync",
|
39074
|
+
taskQueue: new task_queue_1.ArrayTaskQueue(),
|
39075
|
+
niceIncrement: 0,
|
39076
|
+
trackUnmanagedFds: true,
|
39077
|
+
closeTimeout: 3e4,
|
39078
|
+
recordTiming: true,
|
39079
|
+
workerHistogram: false
|
39080
|
+
};
|
39081
|
+
var kDefaultRunOptions = {
|
39082
|
+
transferList: void 0,
|
39083
|
+
filename: null,
|
39084
|
+
signal: null,
|
39085
|
+
name: null
|
39086
|
+
};
|
39087
|
+
var kDefaultCloseOptions = {
|
39088
|
+
force: false
|
39089
|
+
};
|
39090
|
+
var DirectlyTransferable = class {
|
39091
|
+
constructor(value) {
|
39092
|
+
_DirectlyTransferable_value.set(this, void 0);
|
39093
|
+
__classPrivateFieldSet(this, _DirectlyTransferable_value, value, "f");
|
39094
|
+
}
|
39095
|
+
get [(_DirectlyTransferable_value = /* @__PURE__ */ new WeakMap(), symbols_1.kTransferable)]() {
|
39096
|
+
return __classPrivateFieldGet(this, _DirectlyTransferable_value, "f");
|
39097
|
+
}
|
39098
|
+
get [symbols_1.kValue]() {
|
39099
|
+
return __classPrivateFieldGet(this, _DirectlyTransferable_value, "f");
|
39100
|
+
}
|
39101
|
+
};
|
39102
|
+
var ArrayBufferViewTransferable = class {
|
39103
|
+
constructor(view) {
|
39104
|
+
_ArrayBufferViewTransferable_view.set(this, void 0);
|
39105
|
+
__classPrivateFieldSet(this, _ArrayBufferViewTransferable_view, view, "f");
|
39106
|
+
}
|
39107
|
+
get [(_ArrayBufferViewTransferable_view = /* @__PURE__ */ new WeakMap(), symbols_1.kTransferable)]() {
|
39108
|
+
return __classPrivateFieldGet(this, _ArrayBufferViewTransferable_view, "f").buffer;
|
39109
|
+
}
|
39110
|
+
get [symbols_1.kValue]() {
|
39111
|
+
return __classPrivateFieldGet(this, _ArrayBufferViewTransferable_view, "f");
|
39112
|
+
}
|
39113
|
+
};
|
39114
|
+
var ThreadPool = class {
|
39115
|
+
constructor(publicInterface, options2) {
|
39116
|
+
var _a2, _b, _c;
|
39117
|
+
this.skipQueue = [];
|
39118
|
+
this.completed = 0;
|
39119
|
+
this.start = node_perf_hooks_1.performance.now();
|
39120
|
+
this.inProcessPendingMessages = false;
|
39121
|
+
this.startingUp = false;
|
39122
|
+
this.closingUp = false;
|
39123
|
+
this.workerFailsDuringBootstrap = false;
|
39124
|
+
this.destroying = false;
|
39125
|
+
this.publicInterface = publicInterface;
|
39126
|
+
this.taskQueue = (_a2 = options2.taskQueue) !== null && _a2 !== void 0 ? _a2 : new task_queue_1.FixedQueue();
|
39127
|
+
const filename = options2.filename ? (0, common_1.maybeFileURLToPath)(options2.filename) : null;
|
39128
|
+
this.options = { ...kDefaultOptions, ...options2, filename, maxQueue: 0 };
|
39129
|
+
if (this.options.recordTiming) {
|
39130
|
+
this.runTime = (0, node_perf_hooks_1.createHistogram)();
|
39131
|
+
this.waitTime = (0, node_perf_hooks_1.createHistogram)();
|
39132
|
+
}
|
39133
|
+
if (options2.maxThreads !== void 0 && this.options.minThreads >= options2.maxThreads) {
|
39134
|
+
this.options.minThreads = options2.maxThreads;
|
39135
|
+
}
|
39136
|
+
if (options2.minThreads !== void 0 && this.options.maxThreads <= options2.minThreads) {
|
39137
|
+
this.options.maxThreads = options2.minThreads;
|
39138
|
+
}
|
39139
|
+
if (options2.maxQueue === "auto") {
|
39140
|
+
this.options.maxQueue = this.options.maxThreads ** 2;
|
39141
|
+
} else {
|
39142
|
+
this.options.maxQueue = (_b = options2.maxQueue) !== null && _b !== void 0 ? _b : kDefaultOptions.maxQueue;
|
39143
|
+
}
|
39144
|
+
this.balancer = (_c = this.options.loadBalancer) !== null && _c !== void 0 ? _c : (0, worker_pool_1.LeastBusyBalancer)({ maximumUsage: this.options.concurrentTasksPerWorker });
|
39145
|
+
this.workers = new worker_pool_1.AsynchronouslyCreatedResourcePool(this.options.concurrentTasksPerWorker);
|
39146
|
+
this.workers.onTaskDone((w) => this._onWorkerTaskDone(w));
|
39147
|
+
this.maxCapacity = this.options.maxThreads * this.options.concurrentTasksPerWorker;
|
39148
|
+
this.startingUp = true;
|
39149
|
+
this._ensureMinimumWorkers();
|
39150
|
+
this.startingUp = false;
|
39151
|
+
this._needsDrain = false;
|
39152
|
+
}
|
39153
|
+
_ensureMinimumWorkers() {
|
39154
|
+
if (this.closingUp || this.destroying) {
|
39155
|
+
return;
|
39156
|
+
}
|
39157
|
+
while (this.workers.size < this.options.minThreads) {
|
39158
|
+
this._addNewWorker();
|
39159
|
+
}
|
39160
|
+
}
|
39161
|
+
_addNewWorker() {
|
39162
|
+
if (this.closingUp)
|
39163
|
+
return;
|
39164
|
+
const pool = this;
|
39165
|
+
const worker = new node_worker_threads_1.Worker((0, node_path_1.resolve)(__dirname, "worker.js"), {
|
39166
|
+
env: this.options.env,
|
39167
|
+
argv: this.options.argv,
|
39168
|
+
execArgv: this.options.execArgv,
|
39169
|
+
resourceLimits: this.options.resourceLimits,
|
39170
|
+
workerData: this.options.workerData,
|
39171
|
+
trackUnmanagedFds: this.options.trackUnmanagedFds
|
39172
|
+
});
|
39173
|
+
const { port1, port2 } = new node_worker_threads_1.MessageChannel();
|
39174
|
+
const workerInfo = new worker_pool_1.WorkerInfo(worker, port1, onMessage, this.options.workerHistogram);
|
39175
|
+
workerInfo.onDestroy(() => {
|
39176
|
+
this.publicInterface.emit("workerDestroy", workerInfo.interface);
|
39177
|
+
});
|
39178
|
+
if (this.startingUp) {
|
39179
|
+
workerInfo.markAsReady();
|
39180
|
+
queueMicrotask(() => {
|
39181
|
+
this.publicInterface.emit("workerCreate", workerInfo.interface);
|
39182
|
+
this._onWorkerReady(workerInfo);
|
39183
|
+
});
|
39184
|
+
} else {
|
39185
|
+
workerInfo.onReady(() => {
|
39186
|
+
this.publicInterface.emit("workerCreate", workerInfo.interface);
|
39187
|
+
this._onWorkerReady(workerInfo);
|
39188
|
+
});
|
39189
|
+
}
|
39190
|
+
const message = {
|
39191
|
+
filename: this.options.filename,
|
39192
|
+
name: this.options.name,
|
39193
|
+
port: port2,
|
39194
|
+
sharedBuffer: workerInfo.sharedBuffer,
|
39195
|
+
atomics: this.options.atomics,
|
39196
|
+
niceIncrement: this.options.niceIncrement
|
39197
|
+
};
|
39198
|
+
worker.postMessage(message, [port2]);
|
39199
|
+
function onMessage(message2) {
|
39200
|
+
const { taskId, result } = message2;
|
39201
|
+
const taskInfo = workerInfo.taskInfos.get(taskId);
|
39202
|
+
workerInfo.taskInfos.delete(taskId);
|
39203
|
+
pool.workers.taskDone(workerInfo);
|
39204
|
+
if (taskInfo === void 0) {
|
39205
|
+
const err = new Error(`Unexpected message from Worker: ${(0, node_util_1.inspect)(message2)}`);
|
39206
|
+
pool.publicInterface.emit("error", err);
|
39207
|
+
} else {
|
39208
|
+
taskInfo.done(message2.error, result);
|
39209
|
+
}
|
39210
|
+
pool._processPendingMessages();
|
39211
|
+
}
|
39212
|
+
function onReady() {
|
39213
|
+
if (workerInfo.currentUsage() === 0) {
|
39214
|
+
workerInfo.unref();
|
39215
|
+
}
|
39216
|
+
if (!workerInfo.isReady()) {
|
39217
|
+
workerInfo.markAsReady();
|
39218
|
+
}
|
39219
|
+
}
|
39220
|
+
function onEventMessage(message2) {
|
39221
|
+
pool.publicInterface.emit("message", message2);
|
39222
|
+
}
|
39223
|
+
worker.on("message", (message2) => {
|
39224
|
+
message2 instanceof Object && common_1.READY in message2 ? onReady() : onEventMessage(message2);
|
39225
|
+
});
|
39226
|
+
worker.on("error", (err) => {
|
39227
|
+
this._onError(worker, workerInfo, err, false);
|
39228
|
+
});
|
39229
|
+
worker.on("exit", (exitCode) => {
|
39230
|
+
if (this.destroying) {
|
39231
|
+
return;
|
39232
|
+
}
|
39233
|
+
const err = new Error(`worker exited with code: ${exitCode}`);
|
39234
|
+
this._onError(worker, workerInfo, err, true);
|
39235
|
+
});
|
39236
|
+
worker.unref();
|
39237
|
+
port1.on("close", () => {
|
39238
|
+
worker.ref();
|
39239
|
+
});
|
39240
|
+
this.workers.add(workerInfo);
|
39241
|
+
}
|
39242
|
+
_onError(worker, workerInfo, err, onlyErrorUnfinishedTasks) {
|
39243
|
+
worker.ref = () => {
|
39244
|
+
};
|
39245
|
+
const taskInfos = [...workerInfo.taskInfos.values()];
|
39246
|
+
workerInfo.taskInfos.clear();
|
39247
|
+
this._removeWorker(workerInfo);
|
39248
|
+
if (workerInfo.isReady() && !this.workerFailsDuringBootstrap) {
|
39249
|
+
this._ensureMinimumWorkers();
|
39250
|
+
} else {
|
39251
|
+
this.workerFailsDuringBootstrap = true;
|
39252
|
+
}
|
39253
|
+
if (taskInfos.length > 0) {
|
39254
|
+
for (const taskInfo of taskInfos) {
|
39255
|
+
taskInfo.done(err, null);
|
39256
|
+
}
|
39257
|
+
} else if (!onlyErrorUnfinishedTasks) {
|
39258
|
+
this.publicInterface.emit("error", err);
|
39259
|
+
}
|
39260
|
+
}
|
39261
|
+
_processPendingMessages() {
|
39262
|
+
if (this.inProcessPendingMessages || this.options.atomics === "disabled") {
|
39263
|
+
return;
|
39264
|
+
}
|
39265
|
+
this.inProcessPendingMessages = true;
|
39266
|
+
try {
|
39267
|
+
for (const workerInfo of this.workers) {
|
39268
|
+
workerInfo.processPendingMessages();
|
39269
|
+
}
|
39270
|
+
} finally {
|
39271
|
+
this.inProcessPendingMessages = false;
|
39272
|
+
}
|
39273
|
+
}
|
39274
|
+
_removeWorker(workerInfo) {
|
39275
|
+
workerInfo.destroy();
|
39276
|
+
this.workers.delete(workerInfo);
|
39277
|
+
}
|
39278
|
+
_onWorkerReady(workerInfo) {
|
39279
|
+
this._onWorkerAvailable(workerInfo);
|
39280
|
+
}
|
39281
|
+
_onWorkerTaskDone(workerInfo) {
|
39282
|
+
this._onWorkerAvailable(workerInfo);
|
39283
|
+
}
|
39284
|
+
_onWorkerAvailable(workerInfo) {
|
39285
|
+
let workers = null;
|
39286
|
+
while (this.taskQueue.size > 0 || this.skipQueue.length > 0) {
|
39287
|
+
const taskInfo = this.skipQueue.shift() || this.taskQueue.shift();
|
39288
|
+
if (workers == null) {
|
39289
|
+
workers = [...this.workers].map((workerInfo2) => workerInfo2.interface);
|
39290
|
+
}
|
39291
|
+
const distributed = this._distributeTask(taskInfo, workers);
|
39292
|
+
if (distributed) {
|
39293
|
+
continue;
|
39294
|
+
} else if (this.workers.size < this.options.maxThreads) {
|
39295
|
+
this._addNewWorker();
|
39296
|
+
continue;
|
39297
|
+
} else {
|
39298
|
+
break;
|
39299
|
+
}
|
39300
|
+
}
|
39301
|
+
if (workerInfo.currentUsage() === 0 && this.workers.size > this.options.minThreads) {
|
39302
|
+
workerInfo.idleTimeout = setTimeout(() => {
|
39303
|
+
node_assert_1.default.strictEqual(workerInfo.currentUsage(), 0);
|
39304
|
+
if (this.workers.size > this.options.minThreads) {
|
39305
|
+
this._removeWorker(workerInfo);
|
39306
|
+
}
|
39307
|
+
}, this.options.idleTimeout).unref();
|
39308
|
+
}
|
39309
|
+
}
|
39310
|
+
_distributeTask(task, workers) {
|
39311
|
+
var _a2;
|
39312
|
+
if (task.aborted)
|
39313
|
+
return false;
|
39314
|
+
const candidate = this.balancer(task.interface, workers);
|
39315
|
+
if (candidate != null && candidate[symbols_1.kWorkerData] != null) {
|
39316
|
+
const now = node_perf_hooks_1.performance.now();
|
39317
|
+
(_a2 = this.waitTime) === null || _a2 === void 0 ? void 0 : _a2.record((0, common_1.toHistogramIntegerNano)(now - task.created));
|
39318
|
+
task.started = now;
|
39319
|
+
candidate[symbols_1.kWorkerData].postTask(task);
|
39320
|
+
this._maybeDrain();
|
39321
|
+
return true;
|
39322
|
+
}
|
39323
|
+
if (task.abortSignal) {
|
39324
|
+
this.skipQueue.push(task);
|
39325
|
+
} else {
|
39326
|
+
this.taskQueue.push(task);
|
39327
|
+
}
|
39328
|
+
return false;
|
39329
|
+
}
|
39330
|
+
runTask(task, options2) {
|
39331
|
+
var _a2;
|
39332
|
+
let { filename, name } = options2;
|
39333
|
+
const { transferList = [] } = options2;
|
39334
|
+
if (filename == null) {
|
39335
|
+
filename = this.options.filename;
|
39336
|
+
}
|
39337
|
+
if (name == null) {
|
39338
|
+
name = this.options.name;
|
39339
|
+
}
|
39340
|
+
if (typeof filename !== "string") {
|
39341
|
+
return Promise.reject(errors_1.Errors.FilenameNotProvided());
|
39342
|
+
}
|
39343
|
+
filename = (0, common_1.maybeFileURLToPath)(filename);
|
39344
|
+
let signal;
|
39345
|
+
if (this.closingUp || this.destroying) {
|
39346
|
+
const closingUpAbortController = new AbortController();
|
39347
|
+
closingUpAbortController.abort("queue is being terminated");
|
39348
|
+
signal = closingUpAbortController.signal;
|
39349
|
+
} else {
|
39350
|
+
signal = (_a2 = options2.signal) !== null && _a2 !== void 0 ? _a2 : null;
|
39351
|
+
}
|
39352
|
+
let resolve;
|
39353
|
+
let reject;
|
39354
|
+
const ret = new Promise((res, rej) => {
|
39355
|
+
resolve = res;
|
39356
|
+
reject = rej;
|
39357
|
+
});
|
39358
|
+
const taskInfo = new task_queue_1.TaskInfo(task, transferList, filename, name, (err, result) => {
|
39359
|
+
var _a3;
|
39360
|
+
this.completed++;
|
39361
|
+
if (taskInfo.started) {
|
39362
|
+
(_a3 = this.runTime) === null || _a3 === void 0 ? void 0 : _a3.record((0, common_1.toHistogramIntegerNano)(node_perf_hooks_1.performance.now() - taskInfo.started));
|
39363
|
+
}
|
39364
|
+
if (err !== null) {
|
39365
|
+
reject(err);
|
39366
|
+
} else {
|
39367
|
+
resolve(result);
|
39368
|
+
}
|
39369
|
+
this._maybeDrain();
|
39370
|
+
}, signal, this.publicInterface.asyncResource.asyncId());
|
39371
|
+
if (signal !== null) {
|
39372
|
+
if (signal.aborted) {
|
39373
|
+
reject(new abort_1.AbortError(signal.reason));
|
39374
|
+
return ret;
|
39375
|
+
}
|
39376
|
+
taskInfo.abortListener = () => {
|
39377
|
+
reject(new abort_1.AbortError(signal.reason));
|
39378
|
+
if (taskInfo.workerInfo !== null) {
|
39379
|
+
this._removeWorker(taskInfo.workerInfo);
|
39380
|
+
this._ensureMinimumWorkers();
|
39381
|
+
} else {
|
39382
|
+
this.taskQueue.remove(taskInfo);
|
39383
|
+
}
|
39384
|
+
};
|
39385
|
+
(0, abort_1.onabort)(signal, taskInfo.abortListener);
|
39386
|
+
}
|
39387
|
+
if (this.taskQueue.size > 0) {
|
39388
|
+
const totalCapacity = this.options.maxQueue + this.pendingCapacity();
|
39389
|
+
if (this.taskQueue.size >= totalCapacity) {
|
39390
|
+
if (this.options.maxQueue === 0) {
|
39391
|
+
reject(errors_1.Errors.NoTaskQueueAvailable());
|
39392
|
+
} else {
|
39393
|
+
reject(errors_1.Errors.TaskQueueAtLimit());
|
39394
|
+
}
|
39395
|
+
} else {
|
39396
|
+
this.taskQueue.push(taskInfo);
|
39397
|
+
}
|
39398
|
+
this._maybeDrain();
|
39399
|
+
return ret;
|
39400
|
+
}
|
39401
|
+
const workers = [...this.workers.readyItems].map((workerInfo) => workerInfo.interface);
|
39402
|
+
const distributed = this._distributeTask(taskInfo, workers);
|
39403
|
+
if (!distributed) {
|
39404
|
+
if (this.workers.size < this.options.maxThreads) {
|
39405
|
+
this._addNewWorker();
|
39406
|
+
}
|
39407
|
+
if (this.options.maxQueue <= 0 && this.pendingCapacity() === 0) {
|
39408
|
+
reject(errors_1.Errors.NoTaskQueueAvailable());
|
39409
|
+
}
|
39410
|
+
}
|
39411
|
+
;
|
39412
|
+
this._maybeDrain();
|
39413
|
+
return ret;
|
39414
|
+
}
|
39415
|
+
pendingCapacity() {
|
39416
|
+
return this.workers.pendingItems.size * this.options.concurrentTasksPerWorker;
|
39417
|
+
}
|
39418
|
+
_maybeDrain() {
|
39419
|
+
const { maxCapacity } = this;
|
39420
|
+
const currentUsage = this.workers.getCurrentUsage();
|
39421
|
+
if (maxCapacity === currentUsage) {
|
39422
|
+
this._needsDrain = true;
|
39423
|
+
this.publicInterface.emit("needsDrain");
|
39424
|
+
} else if (maxCapacity > currentUsage && this._needsDrain) {
|
39425
|
+
this._needsDrain = false;
|
39426
|
+
this.publicInterface.emit("drain");
|
39427
|
+
}
|
39428
|
+
}
|
39429
|
+
async destroy() {
|
39430
|
+
this.destroying = true;
|
39431
|
+
while (this.skipQueue.length > 0) {
|
39432
|
+
const taskInfo = this.skipQueue.shift();
|
39433
|
+
taskInfo.done(new Error("Terminating worker thread"));
|
39434
|
+
}
|
39435
|
+
while (this.taskQueue.size > 0) {
|
39436
|
+
const taskInfo = this.taskQueue.shift();
|
39437
|
+
taskInfo.done(new Error("Terminating worker thread"));
|
39438
|
+
}
|
39439
|
+
const exitEvents = [];
|
39440
|
+
while (this.workers.size > 0) {
|
39441
|
+
const [workerInfo] = this.workers;
|
39442
|
+
exitEvents.push((0, node_events_1.once)(workerInfo.worker, "exit"));
|
39443
|
+
this._removeWorker(workerInfo);
|
39444
|
+
}
|
39445
|
+
try {
|
39446
|
+
await Promise.all(exitEvents);
|
39447
|
+
} finally {
|
39448
|
+
this.destroying = false;
|
39449
|
+
}
|
39450
|
+
}
|
39451
|
+
async close(options2) {
|
39452
|
+
this.closingUp = true;
|
39453
|
+
if (options2.force) {
|
39454
|
+
const skipQueueLength = this.skipQueue.length;
|
39455
|
+
for (let i = 0; i < skipQueueLength; i++) {
|
39456
|
+
const taskInfo = this.skipQueue.shift();
|
39457
|
+
if (taskInfo.workerInfo === null) {
|
39458
|
+
taskInfo.done(new abort_1.AbortError("pool is closed"));
|
39459
|
+
} else {
|
39460
|
+
this.skipQueue.push(taskInfo);
|
39461
|
+
}
|
39462
|
+
}
|
39463
|
+
const taskQueueLength = this.taskQueue.size;
|
39464
|
+
for (let i = 0; i < taskQueueLength; i++) {
|
39465
|
+
const taskInfo = this.taskQueue.shift();
|
39466
|
+
if (taskInfo.workerInfo === null) {
|
39467
|
+
taskInfo.done(new abort_1.AbortError("pool is closed"));
|
39468
|
+
} else {
|
39469
|
+
this.taskQueue.push(taskInfo);
|
39470
|
+
}
|
39471
|
+
}
|
39472
|
+
}
|
39473
|
+
const onPoolFlushed = () => new Promise((resolve) => {
|
39474
|
+
const numberOfWorkers = this.workers.size;
|
39475
|
+
if (numberOfWorkers === 0) {
|
39476
|
+
resolve();
|
39477
|
+
return;
|
39478
|
+
}
|
39479
|
+
let numberOfWorkersDone = 0;
|
39480
|
+
const checkIfWorkerIsDone = (workerInfo) => {
|
39481
|
+
if (workerInfo.taskInfos.size === 0) {
|
39482
|
+
numberOfWorkersDone++;
|
39483
|
+
}
|
39484
|
+
if (numberOfWorkers === numberOfWorkersDone) {
|
39485
|
+
resolve();
|
39486
|
+
}
|
39487
|
+
};
|
39488
|
+
for (const workerInfo of this.workers) {
|
39489
|
+
checkIfWorkerIsDone(workerInfo);
|
39490
|
+
this.workers.onTaskDone(checkIfWorkerIsDone);
|
39491
|
+
}
|
39492
|
+
});
|
39493
|
+
const throwOnTimeOut = async (timeout) => {
|
39494
|
+
await (0, promises_1.setTimeout)(timeout, null, { ref: false });
|
39495
|
+
throw errors_1.Errors.CloseTimeout();
|
39496
|
+
};
|
39497
|
+
try {
|
39498
|
+
await Promise.race([
|
39499
|
+
onPoolFlushed(),
|
39500
|
+
throwOnTimeOut(this.options.closeTimeout)
|
39501
|
+
]);
|
39502
|
+
} catch (error) {
|
39503
|
+
this.publicInterface.emit("error", error);
|
39504
|
+
} finally {
|
39505
|
+
await this.destroy();
|
39506
|
+
this.publicInterface.emit("close");
|
39507
|
+
this.closingUp = false;
|
39508
|
+
}
|
39509
|
+
}
|
39510
|
+
};
|
39511
|
+
var Piscina2 = class _Piscina extends node_events_1.EventEmitterAsyncResource {
|
39512
|
+
constructor(options2 = {}) {
|
39513
|
+
super({ ...options2, name: "Piscina" });
|
39514
|
+
_Piscina_pool.set(this, void 0);
|
39515
|
+
if (typeof options2.filename !== "string" && options2.filename != null) {
|
39516
|
+
throw new TypeError("options.filename must be a string or null");
|
39517
|
+
}
|
39518
|
+
if (typeof options2.name !== "string" && options2.name != null) {
|
39519
|
+
throw new TypeError("options.name must be a string or null");
|
39520
|
+
}
|
39521
|
+
if (options2.minThreads !== void 0 && (typeof options2.minThreads !== "number" || options2.minThreads < 0)) {
|
39522
|
+
throw new TypeError("options.minThreads must be a non-negative integer");
|
39523
|
+
}
|
39524
|
+
if (options2.maxThreads !== void 0 && (typeof options2.maxThreads !== "number" || options2.maxThreads < 1)) {
|
39525
|
+
throw new TypeError("options.maxThreads must be a positive integer");
|
39526
|
+
}
|
39527
|
+
if (options2.minThreads !== void 0 && options2.maxThreads !== void 0 && options2.minThreads > options2.maxThreads) {
|
39528
|
+
throw new RangeError("options.minThreads and options.maxThreads must not conflict");
|
39529
|
+
}
|
39530
|
+
if (options2.idleTimeout !== void 0 && (typeof options2.idleTimeout !== "number" || options2.idleTimeout < 0)) {
|
39531
|
+
throw new TypeError("options.idleTimeout must be a non-negative integer");
|
39532
|
+
}
|
39533
|
+
if (options2.maxQueue !== void 0 && options2.maxQueue !== "auto" && (typeof options2.maxQueue !== "number" || options2.maxQueue < 0)) {
|
39534
|
+
throw new TypeError("options.maxQueue must be a non-negative integer");
|
39535
|
+
}
|
39536
|
+
if (options2.concurrentTasksPerWorker !== void 0 && (typeof options2.concurrentTasksPerWorker !== "number" || options2.concurrentTasksPerWorker < 1)) {
|
39537
|
+
throw new TypeError("options.concurrentTasksPerWorker must be a positive integer");
|
39538
|
+
}
|
39539
|
+
if (options2.atomics != null && (typeof options2.atomics !== "string" || !["sync", "async", "disabled"].includes(options2.atomics))) {
|
39540
|
+
throw new TypeError("options.atomics should be a value of sync, sync or disabled.");
|
39541
|
+
}
|
39542
|
+
if (options2.resourceLimits !== void 0 && (typeof options2.resourceLimits !== "object" || options2.resourceLimits === null)) {
|
39543
|
+
throw new TypeError("options.resourceLimits must be an object");
|
39544
|
+
}
|
39545
|
+
if (options2.taskQueue !== void 0 && !(0, task_queue_1.isTaskQueue)(options2.taskQueue)) {
|
39546
|
+
throw new TypeError("options.taskQueue must be a TaskQueue object");
|
39547
|
+
}
|
39548
|
+
if (options2.niceIncrement !== void 0 && (typeof options2.niceIncrement !== "number" || options2.niceIncrement < 0 && process.platform !== "win32")) {
|
39549
|
+
throw new TypeError("options.niceIncrement must be a non-negative integer on Unix systems");
|
39550
|
+
}
|
39551
|
+
if (options2.trackUnmanagedFds !== void 0 && typeof options2.trackUnmanagedFds !== "boolean") {
|
39552
|
+
throw new TypeError("options.trackUnmanagedFds must be a boolean value");
|
39553
|
+
}
|
39554
|
+
if (options2.closeTimeout !== void 0 && (typeof options2.closeTimeout !== "number" || options2.closeTimeout < 0)) {
|
39555
|
+
throw new TypeError("options.closeTimeout must be a non-negative integer");
|
39556
|
+
}
|
39557
|
+
if (options2.loadBalancer !== void 0 && (typeof options2.loadBalancer !== "function" || options2.loadBalancer.length < 1)) {
|
39558
|
+
throw new TypeError("options.loadBalancer must be a function with at least two args");
|
39559
|
+
}
|
39560
|
+
if (options2.workerHistogram !== void 0 && typeof options2.workerHistogram !== "boolean") {
|
39561
|
+
throw new TypeError("options.workerHistogram must be a boolean");
|
39562
|
+
}
|
39563
|
+
__classPrivateFieldSet(this, _Piscina_pool, new ThreadPool(this, options2), "f");
|
39564
|
+
}
|
39565
|
+
run(task, options2 = kDefaultRunOptions) {
|
39566
|
+
if (options2 === null || typeof options2 !== "object") {
|
39567
|
+
return Promise.reject(new TypeError("options must be an object"));
|
39568
|
+
}
|
39569
|
+
const { transferList, filename, name, signal } = options2;
|
39570
|
+
if (transferList !== void 0 && !Array.isArray(transferList)) {
|
39571
|
+
return Promise.reject(new TypeError("transferList argument must be an Array"));
|
39572
|
+
}
|
39573
|
+
if (filename != null && typeof filename !== "string") {
|
39574
|
+
return Promise.reject(new TypeError("filename argument must be a string"));
|
39575
|
+
}
|
39576
|
+
if (name != null && typeof name !== "string") {
|
39577
|
+
return Promise.reject(new TypeError("name argument must be a string"));
|
39578
|
+
}
|
39579
|
+
if (signal != null && typeof signal !== "object") {
|
39580
|
+
return Promise.reject(new TypeError("signal argument must be an object"));
|
39581
|
+
}
|
39582
|
+
return __classPrivateFieldGet(this, _Piscina_pool, "f").runTask(task, { transferList, filename, name, signal });
|
39583
|
+
}
|
39584
|
+
async close(options2 = kDefaultCloseOptions) {
|
39585
|
+
if (options2 === null || typeof options2 !== "object") {
|
39586
|
+
throw TypeError("options must be an object");
|
39587
|
+
}
|
39588
|
+
let { force } = options2;
|
39589
|
+
if (force !== void 0 && typeof force !== "boolean") {
|
39590
|
+
return Promise.reject(new TypeError("force argument must be a boolean"));
|
39591
|
+
}
|
39592
|
+
force !== null && force !== void 0 ? force : force = kDefaultCloseOptions.force;
|
39593
|
+
return __classPrivateFieldGet(this, _Piscina_pool, "f").close({
|
39594
|
+
force
|
39595
|
+
});
|
39596
|
+
}
|
39597
|
+
destroy() {
|
39598
|
+
return __classPrivateFieldGet(this, _Piscina_pool, "f").destroy();
|
39599
|
+
}
|
39600
|
+
get maxThreads() {
|
39601
|
+
return __classPrivateFieldGet(this, _Piscina_pool, "f").options.maxThreads;
|
39602
|
+
}
|
39603
|
+
get minThreads() {
|
39604
|
+
return __classPrivateFieldGet(this, _Piscina_pool, "f").options.minThreads;
|
39605
|
+
}
|
39606
|
+
get options() {
|
39607
|
+
return __classPrivateFieldGet(this, _Piscina_pool, "f").options;
|
39608
|
+
}
|
39609
|
+
get threads() {
|
39610
|
+
const ret = [];
|
39611
|
+
for (const workerInfo of __classPrivateFieldGet(this, _Piscina_pool, "f").workers) {
|
39612
|
+
ret.push(workerInfo.worker);
|
39613
|
+
}
|
39614
|
+
return ret;
|
39615
|
+
}
|
39616
|
+
get queueSize() {
|
39617
|
+
const pool = __classPrivateFieldGet(this, _Piscina_pool, "f");
|
39618
|
+
return Math.max(pool.taskQueue.size - pool.pendingCapacity(), 0);
|
39619
|
+
}
|
39620
|
+
get completed() {
|
39621
|
+
return __classPrivateFieldGet(this, _Piscina_pool, "f").completed;
|
39622
|
+
}
|
39623
|
+
get waitTime() {
|
39624
|
+
if (!__classPrivateFieldGet(this, _Piscina_pool, "f").waitTime) {
|
39625
|
+
return null;
|
39626
|
+
}
|
39627
|
+
return (0, common_1.createHistogramSummary)(__classPrivateFieldGet(this, _Piscina_pool, "f").waitTime);
|
39628
|
+
}
|
39629
|
+
get runTime() {
|
39630
|
+
if (!__classPrivateFieldGet(this, _Piscina_pool, "f").runTime) {
|
39631
|
+
return null;
|
39632
|
+
}
|
39633
|
+
return (0, common_1.createHistogramSummary)(__classPrivateFieldGet(this, _Piscina_pool, "f").runTime);
|
39634
|
+
}
|
39635
|
+
get utilization() {
|
39636
|
+
if (!__classPrivateFieldGet(this, _Piscina_pool, "f").runTime) {
|
39637
|
+
return 0;
|
39638
|
+
}
|
39639
|
+
const count = __classPrivateFieldGet(this, _Piscina_pool, "f").runTime.count;
|
39640
|
+
if (count === 0) {
|
39641
|
+
return 0;
|
39642
|
+
}
|
39643
|
+
if (!__classPrivateFieldGet(this, _Piscina_pool, "f").runTime) {
|
39644
|
+
return 0;
|
39645
|
+
}
|
39646
|
+
const capacity = this.duration * __classPrivateFieldGet(this, _Piscina_pool, "f").options.maxThreads;
|
39647
|
+
const totalMeanRuntime = __classPrivateFieldGet(this, _Piscina_pool, "f").runTime.mean / 1e3 * count;
|
39648
|
+
return totalMeanRuntime / capacity;
|
39649
|
+
}
|
39650
|
+
get duration() {
|
39651
|
+
return node_perf_hooks_1.performance.now() - __classPrivateFieldGet(this, _Piscina_pool, "f").start;
|
39652
|
+
}
|
39653
|
+
get needsDrain() {
|
39654
|
+
return __classPrivateFieldGet(this, _Piscina_pool, "f")._needsDrain;
|
39655
|
+
}
|
39656
|
+
static get isWorkerThread() {
|
39657
|
+
return common_1.commonState.isWorkerThread;
|
39658
|
+
}
|
39659
|
+
static get workerData() {
|
39660
|
+
return common_1.commonState.workerData;
|
39661
|
+
}
|
39662
|
+
static get version() {
|
39663
|
+
return package_json_1.version;
|
39664
|
+
}
|
39665
|
+
static get Piscina() {
|
39666
|
+
return _Piscina;
|
39667
|
+
}
|
39668
|
+
static get FixedQueue() {
|
39669
|
+
return task_queue_1.FixedQueue;
|
39670
|
+
}
|
39671
|
+
static get ArrayTaskQueue() {
|
39672
|
+
return task_queue_1.ArrayTaskQueue;
|
39673
|
+
}
|
39674
|
+
static move(val) {
|
39675
|
+
if (val != null && typeof val === "object" && typeof val !== "function") {
|
39676
|
+
if (!(0, common_1.isTransferable)(val)) {
|
39677
|
+
if (node_util_1.types.isArrayBufferView(val)) {
|
39678
|
+
val = new ArrayBufferViewTransferable(val);
|
39679
|
+
} else {
|
39680
|
+
val = new DirectlyTransferable(val);
|
39681
|
+
}
|
39682
|
+
}
|
39683
|
+
(0, common_1.markMovable)(val);
|
39684
|
+
}
|
39685
|
+
return val;
|
39686
|
+
}
|
39687
|
+
static get transferableSymbol() {
|
39688
|
+
return symbols_1.kTransferable;
|
39689
|
+
}
|
39690
|
+
static get valueSymbol() {
|
39691
|
+
return symbols_1.kValue;
|
39692
|
+
}
|
39693
|
+
static get queueOptionsSymbol() {
|
39694
|
+
return symbols_1.kQueueOptions;
|
39695
|
+
}
|
39696
|
+
};
|
39697
|
+
exports.Piscina = Piscina2;
|
39698
|
+
_Piscina_pool = /* @__PURE__ */ new WeakMap();
|
39699
|
+
exports.default = Piscina2;
|
39700
|
+
exports.move = Piscina2.move;
|
39701
|
+
exports.isWorkerThread = Piscina2.isWorkerThread;
|
39702
|
+
exports.workerData = Piscina2.workerData;
|
39703
|
+
}
|
39704
|
+
});
|
39705
|
+
|
39706
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/main.js
|
39707
|
+
var require_main = __commonJS({
|
39708
|
+
"../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/main.js"(exports, module) {
|
39709
|
+
"use strict";
|
39710
|
+
var __importDefault = exports && exports.__importDefault || function(mod2) {
|
39711
|
+
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
39712
|
+
};
|
39713
|
+
var index_1 = __importDefault(require_dist());
|
39714
|
+
module.exports = index_1.default;
|
39715
|
+
}
|
39716
|
+
});
|
39717
|
+
|
38241
39718
|
// src/processor-runner.ts
|
38242
39719
|
var import_fs_extra2 = __toESM(require_lib4(), 1);
|
38243
39720
|
var import_grpc_js = __toESM(require_src(), 1);
|
@@ -38950,8 +40427,8 @@ function commandLineArgs(optionDefinitions2, options2) {
|
|
38950
40427
|
var command_line_args_default = commandLineArgs;
|
38951
40428
|
|
38952
40429
|
// src/processor-runner.ts
|
38953
|
-
var
|
38954
|
-
var
|
40430
|
+
var import_nice_grpc2 = __toESM(require_lib2(), 1);
|
40431
|
+
var import_nice_grpc_error_details2 = __toESM(require_lib3(), 1);
|
38955
40432
|
var import_nice_grpc_opentelemetry = __toESM(require_lib5(), 1);
|
38956
40433
|
import http2 from "http";
|
38957
40434
|
import { Session } from "node:inspector/promises";
|
@@ -39316,6 +40793,199 @@ var ActionServer = class {
|
|
39316
40793
|
};
|
39317
40794
|
import("node:process").then((p) => p.stdout.write(""));
|
39318
40795
|
|
40796
|
+
// src/service-manager.ts
|
40797
|
+
var import_nice_grpc = __toESM(require_lib2(), 1);
|
40798
|
+
var import_nice_grpc_error_details = __toESM(require_lib3(), 1);
|
40799
|
+
|
40800
|
+
// ../../node_modules/.pnpm/piscina@5.0.0-alpha.0/node_modules/piscina/dist/esm-wrapper.mjs
|
40801
|
+
var import_main = __toESM(require_main(), 1);
|
40802
|
+
var ArrayTaskQueue = import_main.default.ArrayTaskQueue;
|
40803
|
+
var FixedQueue = import_main.default.FixedQueue;
|
40804
|
+
var Piscina = import_main.default.Piscina;
|
40805
|
+
var isWorkerThread = import_main.default.isWorkerThread;
|
40806
|
+
var move = import_main.default.move;
|
40807
|
+
var queueOptionsSymbol = import_main.default.queueOptionsSymbol;
|
40808
|
+
var transferableSymbol = import_main.default.transferableSymbol;
|
40809
|
+
var valueSymbol = import_main.default.valueSymbol;
|
40810
|
+
var version = import_main.default.version;
|
40811
|
+
var workerData = import_main.default.workerData;
|
40812
|
+
|
40813
|
+
// src/service-manager.ts
|
40814
|
+
var import_rxjs = __toESM(require_cjs(), 1);
|
40815
|
+
var { process_binding_count, process_binding_time, process_binding_error } = processMetrics;
|
40816
|
+
BigInt.prototype.toJSON = function() {
|
40817
|
+
return this.toString();
|
40818
|
+
};
|
40819
|
+
var ServiceManager = class {
|
40820
|
+
constructor(options2, loader2, shutdownHandler) {
|
40821
|
+
this.options = options2;
|
40822
|
+
this.loader = loader2;
|
40823
|
+
this.shutdownHandler = shutdownHandler;
|
40824
|
+
this.pool = new Piscina({
|
40825
|
+
maxThreads: options2.worker,
|
40826
|
+
minThreads: options2.worker,
|
40827
|
+
filename: new URL("./service-worker.js", import.meta.url).href
|
40828
|
+
});
|
40829
|
+
}
|
40830
|
+
started = false;
|
40831
|
+
// When there is unhandled error, stop process and return unavailable error
|
40832
|
+
unhandled;
|
40833
|
+
// private processorConfig: ProcessConfigResponse
|
40834
|
+
pool;
|
40835
|
+
async *preprocessBindingsStream(requests, context2) {
|
40836
|
+
throw new Error("not supported");
|
40837
|
+
}
|
40838
|
+
async getConfig(request3, context2) {
|
40839
|
+
if (!this.started) {
|
40840
|
+
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.UNAVAILABLE, "Service Not started.");
|
40841
|
+
}
|
40842
|
+
const bc = new BroadcastChannel("configure_channel");
|
40843
|
+
bc.postMessage(request3);
|
40844
|
+
const newConfig = ProcessConfigResponse.fromPartial({});
|
40845
|
+
await PluginManager.INSTANCE.configure(newConfig);
|
40846
|
+
return newConfig;
|
40847
|
+
}
|
40848
|
+
//
|
40849
|
+
// async configure() {
|
40850
|
+
// this.processorConfig = ProcessConfigResponse.fromPartial({})
|
40851
|
+
// await PluginManager.INSTANCE.configure(this.processorConfig)
|
40852
|
+
// }
|
40853
|
+
async start(request3, context2) {
|
40854
|
+
if (this.started) {
|
40855
|
+
return {};
|
40856
|
+
}
|
40857
|
+
try {
|
40858
|
+
await this.loader();
|
40859
|
+
} catch (e) {
|
40860
|
+
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "Failed to load processor: " + errorString(e));
|
40861
|
+
}
|
40862
|
+
const bc = new BroadcastChannel("start_channel");
|
40863
|
+
bc.postMessage(request3);
|
40864
|
+
await PluginManager.INSTANCE.start(request3);
|
40865
|
+
this.started = true;
|
40866
|
+
return {};
|
40867
|
+
}
|
40868
|
+
async stop(request3, context2) {
|
40869
|
+
console.log("Server Shutting down in 5 seconds");
|
40870
|
+
if (this.shutdownHandler) {
|
40871
|
+
setTimeout(this.shutdownHandler, 5e3);
|
40872
|
+
}
|
40873
|
+
return {};
|
40874
|
+
}
|
40875
|
+
async processBindings(request3, options2) {
|
40876
|
+
const promises = [];
|
40877
|
+
for (const binding of request3.bindings) {
|
40878
|
+
const promise2 = this.processBinding(binding, void 0);
|
40879
|
+
if (GLOBAL_CONFIG.execution.sequential) {
|
40880
|
+
await promise2;
|
40881
|
+
}
|
40882
|
+
promises.push(promise2);
|
40883
|
+
}
|
40884
|
+
let promise;
|
40885
|
+
try {
|
40886
|
+
promise = await Promise.all(promises);
|
40887
|
+
processMetrics.process_binding_count.add(request3.bindings.length);
|
40888
|
+
} catch (e) {
|
40889
|
+
processMetrics.process_binding_error.add(request3.bindings.length);
|
40890
|
+
throw e;
|
40891
|
+
}
|
40892
|
+
const result = mergeProcessResults(promise);
|
40893
|
+
return {
|
40894
|
+
result
|
40895
|
+
};
|
40896
|
+
}
|
40897
|
+
async processBinding(request3, preparedData, options2) {
|
40898
|
+
if (!this.started) {
|
40899
|
+
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.UNAVAILABLE, "Service Not started.");
|
40900
|
+
}
|
40901
|
+
if (this.unhandled) {
|
40902
|
+
throw new import_nice_grpc_error_details.RichServerError(
|
40903
|
+
import_nice_grpc.Status.UNAVAILABLE,
|
40904
|
+
"Unhandled exception/rejection in previous request: " + errorString(this.unhandled),
|
40905
|
+
[
|
40906
|
+
import_nice_grpc_error_details.DebugInfo.fromPartial({
|
40907
|
+
detail: this.unhandled.message,
|
40908
|
+
stackEntries: this.unhandled.stack?.split("\n")
|
40909
|
+
})
|
40910
|
+
]
|
40911
|
+
);
|
40912
|
+
}
|
40913
|
+
return await this.pool.run({ request: request3, preparedData }, { name: "processBinding" });
|
40914
|
+
}
|
40915
|
+
async *processBindingsStream(requests, context2) {
|
40916
|
+
if (!this.started) {
|
40917
|
+
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.UNAVAILABLE, "Service Not started.");
|
40918
|
+
}
|
40919
|
+
const subject = new import_rxjs.Subject();
|
40920
|
+
this.handleRequests(requests, subject).then(() => {
|
40921
|
+
subject.complete();
|
40922
|
+
}).catch((e) => {
|
40923
|
+
console.error(e);
|
40924
|
+
subject.error(e);
|
40925
|
+
});
|
40926
|
+
yield* from(subject).pipe(withAbort(context2.signal));
|
40927
|
+
}
|
40928
|
+
async handleRequests(requests, subject) {
|
40929
|
+
const contexts = new Contexts();
|
40930
|
+
for await (const request3 of requests) {
|
40931
|
+
try {
|
40932
|
+
if (request3.binding) {
|
40933
|
+
process_binding_count.add(1);
|
40934
|
+
if (request3.binding.handlerType === HandlerType.UNKNOWN) {
|
40935
|
+
subject.next({
|
40936
|
+
processId: request3.processId,
|
40937
|
+
result: ProcessResult.create()
|
40938
|
+
});
|
40939
|
+
continue;
|
40940
|
+
}
|
40941
|
+
const binding = request3.binding;
|
40942
|
+
const start = Date.now();
|
40943
|
+
await this.processBinding(binding, void 0).then(async (result) => {
|
40944
|
+
subject.next({
|
40945
|
+
result,
|
40946
|
+
processId: request3.processId
|
40947
|
+
});
|
40948
|
+
}).catch((e) => {
|
40949
|
+
console.debug(e);
|
40950
|
+
process_binding_error.add(1);
|
40951
|
+
}).finally(() => {
|
40952
|
+
const cost = Date.now() - start;
|
40953
|
+
process_binding_time.add(cost);
|
40954
|
+
contexts.delete(request3.processId);
|
40955
|
+
});
|
40956
|
+
}
|
40957
|
+
if (request3.dbResult) {
|
40958
|
+
const dbContext = contexts.get(request3.processId);
|
40959
|
+
try {
|
40960
|
+
dbContext?.result(request3.dbResult);
|
40961
|
+
} catch (e) {
|
40962
|
+
subject.error(new Error("db result error, process should stop"));
|
40963
|
+
}
|
40964
|
+
}
|
40965
|
+
} catch (e) {
|
40966
|
+
console.error("unexpect error during handle loop", e);
|
40967
|
+
}
|
40968
|
+
}
|
40969
|
+
}
|
40970
|
+
};
|
40971
|
+
var Contexts = class {
|
40972
|
+
contexts = /* @__PURE__ */ new Map();
|
40973
|
+
get(processId) {
|
40974
|
+
return this.contexts.get(processId);
|
40975
|
+
}
|
40976
|
+
new(processId, subject) {
|
40977
|
+
const context2 = new StoreContext(subject, processId);
|
40978
|
+
this.contexts.set(processId, context2);
|
40979
|
+
return context2;
|
40980
|
+
}
|
40981
|
+
delete(processId) {
|
40982
|
+
const context2 = this.get(processId);
|
40983
|
+
context2?.close();
|
40984
|
+
this.contexts.delete(processId);
|
40985
|
+
}
|
40986
|
+
};
|
40987
|
+
import("node:process").then((p) => p.stdout.write(""));
|
40988
|
+
|
39319
40989
|
// src/processor-runner.ts
|
39320
40990
|
var optionDefinitions = [
|
39321
40991
|
{ name: "target", type: String, defaultOption: true },
|
@@ -39334,7 +41004,8 @@ var optionDefinitions = [
|
|
39334
41004
|
{ name: "log-format", type: String, defaultValue: "console" },
|
39335
41005
|
{ name: "debug", type: Boolean, defaultValue: false },
|
39336
41006
|
{ name: "otlp-debug", type: Boolean, defaultValue: false },
|
39337
|
-
{ name: "start-action-server", type: Boolean, defaultValue: false }
|
41007
|
+
{ name: "start-action-server", type: Boolean, defaultValue: false },
|
41008
|
+
{ name: "worker", type: Number, defaultValue: 8 }
|
39338
41009
|
];
|
39339
41010
|
var options = command_line_args_default(optionDefinitions, { partial: true });
|
39340
41011
|
var logLevel = process.env["LOG_LEVEL"]?.toUpperCase();
|
@@ -39375,12 +41046,16 @@ if (options["start-action-server"]) {
|
|
39375
41046
|
server = new ActionServer(loader);
|
39376
41047
|
server.listen(options.port);
|
39377
41048
|
} else {
|
39378
|
-
server = (0,
|
41049
|
+
server = (0, import_nice_grpc2.createServer)({
|
39379
41050
|
"grpc.max_send_message_length": 768 * 1024 * 1024,
|
39380
41051
|
"grpc.max_receive_message_length": 768 * 1024 * 1024,
|
39381
41052
|
"grpc.default_compression_algorithm": import_grpc_js.compressionAlgorithms.gzip
|
39382
|
-
}).use((0, import_nice_grpc_opentelemetry.openTelemetryServerMiddleware)()).use(
|
39383
|
-
|
41053
|
+
}).use((0, import_nice_grpc_opentelemetry.openTelemetryServerMiddleware)()).use(import_nice_grpc_error_details2.errorDetailsServerMiddleware);
|
41054
|
+
if (options.worker > 1) {
|
41055
|
+
baseService = new ServiceManager(options, loader, server.shutdown);
|
41056
|
+
} else {
|
41057
|
+
baseService = new ProcessorServiceImpl(loader, server.shutdown);
|
41058
|
+
}
|
39384
41059
|
const service = new FullProcessorServiceImpl(baseService);
|
39385
41060
|
server.add(ProcessorDefinition, service);
|
39386
41061
|
server.listen("0.0.0.0:" + options.port);
|
@@ -39469,6 +41144,9 @@ function shutdownServers(exitCode) {
|
|
39469
41144
|
});
|
39470
41145
|
}
|
39471
41146
|
import("node:process").then((p) => p.stdout.write(""));
|
41147
|
+
export {
|
41148
|
+
optionDefinitions
|
41149
|
+
};
|
39472
41150
|
/*! Bundled license information:
|
39473
41151
|
|
39474
41152
|
safe-buffer/index.js:
|