@sentio/runtime 3.0.0-rc.8 → 3.0.0
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-757YRULG.js +38 -0
- package/lib/{chunk-CPJKSHSV.js.map → chunk-757YRULG.js.map} +1 -1
- package/lib/chunk-AUPVVLD3.js +3 -0
- package/lib/chunk-CJDESLYQ.js +3 -0
- package/lib/{chunk-L2A6JPIQ.js.map → chunk-CJDESLYQ.js.map} +1 -1
- package/lib/chunk-KF7FHZ25.js +117 -0
- package/lib/{chunk-6MZJOWMH.js.map → chunk-KF7FHZ25.js.map} +1 -1
- package/lib/chunk-TW627LH5.js +3 -0
- package/lib/{chunk-MV6JXS2P.js.map → chunk-TW627LH5.js.map} +1 -1
- package/lib/chunk-ZTRGPIW7.js +26 -0
- package/lib/chunk-ZTRGPIW7.js.map +1 -0
- package/lib/getMachineId-bsd-CDSZ2S36.js +3 -0
- package/lib/{getMachineId-bsd-ZJR2OQTA.js.map → getMachineId-bsd-CDSZ2S36.js.map} +1 -1
- package/lib/getMachineId-darwin-LM5BSWCG.js +4 -0
- package/lib/{getMachineId-darwin-OW6SYINH.js.map → getMachineId-darwin-LM5BSWCG.js.map} +1 -1
- package/lib/getMachineId-linux-UA53ZQFA.js +3 -0
- package/lib/{getMachineId-linux-L5XPRJBN.js.map → getMachineId-linux-UA53ZQFA.js.map} +1 -1
- package/lib/getMachineId-unsupported-LDR77GGJ.js +3 -0
- package/lib/{getMachineId-unsupported-B3NMIOO3.js.map → getMachineId-unsupported-LDR77GGJ.js.map} +1 -1
- package/lib/getMachineId-win-XULW45X4.js +3 -0
- package/lib/{getMachineId-win-TT64F63B.js.map → getMachineId-win-XULW45X4.js.map} +1 -1
- package/lib/index.d.ts +4 -9
- package/lib/index.js +1 -76
- package/lib/index.js.map +1 -1
- package/lib/{processor-CNHsQeJ6.d.ts → processor-BUTmbpmJ.d.ts} +2 -3
- package/lib/processor-runner.js +43 -32947
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.js +2 -132
- package/lib/service-worker.js.map +1 -1
- package/lib/test-processor.test.d.ts +1 -1
- package/lib/test-processor.test.js.map +1 -1
- package/package.json +1 -1
- package/src/db-context.ts +4 -4
- package/src/gen/processor/protos/processor.ts +17 -1
- package/src/gen/service/common/protos/common.ts +356 -1
- package/src/otlp.ts +20 -12
- package/src/plugin.ts +0 -11
- package/src/processor-runner.ts +3 -3
- package/src/service-manager.ts +0 -8
- package/src/service-v3.ts +11 -18
- package/src/state.ts +0 -22
- package/lib/chunk-6MZJOWMH.js +0 -60145
- package/lib/chunk-CPJKSHSV.js +0 -10976
- package/lib/chunk-KVSDPGUI.js +0 -50
- package/lib/chunk-L2A6JPIQ.js +0 -21
- package/lib/chunk-MV6JXS2P.js +0 -1703
- package/lib/chunk-N3VEKOPD.js +0 -97
- package/lib/chunk-N3VEKOPD.js.map +0 -1
- package/lib/chunk-QHFSZVR5.js +0 -25779
- package/lib/chunk-QHFSZVR5.js.map +0 -1
- package/lib/getMachineId-bsd-ZJR2OQTA.js +0 -41
- package/lib/getMachineId-darwin-OW6SYINH.js +0 -41
- package/lib/getMachineId-linux-L5XPRJBN.js +0 -33
- package/lib/getMachineId-unsupported-B3NMIOO3.js +0 -24
- package/lib/getMachineId-win-TT64F63B.js +0 -43
- /package/lib/{chunk-KVSDPGUI.js.map → chunk-AUPVVLD3.js.map} +0 -0
package/lib/service-worker.js
CHANGED
|
@@ -1,134 +1,4 @@
|
|
|
1
1
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-CPJKSHSV.js";
|
|
5
|
-
import {
|
|
6
|
-
ProcessorServiceImpl,
|
|
7
|
-
configureEndpoints,
|
|
8
|
-
errorString,
|
|
9
|
-
freezeGlobalConfig,
|
|
10
|
-
require_cjs,
|
|
11
|
-
require_lib3 as require_lib,
|
|
12
|
-
require_lib4 as require_lib2
|
|
13
|
-
} from "./chunk-6MZJOWMH.js";
|
|
14
|
-
import "./chunk-QHFSZVR5.js";
|
|
15
|
-
import "./chunk-MV6JXS2P.js";
|
|
16
|
-
import {
|
|
17
|
-
__toESM
|
|
18
|
-
} from "./chunk-KVSDPGUI.js";
|
|
19
|
-
|
|
20
|
-
// src/service-worker.ts
|
|
21
|
-
var import_nice_grpc = __toESM(require_lib(), 1);
|
|
22
|
-
var import_nice_grpc_error_details = __toESM(require_lib2(), 1);
|
|
23
|
-
import { threadId } from "worker_threads";
|
|
24
|
-
import { Piscina } from "piscina";
|
|
25
|
-
var import_rxjs = __toESM(require_cjs(), 1);
|
|
26
|
-
var started = false;
|
|
27
|
-
var unhandled;
|
|
28
|
-
process.on("uncaughtException", (err) => {
|
|
29
|
-
console.error("Uncaught Exception, please checking if await is properly used", err);
|
|
30
|
-
unhandled = err;
|
|
31
|
-
}).on("unhandledRejection", (reason, p) => {
|
|
32
|
-
if (reason?.message.startsWith('invalid ENS name (disallowed character: "*"')) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
console.error("Unhandled Rejection, please checking if await is properly", reason);
|
|
36
|
-
unhandled = reason;
|
|
37
|
-
}).on("exit", () => {
|
|
38
|
-
console.info("Worker thread exiting, threadId:", threadId);
|
|
39
|
-
});
|
|
40
|
-
var service;
|
|
41
|
-
var loader = async (options) => {
|
|
42
|
-
if (options.target) {
|
|
43
|
-
const m = await import(options.target);
|
|
44
|
-
console.debug("Module loaded, path:", options.target, "module:", m);
|
|
45
|
-
return m;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var emptyCallContext = {};
|
|
49
|
-
async function start(request, options) {
|
|
50
|
-
if (started) {
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
|
-
freezeGlobalConfig();
|
|
54
|
-
try {
|
|
55
|
-
service = new ProcessorServiceImpl(() => loader(options), options);
|
|
56
|
-
} catch (e) {
|
|
57
|
-
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "Failed to load processor: " + errorString(e));
|
|
58
|
-
}
|
|
59
|
-
await service.start(request, emptyCallContext);
|
|
60
|
-
started = true;
|
|
61
|
-
return {};
|
|
62
|
-
}
|
|
63
|
-
async function service_worker_default({
|
|
64
|
-
processId,
|
|
65
|
-
request: firstRequest,
|
|
66
|
-
workerPort
|
|
67
|
-
}) {
|
|
68
|
-
const { startRequest, configRequest, options } = Piscina.workerData;
|
|
69
|
-
if (!started) {
|
|
70
|
-
const logLevel = process.env["LOG_LEVEL"]?.toUpperCase();
|
|
71
|
-
setupLogger(options.logFormat === "json", logLevel === "debug" ? true : options.debug, threadId);
|
|
72
|
-
configureEndpoints(options);
|
|
73
|
-
if (startRequest) {
|
|
74
|
-
await start(startRequest, options);
|
|
75
|
-
console.debug("worker", threadId, " started, template instance:", startRequest.templateInstances?.length);
|
|
76
|
-
}
|
|
77
|
-
if (configRequest) {
|
|
78
|
-
await service?.getConfig(configRequest, emptyCallContext);
|
|
79
|
-
console.debug("worker", threadId, " configured");
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (unhandled) {
|
|
83
|
-
const err = unhandled;
|
|
84
|
-
unhandled = void 0;
|
|
85
|
-
console.error("Unhandled exception/rejection in previous request:", err);
|
|
86
|
-
throw new import_nice_grpc_error_details.RichServerError(
|
|
87
|
-
import_nice_grpc.Status.UNAVAILABLE,
|
|
88
|
-
"Unhandled exception/rejection in previous request: " + errorString(err),
|
|
89
|
-
[
|
|
90
|
-
import_nice_grpc_error_details.DebugInfo.fromPartial({
|
|
91
|
-
detail: err.message,
|
|
92
|
-
stackEntries: err.stack?.split("\n")
|
|
93
|
-
})
|
|
94
|
-
]
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
const timeout = (options.workerTimeout || 0) * 1e3;
|
|
98
|
-
const enablePartition = options.enablePartition || false;
|
|
99
|
-
await new Promise((resolve, reject) => {
|
|
100
|
-
const subject = new import_rxjs.Subject();
|
|
101
|
-
let timeoutId = void 0;
|
|
102
|
-
subject.subscribe((resp) => {
|
|
103
|
-
console.debug("Worker", threadId, "send response:", resp.result ? "result" : "dbResult");
|
|
104
|
-
workerPort.postMessage(resp);
|
|
105
|
-
if (resp.result) {
|
|
106
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
107
|
-
resolve();
|
|
108
|
-
workerPort.close();
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
workerPort.on("message", (msg) => {
|
|
112
|
-
const request = msg;
|
|
113
|
-
console.debug("Worker", threadId, "received request:", request.start ? "start" : "dbResult");
|
|
114
|
-
service?.handleRequest(request, firstRequest.binding, subject);
|
|
115
|
-
if (enablePartition && request.start && timeout > 0) {
|
|
116
|
-
timeoutId = setTimeout(async () => {
|
|
117
|
-
reject(new import_nice_grpc_error_details.RichServerError(import_nice_grpc.Status.DEADLINE_EXCEEDED, "Worker timeout exceeded"));
|
|
118
|
-
}, timeout);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
console.debug("Worker", threadId, "handle request: binding");
|
|
122
|
-
service?.handleRequest(firstRequest, firstRequest.binding, subject);
|
|
123
|
-
if (!enablePartition && timeout > 0) {
|
|
124
|
-
timeoutId = setTimeout(() => {
|
|
125
|
-
reject(new import_nice_grpc_error_details.RichServerError(import_nice_grpc.Status.DEADLINE_EXCEEDED, "Worker timeout exceeded"));
|
|
126
|
-
}, timeout);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
131
|
-
export {
|
|
132
|
-
service_worker_default as default
|
|
133
|
-
};
|
|
2
|
+
import{a as k}from"./chunk-757YRULG.js";import{E as I,c as h,j as S,l as x,m as C,q,z as y}from"./chunk-KF7FHZ25.js";import"./chunk-ZTRGPIW7.js";import"./chunk-TW627LH5.js";import{e as E}from"./chunk-AUPVVLD3.js";var s=E(x(),1);var i=E(C(),1);import{threadId as o}from"worker_threads";import{Piscina as L}from"piscina";var D=E(y(),1),b=!1,u;process.on("uncaughtException",e=>{console.error("Uncaught Exception, please checking if await is properly used",e),u=e}).on("unhandledRejection",(e,t)=>{e?.message.startsWith('invalid ENS name (disallowed character: "*"')||(console.error("Unhandled Rejection, please checking if await is properly",e),u=e)}).on("exit",()=>{console.info("Worker thread exiting, threadId:",o)});var d,A=async e=>{if(e.target){let t=await import(e.target);return console.debug("Module loaded, path:",e.target,"module:",t),t}},v={};async function N(e,t){if(b)return{};q();try{d=new I(()=>A(t),t)}catch(a){throw new s.ServerError(s.Status.INVALID_ARGUMENT,"Failed to load processor: "+h(a))}return await d.start(e,v),b=!0,{}}async function F({processId:e,request:t,workerPort:a}){let{startRequest:p,configRequest:w,options:n}=L.workerData;if(!b){let r=process.env.LOG_LEVEL?.toUpperCase();k(n.logFormat==="json",r==="debug"?!0:n.debug,o),S(n),p&&(await N(p,n),console.debug("worker",o," started, template instance:",p.templateInstances?.length)),w&&(await d?.getConfig(w,v),console.debug("worker",o," configured"))}if(u){let r=u;throw u=void 0,console.error("Unhandled exception/rejection in previous request:",r),new i.RichServerError(s.Status.UNAVAILABLE,"Unhandled exception/rejection in previous request: "+h(r),[i.DebugInfo.fromPartial({detail:r.message,stackEntries:r.stack?.split(`
|
|
3
|
+
`)})])}let l=(n.workerTimeout||0)*1e3,P=n.enablePartition||!1;await new Promise((r,R)=>{let f=new D.Subject,m;f.subscribe(c=>{console.debug("Worker",o,"send response:",c.result?"result":"dbResult"),a.postMessage(c),c.result&&(m&&clearTimeout(m),r(),a.close())}),a.on("message",c=>{let g=c;console.debug("Worker",o,"received request:",g.start?"start":"dbResult"),d?.handleRequest(g,t.binding,f),P&&g.start&&l>0&&(m=setTimeout(async()=>{R(new i.RichServerError(s.Status.DEADLINE_EXCEEDED,"Worker timeout exceeded"))},l))}),console.debug("Worker",o,"handle request: binding"),d?.handleRequest(t,t.binding,f),!P&&l>0&&(m=setTimeout(()=>{R(new i.RichServerError(s.Status.DEADLINE_EXCEEDED,"Worker timeout exceeded"))},l))})}import("node:process").then(e=>e.stdout.write(""));export{F as default};
|
|
134
4
|
//# sourceMappingURL=service-worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/service-worker.ts"],"sourcesContent":["import { DeepPartial, Empty, ProcessStreamRequest, ProcessStreamResponse, StartRequest } from '@sentio/protos'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { errorString } from './utils.js'\nimport { freezeGlobalConfig } from './global-config.js'\nimport { DebugInfo, RichServerError } from 'nice-grpc-error-details'\nimport { ProcessorServiceImpl } from './service.js'\nimport { MessagePort, threadId } from 'worker_threads'\nimport { Piscina } from 'piscina'\nimport { configureEndpoints } from './endpoints.js'\nimport { setupLogger } from './logger.js'\nimport { Subject } from 'rxjs'\nimport { ProcessorRuntimeOptions } from 'processor-runner-program.js'\n\nlet started = false\n\nlet unhandled: Error | undefined\n\nprocess\n .on('uncaughtException', (err) => {\n console.error('Uncaught Exception, please checking if await is properly used', err)\n unhandled = err\n })\n .on('unhandledRejection', (reason, p) => {\n // @ts-ignore ignore invalid ens error\n if (reason?.message.startsWith('invalid ENS name (disallowed character: \"*\"')) {\n return\n }\n console.error('Unhandled Rejection, please checking if await is properly', reason)\n unhandled = reason as Error\n // shutdownServers(1)\n })\n .on('exit', () => {\n console.info('Worker thread exiting, threadId:', threadId)\n })\n\nlet service: ProcessorServiceImpl | undefined\n\nconst loader = async (options: ProcessorRuntimeOptions) => {\n if (options.target) {\n const m = await import(options.target)\n console.debug('Module loaded, path:', options.target, 'module:', m)\n return m\n }\n}\n\nconst emptyCallContext = <CallContext>{}\n\nasync function start(request: StartRequest, options: ProcessorRuntimeOptions): Promise<Empty> {\n if (started) {\n return {}\n }\n freezeGlobalConfig()\n\n try {\n service = new ProcessorServiceImpl(() => loader(options), options)\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n await service.start(request, emptyCallContext)\n started = true\n return {}\n}\n\nexport default async function ({\n processId,\n request: firstRequest,\n workerPort\n}: {\n processId: number\n request: ProcessStreamRequest\n workerPort: MessagePort\n}) {\n const { startRequest, configRequest, options } = Piscina.workerData\n if (!started) {\n const logLevel = process.env['LOG_LEVEL']?.toUpperCase()\n setupLogger(options.logFormat === 'json', logLevel === 'debug' ? true : options.debug, threadId)\n\n configureEndpoints(options)\n\n if (startRequest) {\n await start(startRequest, options)\n console.debug('worker', threadId, ' started, template instance:', startRequest.templateInstances?.length)\n }\n\n if (configRequest) {\n await service?.getConfig(configRequest, emptyCallContext)\n console.debug('worker', threadId, ' configured')\n }\n }\n\n if (unhandled) {\n const err = unhandled\n unhandled = undefined\n console.error('Unhandled exception/rejection in previous request:', err)\n throw new RichServerError(\n Status.UNAVAILABLE,\n 'Unhandled exception/rejection in previous request: ' + errorString(err),\n [\n DebugInfo.fromPartial({\n detail: err.message,\n stackEntries: err.stack?.split('\\n')\n })\n ]\n )\n }\n const timeout = (options.workerTimeout || 0) * 1000 // convert to milliseconds\n const enablePartition = options.enablePartition || false\n await new Promise<void>((resolve, reject) => {\n const subject = new Subject<DeepPartial<ProcessStreamResponse>>()\n let timeoutId: NodeJS.Timeout | undefined = undefined\n subject.subscribe((resp: ProcessStreamResponse) => {\n console.debug('Worker', threadId, 'send response:', resp.result ? 'result' : 'dbResult')\n workerPort.postMessage(resp)\n // receive the response from the processor , close and resolve the promise\n if (resp.result) {\n if (timeoutId) clearTimeout(timeoutId)\n resolve()\n workerPort.close()\n }\n })\n workerPort.on('message', (msg: ProcessStreamRequest) => {\n const request = msg as ProcessStreamRequest\n console.debug('Worker', threadId, 'received request:', request.start ? 'start' : 'dbResult')\n service?.handleRequest(request, firstRequest.binding, subject)\n if (enablePartition && request.start && timeout > 0) {\n timeoutId = setTimeout(async () => {\n reject(new RichServerError(Status.DEADLINE_EXCEEDED, 'Worker timeout exceeded'))\n }, timeout)\n }\n })\n console.debug('Worker', threadId, 'handle request: binding')\n service?.handleRequest(firstRequest, firstRequest.binding, subject)\n if (!enablePartition && timeout > 0) {\n timeoutId = setTimeout(() => {\n reject(new RichServerError(Status.DEADLINE_EXCEEDED, 'Worker timeout exceeded'))\n }, timeout)\n }\n })\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/service-worker.ts"],"sourcesContent":["import { DeepPartial, Empty, ProcessStreamRequest, ProcessStreamResponse, StartRequest } from '@sentio/protos'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { errorString } from './utils.js'\nimport { freezeGlobalConfig } from './global-config.js'\nimport { DebugInfo, RichServerError } from 'nice-grpc-error-details'\nimport { ProcessorServiceImpl } from './service.js'\nimport { MessagePort, threadId } from 'worker_threads'\nimport { Piscina } from 'piscina'\nimport { configureEndpoints } from './endpoints.js'\nimport { setupLogger } from './logger.js'\nimport { Subject } from 'rxjs'\nimport { ProcessorRuntimeOptions } from 'processor-runner-program.js'\n\nlet started = false\n\nlet unhandled: Error | undefined\n\nprocess\n .on('uncaughtException', (err) => {\n console.error('Uncaught Exception, please checking if await is properly used', err)\n unhandled = err\n })\n .on('unhandledRejection', (reason, p) => {\n // @ts-ignore ignore invalid ens error\n if (reason?.message.startsWith('invalid ENS name (disallowed character: \"*\"')) {\n return\n }\n console.error('Unhandled Rejection, please checking if await is properly', reason)\n unhandled = reason as Error\n // shutdownServers(1)\n })\n .on('exit', () => {\n console.info('Worker thread exiting, threadId:', threadId)\n })\n\nlet service: ProcessorServiceImpl | undefined\n\nconst loader = async (options: ProcessorRuntimeOptions) => {\n if (options.target) {\n const m = await import(options.target)\n console.debug('Module loaded, path:', options.target, 'module:', m)\n return m\n }\n}\n\nconst emptyCallContext = <CallContext>{}\n\nasync function start(request: StartRequest, options: ProcessorRuntimeOptions): Promise<Empty> {\n if (started) {\n return {}\n }\n freezeGlobalConfig()\n\n try {\n service = new ProcessorServiceImpl(() => loader(options), options)\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n await service.start(request, emptyCallContext)\n started = true\n return {}\n}\n\nexport default async function ({\n processId,\n request: firstRequest,\n workerPort\n}: {\n processId: number\n request: ProcessStreamRequest\n workerPort: MessagePort\n}) {\n const { startRequest, configRequest, options } = Piscina.workerData\n if (!started) {\n const logLevel = process.env['LOG_LEVEL']?.toUpperCase()\n setupLogger(options.logFormat === 'json', logLevel === 'debug' ? true : options.debug, threadId)\n\n configureEndpoints(options)\n\n if (startRequest) {\n await start(startRequest, options)\n console.debug('worker', threadId, ' started, template instance:', startRequest.templateInstances?.length)\n }\n\n if (configRequest) {\n await service?.getConfig(configRequest, emptyCallContext)\n console.debug('worker', threadId, ' configured')\n }\n }\n\n if (unhandled) {\n const err = unhandled\n unhandled = undefined\n console.error('Unhandled exception/rejection in previous request:', err)\n throw new RichServerError(\n Status.UNAVAILABLE,\n 'Unhandled exception/rejection in previous request: ' + errorString(err),\n [\n DebugInfo.fromPartial({\n detail: err.message,\n stackEntries: err.stack?.split('\\n')\n })\n ]\n )\n }\n const timeout = (options.workerTimeout || 0) * 1000 // convert to milliseconds\n const enablePartition = options.enablePartition || false\n await new Promise<void>((resolve, reject) => {\n const subject = new Subject<DeepPartial<ProcessStreamResponse>>()\n let timeoutId: NodeJS.Timeout | undefined = undefined\n subject.subscribe((resp: ProcessStreamResponse) => {\n console.debug('Worker', threadId, 'send response:', resp.result ? 'result' : 'dbResult')\n workerPort.postMessage(resp)\n // receive the response from the processor , close and resolve the promise\n if (resp.result) {\n if (timeoutId) clearTimeout(timeoutId)\n resolve()\n workerPort.close()\n }\n })\n workerPort.on('message', (msg: ProcessStreamRequest) => {\n const request = msg as ProcessStreamRequest\n console.debug('Worker', threadId, 'received request:', request.start ? 'start' : 'dbResult')\n service?.handleRequest(request, firstRequest.binding, subject)\n if (enablePartition && request.start && timeout > 0) {\n timeoutId = setTimeout(async () => {\n reject(new RichServerError(Status.DEADLINE_EXCEEDED, 'Worker timeout exceeded'))\n }, timeout)\n }\n })\n console.debug('Worker', threadId, 'handle request: binding')\n service?.handleRequest(firstRequest, firstRequest.binding, subject)\n if (!enablePartition && timeout > 0) {\n timeoutId = setTimeout(() => {\n reject(new RichServerError(Status.DEADLINE_EXCEEDED, 'Worker timeout exceeded'))\n }, timeout)\n }\n })\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";qNACA,IAAAA,EAAiD,SAGjD,IAAAC,EAA2C,SAE3C,OAAsB,YAAAC,MAAgB,iBACtC,OAAS,WAAAC,MAAe,UAGxB,IAAAC,EAAwB,SAGpBC,EAAU,GAEVC,EAEJ,QACG,GAAG,oBAAsBC,GAAQ,CAChC,QAAQ,MAAM,gEAAiEA,CAAG,EAClFD,EAAYC,CACd,CAAC,EACA,GAAG,qBAAsB,CAACC,EAAQC,IAAM,CAEnCD,GAAQ,QAAQ,WAAW,6CAA6C,IAG5E,QAAQ,MAAM,4DAA6DA,CAAM,EACjFF,EAAYE,EAEd,CAAC,EACA,GAAG,OAAQ,IAAM,CAChB,QAAQ,KAAK,mCAAoCE,CAAQ,CAC3D,CAAC,EAEH,IAAIC,EAEEC,EAAS,MAAOC,GAAqC,CACzD,GAAIA,EAAQ,OAAQ,CAClB,IAAMC,EAAI,MAAM,OAAOD,EAAQ,QAC/B,eAAQ,MAAM,uBAAwBA,EAAQ,OAAQ,UAAWC,CAAC,EAC3DA,CACT,CACF,EAEMC,EAAgC,CAAC,EAEvC,eAAeC,EAAMC,EAAuBJ,EAAkD,CAC5F,GAAIR,EACF,MAAO,CAAC,EAEVa,EAAmB,EAEnB,GAAI,CACFP,EAAU,IAAIQ,EAAqB,IAAMP,EAAOC,CAAO,EAAGA,CAAO,CACnE,OAASO,EAAG,CACV,MAAM,IAAI,cAAY,SAAO,iBAAkB,6BAA+BC,EAAYD,CAAC,CAAC,CAC9F,CAEA,aAAMT,EAAQ,MAAMM,EAASF,CAAgB,EAC7CV,EAAU,GACH,CAAC,CACV,CAEA,eAAOiB,EAAwB,CAC7B,UAAAC,EACA,QAASC,EACT,WAAAC,CACF,EAIG,CACD,GAAM,CAAE,aAAAC,EAAc,cAAAC,EAAe,QAAAd,CAAQ,EAAIe,EAAQ,WACzD,GAAI,CAACvB,EAAS,CACZ,IAAMwB,EAAW,QAAQ,IAAI,WAAc,YAAY,EACvDC,EAAYjB,EAAQ,YAAc,OAAQgB,IAAa,QAAU,GAAOhB,EAAQ,MAAOH,CAAQ,EAE/FqB,EAAmBlB,CAAO,EAEtBa,IACF,MAAMV,EAAMU,EAAcb,CAAO,EACjC,QAAQ,MAAM,SAAUH,EAAU,+BAAgCgB,EAAa,mBAAmB,MAAM,GAGtGC,IACF,MAAMhB,GAAS,UAAUgB,EAAeZ,CAAgB,EACxD,QAAQ,MAAM,SAAUL,EAAU,aAAa,EAEnD,CAEA,GAAIJ,EAAW,CACb,IAAMC,EAAMD,EACZ,MAAAA,EAAY,OACZ,QAAQ,MAAM,qDAAsDC,CAAG,EACjE,IAAI,kBACR,SAAO,YACP,sDAAwDc,EAAYd,CAAG,EACvE,CACE,YAAU,YAAY,CACpB,OAAQA,EAAI,QACZ,aAAcA,EAAI,OAAO,MAAM;AAAA,CAAI,CACrC,CAAC,CACH,CACF,CACF,CACA,IAAMyB,GAAWnB,EAAQ,eAAiB,GAAK,IACzCoB,EAAkBpB,EAAQ,iBAAmB,GACnD,MAAM,IAAI,QAAc,CAACqB,EAASC,IAAW,CAC3C,IAAMC,EAAU,IAAI,UAChBC,EACJD,EAAQ,UAAWE,GAAgC,CACjD,QAAQ,MAAM,SAAU5B,EAAU,iBAAkB4B,EAAK,OAAS,SAAW,UAAU,EACvFb,EAAW,YAAYa,CAAI,EAEvBA,EAAK,SACHD,GAAW,aAAaA,CAAS,EACrCH,EAAQ,EACRT,EAAW,MAAM,EAErB,CAAC,EACDA,EAAW,GAAG,UAAYc,GAA8B,CACtD,IAAMtB,EAAUsB,EAChB,QAAQ,MAAM,SAAU7B,EAAU,oBAAqBO,EAAQ,MAAQ,QAAU,UAAU,EAC3FN,GAAS,cAAcM,EAASO,EAAa,QAASY,CAAO,EACzDH,GAAmBhB,EAAQ,OAASe,EAAU,IAChDK,EAAY,WAAW,SAAY,CACjCF,EAAO,IAAI,kBAAgB,SAAO,kBAAmB,yBAAyB,CAAC,CACjF,EAAGH,CAAO,EAEd,CAAC,EACD,QAAQ,MAAM,SAAUtB,EAAU,yBAAyB,EAC3DC,GAAS,cAAca,EAAcA,EAAa,QAASY,CAAO,EAC9D,CAACH,GAAmBD,EAAU,IAChCK,EAAY,WAAW,IAAM,CAC3BF,EAAO,IAAI,kBAAgB,SAAO,kBAAmB,yBAAyB,CAAC,CACjF,EAAGH,CAAO,EAEd,CAAC,CACH,CACC,OAAO,cAAc,EAAE,KAAMvB,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC","names":["import_nice_grpc","import_nice_grpc_error_details","threadId","Piscina","import_rxjs","started","unhandled","err","reason","p","threadId","service","loader","options","m","emptyCallContext","start","request","freezeGlobalConfig","ProcessorServiceImpl","e","errorString","service_worker_default","processId","firstRequest","workerPort","startRequest","configRequest","Piscina","logLevel","setupLogger","configureEndpoints","timeout","enablePartition","resolve","reject","subject","timeoutId","resp","msg"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Plugin, D as DataBinding, a as ProcessResult, H as HandlerType } from './processor-
|
|
1
|
+
import { P as Plugin, D as DataBinding, a as ProcessResult, H as HandlerType } from './processor-BUTmbpmJ.js';
|
|
2
2
|
import { ProcessStreamResponse_Partitions, InitResponse, ProcessConfigResponse } from '@sentio/protos';
|
|
3
3
|
import 'rxjs';
|
|
4
4
|
import 'node:async_hooks';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/test-processor.test.ts"],"sourcesContent":["import { Plugin, PluginManager } from './plugin.js'\nimport { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'\nimport { AccountConfig, InitResponse, ProcessConfigResponse, ProcessStreamResponse_Partitions } from '@sentio/protos'\n\nexport class TestPlugin extends Plugin {\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n const dbContext = PluginManager.INSTANCE.dbContextLocalStorage.getStore()\n if (dbContext) {\n await dbContext.sendRequest({\n get: {\n entity: 'Test',\n id: '1'\n }\n })\n }\n\n return ProcessResult.fromPartial({\n states: {\n configUpdated: true\n }\n })\n }\n supportedHandlers = [HandlerType.UNKNOWN, HandlerType.ETH_LOG]\n\n async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {\n return {\n partitions: request.handlerIds.reduce(\n (acc, id) => ({\n ...acc,\n [id]: {\n userValue: 'test'\n }\n }),\n {}\n )\n }\n }\n\n async init(config: InitResponse): Promise<void> {\n config.chainIds = ['1']\n }\n\n async configure(config: ProcessConfigResponse, forChainId?: string): Promise<void> {\n config.accountConfigs = [\n AccountConfig.fromPartial({\n address: '0x',\n chainId: '1'\n })\n ]\n }\n}\n\nPluginManager.INSTANCE.plugins = []\nPluginManager.INSTANCE.register(new TestPlugin())\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/test-processor.test.ts"],"sourcesContent":["import { Plugin, PluginManager } from './plugin.js'\nimport { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'\nimport { AccountConfig, InitResponse, ProcessConfigResponse, ProcessStreamResponse_Partitions } from '@sentio/protos'\n\nexport class TestPlugin extends Plugin {\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n const dbContext = PluginManager.INSTANCE.dbContextLocalStorage.getStore()\n if (dbContext) {\n await dbContext.sendRequest({\n get: {\n entity: 'Test',\n id: '1'\n }\n })\n }\n\n return ProcessResult.fromPartial({\n states: {\n configUpdated: true\n }\n })\n }\n supportedHandlers = [HandlerType.UNKNOWN, HandlerType.ETH_LOG]\n\n async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {\n return {\n partitions: request.handlerIds.reduce(\n (acc, id) => ({\n ...acc,\n [id]: {\n userValue: 'test'\n }\n }),\n {}\n )\n }\n }\n\n async init(config: InitResponse): Promise<void> {\n config.chainIds = ['1']\n }\n\n async configure(config: ProcessConfigResponse, forChainId?: string): Promise<void> {\n config.accountConfigs = [\n AccountConfig.fromPartial({\n address: '0x',\n chainId: '1'\n })\n ]\n }\n}\n\nPluginManager.INSTANCE.plugins = []\nPluginManager.INSTANCE.register(new TestPlugin())\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";yFAIO,IAAMA,EAAN,cAAyBC,CAAO,CACrC,MAAM,eAAeC,EAA8C,CACjE,IAAMC,EAAYC,EAAc,SAAS,sBAAsB,SAAS,EACxE,OAAID,GACF,MAAMA,EAAU,YAAY,CAC1B,IAAK,CACH,OAAQ,OACR,GAAI,GACN,CACF,CAAC,EAGIE,EAAc,YAAY,CAC/B,OAAQ,CACN,cAAe,EACjB,CACF,CAAC,CACH,CACA,kBAAoB,IAAyC,EAE7D,MAAM,UAAUH,EAAiE,CAC/E,MAAO,CACL,WAAYA,EAAQ,WAAW,OAC7B,CAACI,EAAKC,KAAQ,CACZ,GAAGD,EACH,CAACC,CAAE,EAAG,CACJ,UAAW,MACb,CACF,GACA,CAAC,CACH,CACF,CACF,CAEA,MAAM,KAAKC,EAAqC,CAC9CA,EAAO,SAAW,CAAC,GAAG,CACxB,CAEA,MAAM,UAAUA,EAA+BC,EAAoC,CACjFD,EAAO,eAAiB,CACtBE,EAAc,YAAY,CACxB,QAAS,KACT,QAAS,GACX,CAAC,CACH,CACF,CACF,EAEAN,EAAc,SAAS,QAAU,CAAC,EAClCA,EAAc,SAAS,SAAS,IAAIJ,CAAY,EAC/C,OAAO,cAAc,EAAE,KAAMW,GAAMA,EAAE,OAAO,MAAM,EAAE,CAAC","names":["TestPlugin","Plugin","request","dbContext","PluginManager","ProcessResult","acc","id","config","forChainId","AccountConfig","p"]}
|
package/package.json
CHANGED
package/src/db-context.ts
CHANGED
|
@@ -42,7 +42,7 @@ export interface IStoreContext {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface IDataBindingContext extends IStoreContext {
|
|
45
|
-
sendTemplateRequest(templates: Array<TemplateInstance
|
|
45
|
+
sendTemplateRequest(templates: Array<TemplateInstance>, unbind: boolean): void
|
|
46
46
|
sendTimeseriesRequest(timeseries: Array<TimeseriesResult>): void
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -262,11 +262,12 @@ export class DataBindingContext extends AbstractStoreContext implements IDataBin
|
|
|
262
262
|
super(processId)
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
sendTemplateRequest(templates: Array<TemplateInstance
|
|
265
|
+
sendTemplateRequest(templates: Array<TemplateInstance>, unbind: boolean) {
|
|
266
266
|
this.subject.next({
|
|
267
267
|
processId: this.processId,
|
|
268
268
|
tplRequest: {
|
|
269
|
-
templates
|
|
269
|
+
templates,
|
|
270
|
+
remove: unbind
|
|
270
271
|
}
|
|
271
272
|
})
|
|
272
273
|
}
|
|
@@ -280,7 +281,6 @@ export class DataBindingContext extends AbstractStoreContext implements IDataBin
|
|
|
280
281
|
}
|
|
281
282
|
|
|
282
283
|
doSend(resp: DeepPartial<ProcessStreamResponseV3>) {
|
|
283
|
-
console.debug('sending db request, processId ', this.processId, 'opId', resp.dbRequest?.opId)
|
|
284
284
|
this.subject.next({
|
|
285
285
|
...resp,
|
|
286
286
|
processId: this.processId
|
|
@@ -1062,6 +1062,7 @@ export interface EntityUpdateData_FieldsEntry {
|
|
|
1062
1062
|
|
|
1063
1063
|
export interface TPLRequest {
|
|
1064
1064
|
templates: TemplateInstance[];
|
|
1065
|
+
remove: boolean;
|
|
1065
1066
|
}
|
|
1066
1067
|
|
|
1067
1068
|
export interface TSRequest {
|
|
@@ -8749,7 +8750,7 @@ export const EntityUpdateData_FieldsEntry = {
|
|
|
8749
8750
|
};
|
|
8750
8751
|
|
|
8751
8752
|
function createBaseTPLRequest(): TPLRequest {
|
|
8752
|
-
return { templates: [] };
|
|
8753
|
+
return { templates: [], remove: false };
|
|
8753
8754
|
}
|
|
8754
8755
|
|
|
8755
8756
|
export const TPLRequest = {
|
|
@@ -8757,6 +8758,9 @@ export const TPLRequest = {
|
|
|
8757
8758
|
for (const v of message.templates) {
|
|
8758
8759
|
TemplateInstance.encode(v!, writer.uint32(10).fork()).ldelim();
|
|
8759
8760
|
}
|
|
8761
|
+
if (message.remove !== false) {
|
|
8762
|
+
writer.uint32(16).bool(message.remove);
|
|
8763
|
+
}
|
|
8760
8764
|
return writer;
|
|
8761
8765
|
},
|
|
8762
8766
|
|
|
@@ -8774,6 +8778,13 @@ export const TPLRequest = {
|
|
|
8774
8778
|
|
|
8775
8779
|
message.templates.push(TemplateInstance.decode(reader, reader.uint32()));
|
|
8776
8780
|
continue;
|
|
8781
|
+
case 2:
|
|
8782
|
+
if (tag !== 16) {
|
|
8783
|
+
break;
|
|
8784
|
+
}
|
|
8785
|
+
|
|
8786
|
+
message.remove = reader.bool();
|
|
8787
|
+
continue;
|
|
8777
8788
|
}
|
|
8778
8789
|
if ((tag & 7) === 4 || tag === 0) {
|
|
8779
8790
|
break;
|
|
@@ -8788,6 +8799,7 @@ export const TPLRequest = {
|
|
|
8788
8799
|
templates: globalThis.Array.isArray(object?.templates)
|
|
8789
8800
|
? object.templates.map((e: any) => TemplateInstance.fromJSON(e))
|
|
8790
8801
|
: [],
|
|
8802
|
+
remove: isSet(object.remove) ? globalThis.Boolean(object.remove) : false,
|
|
8791
8803
|
};
|
|
8792
8804
|
},
|
|
8793
8805
|
|
|
@@ -8796,6 +8808,9 @@ export const TPLRequest = {
|
|
|
8796
8808
|
if (message.templates?.length) {
|
|
8797
8809
|
obj.templates = message.templates.map((e) => TemplateInstance.toJSON(e));
|
|
8798
8810
|
}
|
|
8811
|
+
if (message.remove !== false) {
|
|
8812
|
+
obj.remove = message.remove;
|
|
8813
|
+
}
|
|
8799
8814
|
return obj;
|
|
8800
8815
|
},
|
|
8801
8816
|
|
|
@@ -8805,6 +8820,7 @@ export const TPLRequest = {
|
|
|
8805
8820
|
fromPartial(object: DeepPartial<TPLRequest>): TPLRequest {
|
|
8806
8821
|
const message = createBaseTPLRequest();
|
|
8807
8822
|
message.templates = object.templates?.map((e) => TemplateInstance.fromPartial(e)) || [];
|
|
8823
|
+
message.remove = object.remove ?? false;
|
|
8808
8824
|
return message;
|
|
8809
8825
|
},
|
|
8810
8826
|
};
|