@sentio/runtime 2.59.0-rc.39 → 2.59.0-rc.40
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-FO2V2K7T.js → chunk-3SLKMZUX.js} +1 -1
- package/lib/{chunk-C4IDZGJI.js → chunk-ELSE7PSY.js} +4318 -4307
- package/lib/{chunk-C4IDZGJI.js.map → chunk-ELSE7PSY.js.map} +1 -1
- package/lib/{chunk-CPLWSUD7.js → chunk-FDZMT76B.js} +2 -2
- package/lib/index.d.ts +3 -1
- package/lib/index.js +2 -2
- package/lib/processor-runner.js +69 -135
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.d.ts +5 -6
- package/lib/service-worker.js +28 -92
- package/lib/service-worker.js.map +1 -1
- package/lib/test-processor.test.js.map +1 -1
- package/package.json +1 -1
- package/src/processor-runner.ts +9 -3
- package/src/service-manager.ts +43 -140
- package/src/service-worker.ts +28 -101
- package/src/service.ts +60 -49
- /package/lib/{chunk-FO2V2K7T.js.map → chunk-3SLKMZUX.js.map} +0 -0
- /package/lib/{chunk-CPLWSUD7.js.map → chunk-FDZMT76B.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
__require,
|
7
7
|
__toCommonJS,
|
8
8
|
__toESM
|
9
|
-
} from "./chunk-
|
9
|
+
} from "./chunk-3SLKMZUX.js";
|
10
10
|
|
11
11
|
// ../../node_modules/.pnpm/logform@2.6.0/node_modules/logform/format.js
|
12
12
|
var require_format = __commonJS({
|
@@ -10972,4 +10972,4 @@ export {
|
|
10972
10972
|
safe-buffer/index.js:
|
10973
10973
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
10974
10974
|
*/
|
10975
|
-
//# sourceMappingURL=chunk-
|
10975
|
+
//# sourceMappingURL=chunk-FDZMT76B.js.map
|
package/lib/index.d.ts
CHANGED
@@ -166,7 +166,7 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
166
166
|
private readonly enablePreprocess;
|
167
167
|
private preparedData;
|
168
168
|
readonly enablePartition: boolean;
|
169
|
-
constructor(loader: () => Promise<any>, shutdownHandler?: () => void);
|
169
|
+
constructor(loader: () => Promise<any>, options?: any, shutdownHandler?: () => void);
|
170
170
|
getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse>;
|
171
171
|
start(request: StartRequest, context: CallContext): Promise<Empty>;
|
172
172
|
stop(request: Empty, context: CallContext): Promise<Empty>;
|
@@ -665,7 +665,9 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
665
665
|
} | undefined;
|
666
666
|
} | undefined;
|
667
667
|
}, void, undefined>;
|
668
|
+
private dbContexts;
|
668
669
|
protected handleRequests(requests: AsyncIterable<ProcessStreamRequest>, subject: Subject<DeepPartial$1<ProcessStreamResponse>>): Promise<void>;
|
670
|
+
handleRequest(request: ProcessStreamRequest, lastBinding: DataBinding$1 | undefined, subject: Subject<DeepPartial$1<ProcessStreamResponse>>): Promise<void>;
|
669
671
|
private startProcess;
|
670
672
|
}
|
671
673
|
declare function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType$1): void;
|
package/lib/index.js
CHANGED
@@ -29,11 +29,11 @@ import {
|
|
29
29
|
providerMetrics,
|
30
30
|
recordRuntimeInfo,
|
31
31
|
timeoutError
|
32
|
-
} from "./chunk-
|
32
|
+
} from "./chunk-ELSE7PSY.js";
|
33
33
|
import {
|
34
34
|
Plugin,
|
35
35
|
PluginManager
|
36
|
-
} from "./chunk-
|
36
|
+
} from "./chunk-3SLKMZUX.js";
|
37
37
|
|
38
38
|
// src/chain-config.ts
|
39
39
|
import("node:process").then((p) => p.stdout.write(""));
|
package/lib/processor-runner.js
CHANGED
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
} from "./chunk-6XHWJ2VS.js";
|
6
6
|
import {
|
7
7
|
setupLogger
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-FDZMT76B.js";
|
9
9
|
import {
|
10
10
|
DiagConsoleLogger,
|
11
11
|
DiagLogLevel,
|
@@ -35,7 +35,6 @@ import {
|
|
35
35
|
isValidTraceId,
|
36
36
|
metrics,
|
37
37
|
parseSemver,
|
38
|
-
processMetrics,
|
39
38
|
propagation,
|
40
39
|
require_lib,
|
41
40
|
require_lib2,
|
@@ -44,13 +43,11 @@ import {
|
|
44
43
|
require_lodash,
|
45
44
|
require_src,
|
46
45
|
trace
|
47
|
-
} from "./chunk-
|
46
|
+
} from "./chunk-ELSE7PSY.js";
|
48
47
|
import {
|
49
48
|
ExecutionConfig,
|
50
|
-
HandlerType,
|
51
49
|
PluginManager,
|
52
50
|
ProcessConfigResponse,
|
53
|
-
ProcessResult,
|
54
51
|
ProcessorDefinition,
|
55
52
|
StartRequest,
|
56
53
|
__commonJS,
|
@@ -60,7 +57,7 @@ import {
|
|
60
57
|
__toCommonJS,
|
61
58
|
__toESM,
|
62
59
|
require_minimal2 as require_minimal
|
63
|
-
} from "./chunk-
|
60
|
+
} from "./chunk-3SLKMZUX.js";
|
64
61
|
|
65
62
|
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.25.1/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js
|
66
63
|
// @__NO_SIDE_EFFECTS__
|
@@ -12966,19 +12963,19 @@ var require_root = __commonJS({
|
|
12966
12963
|
return Span2;
|
12967
12964
|
}();
|
12968
12965
|
v1.Status = function() {
|
12969
|
-
function
|
12966
|
+
function Status(properties) {
|
12970
12967
|
if (properties) {
|
12971
12968
|
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
12972
12969
|
if (properties[keys[i]] != null)
|
12973
12970
|
this[keys[i]] = properties[keys[i]];
|
12974
12971
|
}
|
12975
12972
|
}
|
12976
|
-
|
12977
|
-
|
12978
|
-
|
12979
|
-
return new
|
12973
|
+
Status.prototype.message = null;
|
12974
|
+
Status.prototype.code = null;
|
12975
|
+
Status.create = function create(properties) {
|
12976
|
+
return new Status(properties);
|
12980
12977
|
};
|
12981
|
-
|
12978
|
+
Status.encode = function encode(message, writer) {
|
12982
12979
|
if (!writer)
|
12983
12980
|
writer = $Writer.create();
|
12984
12981
|
if (message.message != null && Object.hasOwnProperty.call(message, "message"))
|
@@ -12993,10 +12990,10 @@ var require_root = __commonJS({
|
|
12993
12990
|
).int32(message.code);
|
12994
12991
|
return writer;
|
12995
12992
|
};
|
12996
|
-
|
12993
|
+
Status.encodeDelimited = function encodeDelimited(message, writer) {
|
12997
12994
|
return this.encode(message, writer).ldelim();
|
12998
12995
|
};
|
12999
|
-
|
12996
|
+
Status.decode = function decode(reader, length) {
|
13000
12997
|
if (!(reader instanceof $Reader))
|
13001
12998
|
reader = $Reader.create(reader);
|
13002
12999
|
var end = length === void 0 ? reader.len : reader.pos + length, message = new $root.opentelemetry.proto.trace.v1.Status();
|
@@ -13018,12 +13015,12 @@ var require_root = __commonJS({
|
|
13018
13015
|
}
|
13019
13016
|
return message;
|
13020
13017
|
};
|
13021
|
-
|
13018
|
+
Status.decodeDelimited = function decodeDelimited(reader) {
|
13022
13019
|
if (!(reader instanceof $Reader))
|
13023
13020
|
reader = new $Reader(reader);
|
13024
13021
|
return this.decode(reader, reader.uint32());
|
13025
13022
|
};
|
13026
|
-
|
13023
|
+
Status.verify = function verify(message) {
|
13027
13024
|
if (typeof message !== "object" || message === null)
|
13028
13025
|
return "object expected";
|
13029
13026
|
if (message.message != null && message.hasOwnProperty("message")) {
|
@@ -13041,7 +13038,7 @@ var require_root = __commonJS({
|
|
13041
13038
|
}
|
13042
13039
|
return null;
|
13043
13040
|
};
|
13044
|
-
|
13041
|
+
Status.fromObject = function fromObject(object) {
|
13045
13042
|
if (object instanceof $root.opentelemetry.proto.trace.v1.Status)
|
13046
13043
|
return object;
|
13047
13044
|
var message = new $root.opentelemetry.proto.trace.v1.Status();
|
@@ -13069,7 +13066,7 @@ var require_root = __commonJS({
|
|
13069
13066
|
}
|
13070
13067
|
return message;
|
13071
13068
|
};
|
13072
|
-
|
13069
|
+
Status.toObject = function toObject(message, options2) {
|
13073
13070
|
if (!options2)
|
13074
13071
|
options2 = {};
|
13075
13072
|
var object = {};
|
@@ -13083,23 +13080,23 @@ var require_root = __commonJS({
|
|
13083
13080
|
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;
|
13084
13081
|
return object;
|
13085
13082
|
};
|
13086
|
-
|
13083
|
+
Status.prototype.toJSON = function toJSON() {
|
13087
13084
|
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
13088
13085
|
};
|
13089
|
-
|
13086
|
+
Status.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
13090
13087
|
if (typeUrlPrefix === void 0) {
|
13091
13088
|
typeUrlPrefix = "type.googleapis.com";
|
13092
13089
|
}
|
13093
13090
|
return typeUrlPrefix + "/opentelemetry.proto.trace.v1.Status";
|
13094
13091
|
};
|
13095
|
-
|
13092
|
+
Status.StatusCode = function() {
|
13096
13093
|
var valuesById = {}, values = Object.create(valuesById);
|
13097
13094
|
values[valuesById[0] = "STATUS_CODE_UNSET"] = 0;
|
13098
13095
|
values[valuesById[1] = "STATUS_CODE_OK"] = 1;
|
13099
13096
|
values[valuesById[2] = "STATUS_CODE_ERROR"] = 2;
|
13100
13097
|
return values;
|
13101
13098
|
}();
|
13102
|
-
return
|
13099
|
+
return Status;
|
13103
13100
|
}();
|
13104
13101
|
return v1;
|
13105
13102
|
}();
|
@@ -25945,7 +25942,7 @@ function commandLineArgs(optionDefinitions2, options2) {
|
|
25945
25942
|
var command_line_args_default = commandLineArgs;
|
25946
25943
|
|
25947
25944
|
// src/processor-runner.ts
|
25948
|
-
var
|
25945
|
+
var import_nice_grpc = __toESM(require_lib3(), 1);
|
25949
25946
|
var import_nice_grpc_error_details = __toESM(require_lib4(), 1);
|
25950
25947
|
var import_nice_grpc_opentelemetry = __toESM(require_lib5(), 1);
|
25951
25948
|
import http2 from "http";
|
@@ -26287,16 +26284,14 @@ var ActionServer = class {
|
|
26287
26284
|
import("node:process").then((p) => p.stdout.write(""));
|
26288
26285
|
|
26289
26286
|
// src/service-manager.ts
|
26290
|
-
var import_nice_grpc = __toESM(require_lib3(), 1);
|
26291
26287
|
import { Piscina } from "piscina";
|
26292
26288
|
import { MessageChannel } from "node:worker_threads";
|
26293
|
-
var { process_binding_count, process_binding_time, process_binding_error } = processMetrics;
|
26294
26289
|
BigInt.prototype.toJSON = function() {
|
26295
26290
|
return this.toString();
|
26296
26291
|
};
|
26297
26292
|
var ServiceManager = class extends ProcessorServiceImpl {
|
26298
|
-
constructor(
|
26299
|
-
super(loader2, shutdownHandler);
|
26293
|
+
constructor(loader2, options2, shutdownHandler) {
|
26294
|
+
super(loader2, options2, shutdownHandler);
|
26300
26295
|
this.options = options2;
|
26301
26296
|
this.workerData.options = options2;
|
26302
26297
|
}
|
@@ -26324,89 +26319,43 @@ var ServiceManager = class extends ProcessorServiceImpl {
|
|
26324
26319
|
}
|
26325
26320
|
contexts = new Contexts();
|
26326
26321
|
async handleRequests(requests, subject) {
|
26327
|
-
|
26322
|
+
if (!this.pool) {
|
26323
|
+
await this.initPool();
|
26324
|
+
}
|
26328
26325
|
for await (const request3 of requests) {
|
26329
|
-
|
26330
|
-
if (request3.binding) {
|
26331
|
-
lastBinding = request3.binding;
|
26332
|
-
process_binding_count.add(1);
|
26333
|
-
if (request3.binding.handlerType === HandlerType.UNKNOWN) {
|
26334
|
-
subject.next({
|
26335
|
-
processId: request3.processId,
|
26336
|
-
result: ProcessResult.create()
|
26337
|
-
});
|
26338
|
-
continue;
|
26339
|
-
}
|
26340
|
-
if (this.enablePartition) {
|
26341
|
-
this.doPartition(request3.processId, request3.binding, subject);
|
26342
|
-
} else {
|
26343
|
-
this.doProcess(request3.processId, request3.binding, subject);
|
26344
|
-
}
|
26345
|
-
}
|
26346
|
-
if (request3.start) {
|
26347
|
-
if (!lastBinding) {
|
26348
|
-
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "start request received without binding");
|
26349
|
-
}
|
26350
|
-
this.doProcess(request3.processId, lastBinding, subject);
|
26351
|
-
}
|
26352
|
-
if (request3.dbResult) {
|
26353
|
-
const dbContext = this.contexts.get(request3.processId);
|
26354
|
-
try {
|
26355
|
-
dbContext?.result(request3.dbResult);
|
26356
|
-
} catch (e) {
|
26357
|
-
subject.error(new Error("db result error, process should stop"));
|
26358
|
-
}
|
26359
|
-
}
|
26360
|
-
} catch (e) {
|
26361
|
-
console.error("unexpect error during handle loop", e);
|
26362
|
-
}
|
26326
|
+
this.handleSingleRequest(request3, subject);
|
26363
26327
|
}
|
26364
26328
|
}
|
26365
|
-
|
26366
|
-
const
|
26367
|
-
|
26368
|
-
|
26369
|
-
|
26370
|
-
|
26371
|
-
|
26372
|
-
|
26373
|
-
|
26374
|
-
}).catch((e) => {
|
26375
|
-
dbContext.error(processId, e);
|
26376
|
-
process_binding_error.add(1);
|
26377
|
-
console.error("partition", processId, "failed, took:", Date.now() - start);
|
26378
|
-
}).finally(() => {
|
26379
|
-
const cost = Date.now() - start;
|
26380
|
-
process_binding_time.add(cost);
|
26381
|
-
this.contexts.delete(processId);
|
26382
|
-
});
|
26383
|
-
}
|
26384
|
-
doProcess(processId, binding, subject) {
|
26385
|
-
const dbContext = this.contexts.new(processId, subject);
|
26386
|
-
const start = Date.now();
|
26387
|
-
this.process(binding, processId, dbContext, false).then(async (result) => {
|
26388
|
-
console.debug("process", processId, "finished, took:", Date.now() - start);
|
26389
|
-
subject.next({
|
26390
|
-
result,
|
26391
|
-
processId
|
26329
|
+
async handleSingleRequest(request3, subject) {
|
26330
|
+
const processId = request3.processId;
|
26331
|
+
if (request3.binding) {
|
26332
|
+
const context2 = this.contexts.new(processId);
|
26333
|
+
context2.mainPort.on("message", (resp) => {
|
26334
|
+
subject.next(resp);
|
26335
|
+
if (resp.result) {
|
26336
|
+
this.contexts.delete(processId);
|
26337
|
+
}
|
26392
26338
|
});
|
26393
|
-
|
26394
|
-
|
26395
|
-
|
26396
|
-
|
26397
|
-
}
|
26398
|
-
const
|
26399
|
-
|
26400
|
-
|
26401
|
-
|
26339
|
+
await this.pool.run(
|
26340
|
+
{ request: request3, workerPort: context2.workerPort, processId },
|
26341
|
+
{ transferList: [context2.workerPort] }
|
26342
|
+
);
|
26343
|
+
} else {
|
26344
|
+
const context2 = this.contexts.get(processId);
|
26345
|
+
if (!context2) {
|
26346
|
+
console.error("No context found for processId:", processId);
|
26347
|
+
throw new Error(`No context found for processId: ${processId}`);
|
26348
|
+
}
|
26349
|
+
context2.sendRequest(request3);
|
26350
|
+
}
|
26402
26351
|
}
|
26403
|
-
async process(
|
26352
|
+
async process(processId, context2) {
|
26404
26353
|
if (!this.pool) {
|
26405
26354
|
await this.initPool();
|
26406
26355
|
}
|
26407
26356
|
return this.pool.run(
|
26408
|
-
{
|
26409
|
-
{ transferList:
|
26357
|
+
{ workerPort: context2?.workerPort, processId },
|
26358
|
+
{ transferList: context2?.workerPort ? [context2?.workerPort] : [] }
|
26410
26359
|
);
|
26411
26360
|
}
|
26412
26361
|
async initPool() {
|
@@ -26433,12 +26382,12 @@ var Contexts = class {
|
|
26433
26382
|
get(processId) {
|
26434
26383
|
return this.contexts.get(processId);
|
26435
26384
|
}
|
26436
|
-
new(processId
|
26385
|
+
new(processId) {
|
26437
26386
|
let context2 = this.get(processId);
|
26438
26387
|
if (context2) {
|
26439
26388
|
return context2;
|
26440
26389
|
}
|
26441
|
-
context2 = new
|
26390
|
+
context2 = new ChannelContext(processId);
|
26442
26391
|
this.contexts.set(processId, context2);
|
26443
26392
|
return context2;
|
26444
26393
|
}
|
@@ -26447,21 +26396,17 @@ var Contexts = class {
|
|
26447
26396
|
context2?.close();
|
26448
26397
|
this.contexts.delete(processId);
|
26449
26398
|
}
|
26399
|
+
has(processId) {
|
26400
|
+
return this.contexts.has(processId);
|
26401
|
+
}
|
26450
26402
|
};
|
26451
|
-
var
|
26452
|
-
constructor(
|
26453
|
-
this.subject = subject;
|
26403
|
+
var ChannelContext = class {
|
26404
|
+
constructor(processId) {
|
26454
26405
|
this.processId = processId;
|
26455
|
-
this.mainPort.on("message", (req) => {
|
26456
|
-
subject.next({
|
26457
|
-
...req,
|
26458
|
-
processId
|
26459
|
-
});
|
26460
|
-
});
|
26461
26406
|
}
|
26462
26407
|
channel = new MessageChannel();
|
26463
|
-
sendRequest(request3
|
26464
|
-
|
26408
|
+
sendRequest(request3) {
|
26409
|
+
this.mainPort.postMessage(request3);
|
26465
26410
|
}
|
26466
26411
|
get workerPort() {
|
26467
26412
|
return this.channel.port2;
|
@@ -26469,25 +26414,9 @@ var ChannelStoreContext = class {
|
|
26469
26414
|
get mainPort() {
|
26470
26415
|
return this.channel.port1;
|
26471
26416
|
}
|
26472
|
-
result(dbResult) {
|
26473
|
-
this.mainPort.postMessage(dbResult);
|
26474
|
-
}
|
26475
26417
|
close() {
|
26476
26418
|
this.mainPort.close();
|
26477
26419
|
}
|
26478
|
-
error(processId, e) {
|
26479
|
-
const stack = new Error().stack;
|
26480
|
-
console.error("process error", processId, e, stack);
|
26481
|
-
const errorResult = ProcessResult.create({
|
26482
|
-
states: {
|
26483
|
-
error: e?.toString()
|
26484
|
-
}
|
26485
|
-
});
|
26486
|
-
this.subject.next({
|
26487
|
-
result: errorResult,
|
26488
|
-
processId
|
26489
|
-
});
|
26490
|
-
}
|
26491
26420
|
};
|
26492
26421
|
import("node:process").then((p) => p.stdout.write(""));
|
26493
26422
|
|
@@ -26518,8 +26447,13 @@ var optionDefinitions = [
|
|
26518
26447
|
{ name: "otlp-debug", type: Boolean, defaultValue: false },
|
26519
26448
|
{ name: "start-action-server", type: Boolean, defaultValue: false },
|
26520
26449
|
{ name: "worker", type: Number, defaultValue: workerNum },
|
26521
|
-
{ name: "process-timeout", type: Number, defaultValue: 60 }
|
26522
|
-
|
26450
|
+
{ name: "process-timeout", type: Number, defaultValue: 60 },
|
26451
|
+
{ name: "worker-timeout", type: Number, defaultValue: 60 },
|
26452
|
+
{
|
26453
|
+
name: "enable-partition",
|
26454
|
+
type: Boolean,
|
26455
|
+
defaultValue: process.env["SENTIO_ENABLE_BINDING_DATA_PARTITION"] === "true"
|
26456
|
+
}
|
26523
26457
|
];
|
26524
26458
|
var options = command_line_args_default(optionDefinitions, { partial: true });
|
26525
26459
|
var logLevel = process.env["LOG_LEVEL"]?.toLowerCase();
|
@@ -26540,15 +26474,15 @@ if (options["start-action-server"]) {
|
|
26540
26474
|
server = new ActionServer(loader);
|
26541
26475
|
server.listen(options.port);
|
26542
26476
|
} else {
|
26543
|
-
server = (0,
|
26477
|
+
server = (0, import_nice_grpc.createServer)({
|
26544
26478
|
"grpc.max_send_message_length": 768 * 1024 * 1024,
|
26545
26479
|
"grpc.max_receive_message_length": 768 * 1024 * 1024,
|
26546
26480
|
"grpc.default_compression_algorithm": import_grpc_js.compressionAlgorithms.gzip
|
26547
26481
|
}).use((0, import_nice_grpc_opentelemetry.openTelemetryServerMiddleware)()).use(import_nice_grpc_error_details.errorDetailsServerMiddleware);
|
26548
26482
|
if (options.worker > 1) {
|
26549
|
-
baseService = new ServiceManager(
|
26483
|
+
baseService = new ServiceManager(loader, options, server.shutdown);
|
26550
26484
|
} else {
|
26551
|
-
baseService = new ProcessorServiceImpl(loader, server.shutdown);
|
26485
|
+
baseService = new ProcessorServiceImpl(loader, options, server.shutdown);
|
26552
26486
|
}
|
26553
26487
|
const service = new FullProcessorServiceImpl(baseService);
|
26554
26488
|
server.add(ProcessorDefinition, service);
|