@sentio/runtime 4.0.0-rc.2 → 4.0.0-rc.3
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-OLNJTVP4.js +15167 -0
- package/lib/chunk-OLNJTVP4.js.map +1 -0
- package/lib/{chunk-MSVN53DI.js → chunk-VVWSRCNO.js} +1 -5
- package/lib/{chunk-MSVN53DI.js.map → chunk-VVWSRCNO.js.map} +1 -1
- package/lib/index.d.ts +62 -408
- package/lib/index.js +21290 -40
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.js +25 -235
- package/lib/processor-runner.js.map +1 -1
- package/package.json +1 -1
- package/src/full-service.ts +0 -35
- package/src/index.ts +1 -1
- package/src/processor-runner.ts +2 -16
- package/src/service-v3.ts +3 -3
- package/src/utils.ts +21 -1
- package/lib/chunk-63SN5KU2.js +0 -38205
- package/lib/chunk-63SN5KU2.js.map +0 -1
- package/src/service.ts +0 -556
package/lib/processor-runner.js
CHANGED
|
@@ -3,34 +3,21 @@ import { createRequire as createRequireShim } from 'module'; const require = cre
|
|
|
3
3
|
import {
|
|
4
4
|
Code,
|
|
5
5
|
ConnectError,
|
|
6
|
-
DataBindingContext,
|
|
7
6
|
GLOBAL_CONFIG,
|
|
8
|
-
|
|
7
|
+
ProcessorServiceImplV3,
|
|
9
8
|
configureEndpoints,
|
|
10
9
|
createConnectRouter,
|
|
11
|
-
errorString,
|
|
12
|
-
freezeGlobalConfig,
|
|
13
|
-
from,
|
|
14
10
|
locatePackageJson,
|
|
15
|
-
processMetrics,
|
|
16
|
-
recordRuntimeInfo,
|
|
17
|
-
require_cjs,
|
|
18
11
|
require_lib,
|
|
19
|
-
uResponseNotFound
|
|
20
|
-
|
|
21
|
-
} from "./chunk-63SN5KU2.js";
|
|
12
|
+
uResponseNotFound
|
|
13
|
+
} from "./chunk-OLNJTVP4.js";
|
|
22
14
|
import {
|
|
23
|
-
EmptySchema,
|
|
24
15
|
ExecutionConfigSchema,
|
|
25
|
-
HandlerType,
|
|
26
16
|
PluginManager,
|
|
27
17
|
ProcessConfigResponseSchema,
|
|
28
|
-
ProcessResultSchema,
|
|
29
|
-
Processor,
|
|
30
18
|
ProcessorV3,
|
|
31
|
-
clone,
|
|
32
19
|
create
|
|
33
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-VVWSRCNO.js";
|
|
34
21
|
import {
|
|
35
22
|
DiagConsoleLogger,
|
|
36
23
|
DiagLogLevel,
|
|
@@ -3927,7 +3914,7 @@ var require_from = __commonJS({
|
|
|
3927
3914
|
return (hint === "string" ? String : Number)(input);
|
|
3928
3915
|
}
|
|
3929
3916
|
var ERR_INVALID_ARG_TYPE = require_errors2().codes.ERR_INVALID_ARG_TYPE;
|
|
3930
|
-
function
|
|
3917
|
+
function from(Readable2, iterable, opts) {
|
|
3931
3918
|
var iterator;
|
|
3932
3919
|
if (iterable && typeof iterable.next === "function") {
|
|
3933
3920
|
iterator = iterable;
|
|
@@ -3966,7 +3953,7 @@ var require_from = __commonJS({
|
|
|
3966
3953
|
}
|
|
3967
3954
|
return readable;
|
|
3968
3955
|
}
|
|
3969
|
-
module.exports =
|
|
3956
|
+
module.exports = from;
|
|
3970
3957
|
}
|
|
3971
3958
|
});
|
|
3972
3959
|
|
|
@@ -4010,7 +3997,7 @@ var require_stream_readable = __commonJS({
|
|
|
4010
3997
|
var ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
|
|
4011
3998
|
var StringDecoder;
|
|
4012
3999
|
var createReadableStreamAsyncIterator;
|
|
4013
|
-
var
|
|
4000
|
+
var from;
|
|
4014
4001
|
require_inherits()(Readable2, Stream);
|
|
4015
4002
|
var errorOrDestroy = destroyImpl.errorOrDestroy;
|
|
4016
4003
|
var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
|
|
@@ -4688,10 +4675,10 @@ var require_stream_readable = __commonJS({
|
|
|
4688
4675
|
}
|
|
4689
4676
|
if (typeof Symbol === "function") {
|
|
4690
4677
|
Readable2.from = function(iterable, opts) {
|
|
4691
|
-
if (
|
|
4692
|
-
|
|
4678
|
+
if (from === void 0) {
|
|
4679
|
+
from = require_from();
|
|
4693
4680
|
}
|
|
4694
|
-
return
|
|
4681
|
+
return from(Readable2, iterable, opts);
|
|
4695
4682
|
};
|
|
4696
4683
|
}
|
|
4697
4684
|
function indexOf(xs, x) {
|
|
@@ -6263,8 +6250,8 @@ var require_pipeline = __commonJS({
|
|
|
6263
6250
|
function call(fn) {
|
|
6264
6251
|
fn();
|
|
6265
6252
|
}
|
|
6266
|
-
function pipe(
|
|
6267
|
-
return
|
|
6253
|
+
function pipe(from, to) {
|
|
6254
|
+
return from.pipe(to);
|
|
6268
6255
|
}
|
|
6269
6256
|
function popCallback(streams) {
|
|
6270
6257
|
if (!streams.length) return noop;
|
|
@@ -7529,9 +7516,9 @@ var require_index_cjs = __commonJS({
|
|
|
7529
7516
|
}
|
|
7530
7517
|
return graph;
|
|
7531
7518
|
}
|
|
7532
|
-
function link(
|
|
7519
|
+
function link(from, to) {
|
|
7533
7520
|
return function(args) {
|
|
7534
|
-
return to(
|
|
7521
|
+
return to(from(args));
|
|
7535
7522
|
};
|
|
7536
7523
|
}
|
|
7537
7524
|
function wrapConversion(toModel, graph) {
|
|
@@ -11293,11 +11280,11 @@ var init_Buckets = __esm({
|
|
|
11293
11280
|
/**
|
|
11294
11281
|
* reverse the items in the backing array in the range [from, limit).
|
|
11295
11282
|
*/
|
|
11296
|
-
reverse(
|
|
11297
|
-
const num = Math.floor((
|
|
11283
|
+
reverse(from, limit) {
|
|
11284
|
+
const num = Math.floor((from + limit) / 2) - from;
|
|
11298
11285
|
for (let i = 0; i < num; i++) {
|
|
11299
|
-
const tmp = this._counts[
|
|
11300
|
-
this._counts[
|
|
11286
|
+
const tmp = this._counts[from + i];
|
|
11287
|
+
this._counts[from + i] = this._counts[limit - i - 1];
|
|
11301
11288
|
this._counts[limit - i - 1] = tmp;
|
|
11302
11289
|
}
|
|
11303
11290
|
}
|
|
@@ -26434,7 +26421,7 @@ var require_longbits = __commonJS({
|
|
|
26434
26421
|
}
|
|
26435
26422
|
return new LongBits(lo, hi);
|
|
26436
26423
|
};
|
|
26437
|
-
LongBits.from = function
|
|
26424
|
+
LongBits.from = function from(value) {
|
|
26438
26425
|
if (typeof value === "number")
|
|
26439
26426
|
return LongBits.fromNumber(value);
|
|
26440
26427
|
if (util.isString(value)) {
|
|
@@ -34383,9 +34370,9 @@ var require_descriptor2 = __commonJS({
|
|
|
34383
34370
|
return void 0;
|
|
34384
34371
|
return type.fromObject(toDescriptorOptionsRecursive(options2, type));
|
|
34385
34372
|
}
|
|
34386
|
-
function shortname(
|
|
34387
|
-
var fromPath =
|
|
34388
|
-
if (!(
|
|
34373
|
+
function shortname(from, to) {
|
|
34374
|
+
var fromPath = from.fullName.split("."), toPath = to.fullName.split("."), i = 0, j = 0, k = toPath.length - 1;
|
|
34375
|
+
if (!(from instanceof Root) && to instanceof Namespace)
|
|
34389
34376
|
while (i < fromPath.length && j < k && fromPath[i] === toPath[j]) {
|
|
34390
34377
|
var other = to.lookup(fromPath[i++], true);
|
|
34391
34378
|
if (other !== null && other !== to)
|
|
@@ -42678,9 +42665,9 @@ var require_server = __commonJS({
|
|
|
42678
42665
|
}
|
|
42679
42666
|
return bindResult.port;
|
|
42680
42667
|
} else {
|
|
42681
|
-
const
|
|
42682
|
-
logging.log(constants_1.LogVerbosity.ERROR,
|
|
42683
|
-
throw new Error(`${
|
|
42668
|
+
const errorString = `No address added out of total ${addressList.length} resolved`;
|
|
42669
|
+
logging.log(constants_1.LogVerbosity.ERROR, errorString);
|
|
42670
|
+
throw new Error(`${errorString} errors: [${bindResult.errors.join(",")}]`);
|
|
42684
42671
|
}
|
|
42685
42672
|
}
|
|
42686
42673
|
resolvePort(port) {
|
|
@@ -50668,31 +50655,6 @@ import { fork } from "child_process";
|
|
|
50668
50655
|
import { fileURLToPath } from "url";
|
|
50669
50656
|
|
|
50670
50657
|
// src/full-service.ts
|
|
50671
|
-
var FullProcessorServiceImpl = class {
|
|
50672
|
-
constructor(instance) {
|
|
50673
|
-
this.instance = instance;
|
|
50674
|
-
}
|
|
50675
|
-
async getConfig(request, context2) {
|
|
50676
|
-
const config = await this.instance.getConfig(request, context2);
|
|
50677
|
-
config.executionConfig = create(ExecutionConfigSchema, GLOBAL_CONFIG.execution);
|
|
50678
|
-
return config;
|
|
50679
|
-
}
|
|
50680
|
-
async start(request, context2) {
|
|
50681
|
-
return await this.instance.start(request, context2);
|
|
50682
|
-
}
|
|
50683
|
-
async stop(request, context2) {
|
|
50684
|
-
return await this.instance.stop(request, context2);
|
|
50685
|
-
}
|
|
50686
|
-
async processBindings(request, context2) {
|
|
50687
|
-
return await this.instance.processBindings(request, context2);
|
|
50688
|
-
}
|
|
50689
|
-
async *processBindingsStream(requests, context2) {
|
|
50690
|
-
yield* this.instance.processBindingsStream(requests, context2);
|
|
50691
|
-
}
|
|
50692
|
-
async *preprocessBindingsStream(requests, context2) {
|
|
50693
|
-
yield* this.instance.preprocessBindingsStream(requests, context2);
|
|
50694
|
-
}
|
|
50695
|
-
};
|
|
50696
50658
|
var FullProcessorServiceV3Impl = class {
|
|
50697
50659
|
constructor(instance) {
|
|
50698
50660
|
this.instance = instance;
|
|
@@ -50832,168 +50794,6 @@ var ActionServer = class {
|
|
|
50832
50794
|
};
|
|
50833
50795
|
import("node:process").then((p) => p.stdout.write(""));
|
|
50834
50796
|
|
|
50835
|
-
// src/service-v3.ts
|
|
50836
|
-
var import_rxjs = __toESM(require_cjs(), 1);
|
|
50837
|
-
var { process_binding_count, process_binding_time, process_binding_error } = processMetrics;
|
|
50838
|
-
var WRITE_V2_EVENT_LOGS = process.env.WRITE_V2_EVENT_LOGS !== "false";
|
|
50839
|
-
var TIME_SERIES_RESULT_BATCH_SIZE = 1e3;
|
|
50840
|
-
var ProcessorServiceImplV3 = class {
|
|
50841
|
-
enablePartition;
|
|
50842
|
-
loader;
|
|
50843
|
-
shutdownHandler;
|
|
50844
|
-
started = false;
|
|
50845
|
-
constructor(loader2, options2, shutdownHandler) {
|
|
50846
|
-
this.loader = loader2;
|
|
50847
|
-
this.shutdownHandler = shutdownHandler;
|
|
50848
|
-
this.enablePartition = options2?.enablePartition == true;
|
|
50849
|
-
}
|
|
50850
|
-
async start(request, context2) {
|
|
50851
|
-
if (this.started) {
|
|
50852
|
-
return create(EmptySchema);
|
|
50853
|
-
}
|
|
50854
|
-
freezeGlobalConfig();
|
|
50855
|
-
try {
|
|
50856
|
-
await this.loader();
|
|
50857
|
-
} catch (e) {
|
|
50858
|
-
throw new ConnectError("Failed to load processor: " + errorString(e), Code.InvalidArgument);
|
|
50859
|
-
}
|
|
50860
|
-
await PluginManager.INSTANCE.start(request);
|
|
50861
|
-
this.started = true;
|
|
50862
|
-
return create(EmptySchema);
|
|
50863
|
-
}
|
|
50864
|
-
async getConfig(request, context2) {
|
|
50865
|
-
if (!this.started) {
|
|
50866
|
-
throw new ConnectError("Service Not started.", Code.Unavailable);
|
|
50867
|
-
}
|
|
50868
|
-
const newConfig = create(ProcessConfigResponseSchema, {});
|
|
50869
|
-
await PluginManager.INSTANCE.configure(newConfig);
|
|
50870
|
-
return newConfig;
|
|
50871
|
-
}
|
|
50872
|
-
async *processBindingsStream(requests, context2) {
|
|
50873
|
-
const subject = new import_rxjs.Subject();
|
|
50874
|
-
this.handleRequests(requests, subject).then(() => {
|
|
50875
|
-
subject.complete();
|
|
50876
|
-
}).catch((e) => {
|
|
50877
|
-
console.error(e);
|
|
50878
|
-
subject.error(e);
|
|
50879
|
-
});
|
|
50880
|
-
yield* from(subject).pipe(withAbort(context2.signal));
|
|
50881
|
-
}
|
|
50882
|
-
async handleRequests(requests, subject) {
|
|
50883
|
-
let lastBinding = void 0;
|
|
50884
|
-
for await (const request of requests) {
|
|
50885
|
-
try {
|
|
50886
|
-
if (request.value.case === "binding") {
|
|
50887
|
-
lastBinding = request.value.value;
|
|
50888
|
-
}
|
|
50889
|
-
this.handleRequest(request, lastBinding, subject);
|
|
50890
|
-
} catch (e) {
|
|
50891
|
-
console.error("unexpect error during handle loop", e);
|
|
50892
|
-
}
|
|
50893
|
-
}
|
|
50894
|
-
}
|
|
50895
|
-
contexts = new Contexts();
|
|
50896
|
-
async handleRequest(request, lastBinding, subject) {
|
|
50897
|
-
const binding = request.value.case === "binding" ? request.value.value : void 0;
|
|
50898
|
-
if (binding) {
|
|
50899
|
-
process_binding_count.add(1);
|
|
50900
|
-
if (binding.handlerType === HandlerType.UNKNOWN) {
|
|
50901
|
-
subject.next({
|
|
50902
|
-
processId: request.processId,
|
|
50903
|
-
value: { case: "result", value: create(ProcessResultSchema) }
|
|
50904
|
-
});
|
|
50905
|
-
return;
|
|
50906
|
-
}
|
|
50907
|
-
if (this.enablePartition) {
|
|
50908
|
-
try {
|
|
50909
|
-
console.debug("sending partition request", binding);
|
|
50910
|
-
const partitions = await PluginManager.INSTANCE.partition(binding);
|
|
50911
|
-
subject.next({
|
|
50912
|
-
processId: request.processId,
|
|
50913
|
-
value: { case: "partitions", value: partitions }
|
|
50914
|
-
});
|
|
50915
|
-
} catch (e) {
|
|
50916
|
-
console.error("Partition error:", e);
|
|
50917
|
-
subject.error(new Error("Partition error: " + errorString(e)));
|
|
50918
|
-
return;
|
|
50919
|
-
}
|
|
50920
|
-
} else {
|
|
50921
|
-
this.startProcess(request.processId, binding, subject);
|
|
50922
|
-
}
|
|
50923
|
-
}
|
|
50924
|
-
if (request.value.case === "start") {
|
|
50925
|
-
if (!lastBinding) {
|
|
50926
|
-
console.error("start request received without binding");
|
|
50927
|
-
subject.error(new Error("start request received without binding"));
|
|
50928
|
-
return;
|
|
50929
|
-
}
|
|
50930
|
-
this.startProcess(request.processId, lastBinding, subject);
|
|
50931
|
-
}
|
|
50932
|
-
if (request.value.case === "dbResult") {
|
|
50933
|
-
const context2 = this.contexts.get(request.processId);
|
|
50934
|
-
try {
|
|
50935
|
-
context2?.result(request.value.value);
|
|
50936
|
-
} catch (e) {
|
|
50937
|
-
subject.error(new Error("db result error, process should stop"));
|
|
50938
|
-
}
|
|
50939
|
-
}
|
|
50940
|
-
}
|
|
50941
|
-
startProcess(processId, binding, subject) {
|
|
50942
|
-
const context2 = this.contexts.new(processId, subject);
|
|
50943
|
-
const start = Date.now();
|
|
50944
|
-
PluginManager.INSTANCE.processBinding(binding, void 0, context2).then(async (result) => {
|
|
50945
|
-
await context2.awaitPendings();
|
|
50946
|
-
const timeseriesResult = result.timeseriesResult;
|
|
50947
|
-
for (let i = 0; i < timeseriesResult.length; i += TIME_SERIES_RESULT_BATCH_SIZE) {
|
|
50948
|
-
const batch = timeseriesResult.slice(i, i + TIME_SERIES_RESULT_BATCH_SIZE);
|
|
50949
|
-
subject.next({
|
|
50950
|
-
processId,
|
|
50951
|
-
value: { case: "tsRequest", value: { data: batch } }
|
|
50952
|
-
});
|
|
50953
|
-
}
|
|
50954
|
-
const otherResults = clone(ProcessResultSchema, result);
|
|
50955
|
-
otherResults.timeseriesResult = [];
|
|
50956
|
-
subject.next({
|
|
50957
|
-
processId,
|
|
50958
|
-
value: {
|
|
50959
|
-
case: "result",
|
|
50960
|
-
value: WRITE_V2_EVENT_LOGS ? otherResults : create(ProcessResultSchema, { states: result.states })
|
|
50961
|
-
}
|
|
50962
|
-
});
|
|
50963
|
-
recordRuntimeInfo(result, binding.handlerType);
|
|
50964
|
-
}).catch((e) => {
|
|
50965
|
-
console.error(e, e.stack);
|
|
50966
|
-
context2.error(processId, e);
|
|
50967
|
-
process_binding_error.add(1);
|
|
50968
|
-
}).finally(() => {
|
|
50969
|
-
const cost = Date.now() - start;
|
|
50970
|
-
process_binding_time.add(cost);
|
|
50971
|
-
this.contexts.delete(processId);
|
|
50972
|
-
});
|
|
50973
|
-
}
|
|
50974
|
-
async updateTemplates(request, context2) {
|
|
50975
|
-
await PluginManager.INSTANCE.updateTemplates(request);
|
|
50976
|
-
return create(EmptySchema);
|
|
50977
|
-
}
|
|
50978
|
-
};
|
|
50979
|
-
var Contexts = class {
|
|
50980
|
-
contexts = /* @__PURE__ */ new Map();
|
|
50981
|
-
get(processId) {
|
|
50982
|
-
return this.contexts.get(processId);
|
|
50983
|
-
}
|
|
50984
|
-
new(processId, subject) {
|
|
50985
|
-
const context2 = new DataBindingContext(processId, subject);
|
|
50986
|
-
this.contexts.set(processId, context2);
|
|
50987
|
-
return context2;
|
|
50988
|
-
}
|
|
50989
|
-
delete(processId) {
|
|
50990
|
-
const context2 = this.get(processId);
|
|
50991
|
-
context2?.close();
|
|
50992
|
-
this.contexts.delete(processId);
|
|
50993
|
-
}
|
|
50994
|
-
};
|
|
50995
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
50996
|
-
|
|
50997
50797
|
// src/processor-runner.ts
|
|
50998
50798
|
import { dirname, join } from "path";
|
|
50999
50799
|
|
|
@@ -51072,7 +50872,6 @@ if (!isChildProcess) {
|
|
|
51072
50872
|
}
|
|
51073
50873
|
var server;
|
|
51074
50874
|
var processorHttp2Server;
|
|
51075
|
-
var baseService;
|
|
51076
50875
|
var httpServer;
|
|
51077
50876
|
var loader = async () => {
|
|
51078
50877
|
const m = await import(options.target);
|
|
@@ -51084,11 +50883,8 @@ if (options.startActionServer) {
|
|
|
51084
50883
|
server.listen(options.port);
|
|
51085
50884
|
} else {
|
|
51086
50885
|
const shutdown = () => processorHttp2Server?.close();
|
|
51087
|
-
baseService = new ProcessorServiceImpl(loader, options, shutdown);
|
|
51088
|
-
const serviceV2 = new FullProcessorServiceImpl(baseService);
|
|
51089
50886
|
const serviceV3 = new FullProcessorServiceV3Impl(new ProcessorServiceImplV3(loader, options, shutdown));
|
|
51090
50887
|
const routes = (router) => {
|
|
51091
|
-
router.service(Processor, serviceV2);
|
|
51092
50888
|
router.service(ProcessorV3, serviceV3);
|
|
51093
50889
|
};
|
|
51094
50890
|
const adapter = connectNodeAdapter({
|
|
@@ -51184,17 +50980,11 @@ process.once("SIGINT", function() {
|
|
|
51184
50980
|
shutdownServers(0);
|
|
51185
50981
|
}).on("uncaughtException", (err) => {
|
|
51186
50982
|
console.error("Uncaught Exception, please checking if await is properly used", err);
|
|
51187
|
-
if (baseService) {
|
|
51188
|
-
baseService.unhandled = err;
|
|
51189
|
-
}
|
|
51190
50983
|
}).on("unhandledRejection", (reason, _p) => {
|
|
51191
50984
|
if (reason?.message.startsWith('invalid ENS name (disallowed character: "*"')) {
|
|
51192
50985
|
return;
|
|
51193
50986
|
}
|
|
51194
50987
|
console.error("Unhandled Rejection, please checking if await is properly", reason);
|
|
51195
|
-
if (baseService) {
|
|
51196
|
-
baseService.unhandled = reason;
|
|
51197
|
-
}
|
|
51198
50988
|
});
|
|
51199
50989
|
async function dumpHeap(file) {
|
|
51200
50990
|
console.log("Heap dumping to", file);
|