@sentio/runtime 2.60.0-rc.9 → 2.60.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.
@@ -1,132 +1,4 @@
1
1
  import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
2
- import {
3
- setupLogger
4
- } from "./chunk-RJMWLF3Q.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-EFMEF6FT.js";
14
- import {
15
- __toESM
16
- } from "./chunk-AQYRWO7H.js";
17
-
18
- // src/service-worker.ts
19
- var import_nice_grpc = __toESM(require_lib(), 1);
20
- var import_nice_grpc_error_details = __toESM(require_lib2(), 1);
21
- import { threadId } from "worker_threads";
22
- import { Piscina } from "piscina";
23
- var import_rxjs = __toESM(require_cjs(), 1);
24
- var started = false;
25
- var unhandled;
26
- process.on("uncaughtException", (err) => {
27
- console.error("Uncaught Exception, please checking if await is properly used", err);
28
- unhandled = err;
29
- }).on("unhandledRejection", (reason, p) => {
30
- if (reason?.message.startsWith('invalid ENS name (disallowed character: "*"')) {
31
- return;
32
- }
33
- console.error("Unhandled Rejection, please checking if await is properly", reason);
34
- unhandled = reason;
35
- }).on("exit", () => {
36
- console.info("Worker thread exiting, threadId:", threadId);
37
- });
38
- var service;
39
- var loader = async (options) => {
40
- if (options.target) {
41
- const m = await import(options.target);
42
- console.debug("Module loaded, path:", options.target, "module:", m);
43
- return m;
44
- }
45
- };
46
- var emptyCallContext = {};
47
- async function start(request, options) {
48
- if (started) {
49
- return {};
50
- }
51
- freezeGlobalConfig();
52
- try {
53
- service = new ProcessorServiceImpl(() => loader(options), options);
54
- } catch (e) {
55
- throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "Failed to load processor: " + errorString(e));
56
- }
57
- await service.start(request, emptyCallContext);
58
- started = true;
59
- return {};
60
- }
61
- async function service_worker_default({
62
- processId,
63
- request: firstRequest,
64
- workerPort
65
- }) {
66
- const { startRequest, configRequest, options } = Piscina.workerData;
67
- if (!started) {
68
- const logLevel = process.env["LOG_LEVEL"]?.toUpperCase();
69
- setupLogger(options["log-format"] === "json", logLevel === "debug" ? true : options.debug, threadId);
70
- configureEndpoints(options);
71
- if (startRequest) {
72
- await start(startRequest, options);
73
- console.debug("worker", threadId, " started, template instance:", startRequest.templateInstances?.length);
74
- }
75
- if (configRequest) {
76
- await service?.getConfig(configRequest, emptyCallContext);
77
- console.debug("worker", threadId, " configured");
78
- }
79
- }
80
- if (unhandled) {
81
- const err = unhandled;
82
- unhandled = void 0;
83
- console.error("Unhandled exception/rejection in previous request:", err);
84
- throw new import_nice_grpc_error_details.RichServerError(
85
- import_nice_grpc.Status.UNAVAILABLE,
86
- "Unhandled exception/rejection in previous request: " + errorString(err),
87
- [
88
- import_nice_grpc_error_details.DebugInfo.fromPartial({
89
- detail: err.message,
90
- stackEntries: err.stack?.split("\n")
91
- })
92
- ]
93
- );
94
- }
95
- const timeout = (options["worker-timeout"] || 0) * 1e3;
96
- const enablePartition = options["enable-partition"] || false;
97
- await new Promise((resolve, reject) => {
98
- const subject = new import_rxjs.Subject();
99
- let timeoutId = void 0;
100
- subject.subscribe((resp) => {
101
- console.debug("Worker", threadId, "send response:", resp.result ? "result" : "dbResult");
102
- workerPort.postMessage(resp);
103
- if (resp.result) {
104
- if (timeoutId) clearTimeout(timeoutId);
105
- resolve();
106
- workerPort.close();
107
- }
108
- });
109
- workerPort.on("message", (msg) => {
110
- const request = msg;
111
- console.debug("Worker", threadId, "received request:", request.start ? "start" : "dbResult");
112
- service?.handleRequest(request, firstRequest.binding, subject);
113
- if (enablePartition && request.start && timeout > 0) {
114
- timeoutId = setTimeout(async () => {
115
- reject(new import_nice_grpc_error_details.RichServerError(import_nice_grpc.Status.DEADLINE_EXCEEDED, "Worker timeout exceeded"));
116
- }, timeout);
117
- }
118
- });
119
- console.debug("Worker", threadId, "handle request: binding");
120
- service?.handleRequest(firstRequest, firstRequest.binding, subject);
121
- if (!enablePartition && timeout > 0) {
122
- timeoutId = setTimeout(() => {
123
- reject(new import_nice_grpc_error_details.RichServerError(import_nice_grpc.Status.DEADLINE_EXCEEDED, "Worker timeout exceeded"));
124
- }, timeout);
125
- }
126
- });
127
- }
128
- import("node:process").then((p) => p.stdout.write(""));
129
- export {
130
- service_worker_default as default
131
- };
2
+ import{a as k}from"./chunk-NWI5IEZU.js";import{Z as C,c as h,ca as I,j as R,p as x,q as y,u as q}from"./chunk-K3OKCXRW.js";import{e as E}from"./chunk-YYEA4PFJ.js";var s=E(x(),1);var i=E(y(),1);import{threadId as o}from"worker_threads";import{Piscina as L}from"piscina";var D=E(C(),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 z({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["log-format"]==="json",r==="debug"?!0:n.debug,o),R(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["worker-timeout"]||0)*1e3,S=n["enable-partition"]||!1;await new Promise((r,P)=>{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),S&&g.start&&l>0&&(m=setTimeout(async()=>{P(new i.RichServerError(s.Status.DEADLINE_EXCEEDED,"Worker timeout exceeded"))},l))}),console.debug("Worker",o,"handle request: binding"),d?.handleRequest(t,t.binding,f),!S&&l>0&&(m=setTimeout(()=>{P(new i.RichServerError(s.Status.DEADLINE_EXCEEDED,"Worker timeout exceeded"))},l))})}import("node:process").then(e=>e.stdout.write(""));export{z as default};
132
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'\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: any) => {\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: any): 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['log-format'] === '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['worker-timeout'] || 0) * 1000 // convert to milliseconds\n const enablePartition = options['enable-partition'] || 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":";;;;;;;;;;;;;;;;;;AACA,uBAAiD;AAGjD,qCAA2C;AAE3C,SAAsB,gBAAgB;AACtC,SAAS,eAAe;AAGxB,kBAAwB;AAExB,IAAI,UAAU;AAEd,IAAI;AAEJ,QACG,GAAG,qBAAqB,CAAC,QAAQ;AAChC,UAAQ,MAAM,iEAAiE,GAAG;AAClF,cAAY;AACd,CAAC,EACA,GAAG,sBAAsB,CAAC,QAAQ,MAAM;AAEvC,MAAI,QAAQ,QAAQ,WAAW,6CAA6C,GAAG;AAC7E;AAAA,EACF;AACA,UAAQ,MAAM,6DAA6D,MAAM;AACjF,cAAY;AAEd,CAAC,EACA,GAAG,QAAQ,MAAM;AAChB,UAAQ,KAAK,oCAAoC,QAAQ;AAC3D,CAAC;AAEH,IAAI;AAEJ,IAAM,SAAS,OAAO,YAAiB;AACrC,MAAI,QAAQ,QAAQ;AAClB,UAAM,IAAI,MAAM,OAAO,QAAQ;AAC/B,YAAQ,MAAM,wBAAwB,QAAQ,QAAQ,WAAW,CAAC;AAClE,WAAO;AAAA,EACT;AACF;AAEA,IAAM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AAK;AACnD,QAAM,kBAAkB,QAAQ,kBAAkB,KAAK;AACvD,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC3C,UAAM,UAAU,IAAI,oBAA4C;AAChE,QAAI,YAAwC;AAC5C,YAAQ,UAAU,CAAC,SAAgC;AACjD,cAAQ,MAAM,UAAU,UAAU,kBAAkB,KAAK,SAAS,WAAW,UAAU;AACvF,iBAAW,YAAY,IAAI;AAE3B,UAAI,KAAK,QAAQ;AACf,YAAI,UAAW,cAAa,SAAS;AACrC,gBAAQ;AACR,mBAAW,MAAM;AAAA,MACnB;AAAA,IACF,CAAC;AACD,eAAW,GAAG,WAAW,CAAC,QAA8B;AACtD,YAAM,UAAU;AAChB,cAAQ,MAAM,UAAU,UAAU,qBAAqB,QAAQ,QAAQ,UAAU,UAAU;AAC3F,eAAS,cAAc,SAAS,aAAa,SAAS,OAAO;AAC7D,UAAI,mBAAmB,QAAQ,SAAS,UAAU,GAAG;AACnD,oBAAY,WAAW,YAAY;AACjC,iBAAO,IAAI,+CAAgB,wBAAO,mBAAmB,yBAAyB,CAAC;AAAA,QACjF,GAAG,OAAO;AAAA,MACZ;AAAA,IACF,CAAC;AACD,YAAQ,MAAM,UAAU,UAAU,yBAAyB;AAC3D,aAAS,cAAc,cAAc,aAAa,SAAS,OAAO;AAClE,QAAI,CAAC,mBAAmB,UAAU,GAAG;AACnC,kBAAY,WAAW,MAAM;AAC3B,eAAO,IAAI,+CAAgB,wBAAO,mBAAmB,yBAAyB,CAAC;AAAA,MACjF,GAAG,OAAO;AAAA,IACZ;AAAA,EACF,CAAC;AACH;AACC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
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'\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: any) => {\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: any): 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['log-format'] === '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['worker-timeout'] || 0) * 1000 // convert to milliseconds\n const enablePartition = options['enable-partition'] || 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":";mKACA,IAAAA,EAAiD,SAGjD,IAAAC,EAA2C,SAE3C,OAAsB,YAAAC,MAAgB,iBACtC,OAAS,WAAAC,MAAe,UAGxB,IAAAC,EAAwB,SAEpBC,EAAU,GAEVC,EAEJ,QACG,GAAG,oBAAsBC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,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,2 +1,15 @@
1
+ import { P as Plugin, c as DataBinding, d as ProcessResult, H as HandlerType } from './processor-BDXlufg5.js';
2
+ import { ProcessStreamResponse_Partitions, InitResponse, ProcessConfigResponse } from '@sentio/protos';
3
+ import 'rxjs';
4
+ import 'node:async_hooks';
5
+ import 'protobufjs/minimal.js';
1
6
 
2
- export { }
7
+ declare class TestPlugin extends Plugin {
8
+ processBinding(request: DataBinding): Promise<ProcessResult>;
9
+ supportedHandlers: HandlerType[];
10
+ partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions>;
11
+ init(config: InitResponse): Promise<void>;
12
+ configure(config: ProcessConfigResponse, forChainId?: string): Promise<void>;
13
+ }
14
+
15
+ export { TestPlugin };
@@ -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 { ProcessStreamResponse_Partitions } from '@sentio/protos'\n\nclass 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\nPluginManager.INSTANCE.plugins = []\nPluginManager.INSTANCE.register(new TestPlugin())\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;AAIA,IAAM,aAAN,cAAyB,OAAO;AAAA,EAC9B,MAAM,eAAe,SAA8C;AACjE,UAAM,YAAY,cAAc,SAAS,sBAAsB,SAAS;AACxE,QAAI,WAAW;AACb,YAAM,UAAU,YAAY;AAAA,QAC1B,KAAK;AAAA,UACH,QAAQ;AAAA,UACR,IAAI;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO,cAAc,YAAY;AAAA,MAC/B,QAAQ;AAAA,QACN,eAAe;AAAA,MACjB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EACA,oBAAoB,iCAAyC;AAAA,EAE7D,MAAM,UAAU,SAAiE;AAC/E,WAAO;AAAA,MACL,YAAY,QAAQ,WAAW;AAAA,QAC7B,CAAC,KAAK,QAAQ;AAAA,UACZ,GAAG;AAAA,UACH,CAAC,EAAE,GAAG;AAAA,YACJ,WAAW;AAAA,UACb;AAAA,QACF;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAEA,cAAc,SAAS,UAAU,CAAC;AAClC,cAAc,SAAS,SAAS,IAAI,WAAW,CAAC;AAC/C,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
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":";6DAIO,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "2.60.0-rc.9",
3
+ "version": "2.60.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
package/src/db-context.ts CHANGED
@@ -280,6 +280,7 @@ export class DataBindingContext extends AbstractStoreContext implements IDataBin
280
280
  }
281
281
 
282
282
  doSend(resp: DeepPartial<ProcessStreamResponseV2>) {
283
+ console.debug('sending db request, processId ', this.processId, 'opId', resp.dbRequest?.opId)
283
284
  this.subject.next({
284
285
  ...resp,
285
286
  processId: this.processId
@@ -2,19 +2,22 @@ import { CallContext } from 'nice-grpc'
2
2
  import { createRequire } from 'module'
3
3
  // Different than the simple one which
4
4
  import {
5
+ ConfigureHandlersRequest,
5
6
  DataBinding,
6
7
  ExecutionConfig,
7
8
  HandlerType,
9
+ InitResponse,
8
10
  PreprocessStreamRequest,
9
11
  ProcessBindingsRequest,
10
12
  ProcessConfigRequest,
13
+ ProcessConfigResponse,
11
14
  ProcessorServiceImplementation,
12
15
  ProcessResult,
13
16
  ProcessStreamRequest,
14
17
  StartRequest
15
18
  } from './gen/processor/protos/processor.js'
16
19
 
17
- import { Empty } from '@sentio/protos'
20
+ import { ConfigureHandlersResponse, DeepPartial, Empty, ProcessorV3ServiceImplementation } from '@sentio/protos'
18
21
  import fs from 'fs-extra'
19
22
  import path from 'path'
20
23
  import os from 'os'
@@ -78,9 +81,15 @@ function locatePackageJson(pkgId: string) {
78
81
  return JSON.parse(content)
79
82
  }
80
83
 
81
- export class FullProcessorServiceImpl implements ProcessorServiceImplementation {
82
- constructor(instance: ProcessorServiceImplementation) {
83
- this.instance = instance
84
+ /**
85
+ * The RuntimeServicePatcher class is responsible for providing backward compatibility
86
+ * patches for different SDK versions. It ensures that the runtime can adapt to changes
87
+ * in the SDK by applying necessary adjustments to data bindings and other configurations.
88
+ */
89
+ export class RuntimeServicePatcher {
90
+ sdkVersion: Semver
91
+
92
+ constructor() {
84
93
  const sdkPackageJson = locatePackageJson('@sentio/sdk')
85
94
  const runtimePackageJson = locatePackageJson('@sentio/runtime')
86
95
 
@@ -89,111 +98,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
89
98
  this.sdkVersion = parseSemver(sdkPackageJson.version)
90
99
  }
91
100
 
92
- instance: ProcessorServiceImplementation
93
- sdkVersion: Semver
94
-
95
- async getConfig(request: ProcessConfigRequest, context: CallContext) {
96
- const config = await this.instance.getConfig(request, context)
97
- config.executionConfig = ExecutionConfig.fromPartial(GLOBAL_CONFIG.execution)
98
-
99
- if (config.contractConfigs) {
100
- for (const contract of config.contractConfigs) {
101
- // for old fuel processor
102
- if (
103
- compareSemver(this.sdkVersion, FUEL_PROTO_NO_FUEL_TRANSACTION_AS_CALL_VERSION) < 0 &&
104
- contract.fuelCallConfigs
105
- ) {
106
- contract.fuelTransactionConfigs = contract.fuelCallConfigs
107
- contract.fuelCallConfigs = undefined
108
- }
109
-
110
- // @ts-ignore convert old fuelLogConfigs to fuelReceiptConfigs
111
- if (contract.fuelLogConfigs) {
112
- contract.fuelReceiptConfigs = contract.fuelLogConfigs.map((e) => ({
113
- handlerId: e.handlerId,
114
- handlerName: e.handlerName,
115
- log: {
116
- logIds: e.logIds
117
- }
118
- }))
119
- }
120
-
121
- // @ts-ignore old fields
122
- if (contract.aptosCallConfigs) {
123
- // @ts-ignore old fields
124
- contract.moveCallConfigs = contract.aptosCallConfigs
125
- }
126
- // @ts-ignore old fields
127
- if (contract.aptosEventConfigs) {
128
- // @ts-ignore old fields
129
- contract.moveEventConfigs = contract.aptosEventConfigs
130
- }
131
- }
132
- }
133
-
134
- if (compareSemver(this.sdkVersion, MOVE_USE_RAW_VERSION) < 0) {
135
- PROCESSED_MOVE_EVENT_TX_HANDLER.clear()
136
- }
137
-
138
- return config
139
- }
140
-
141
- async start(request: StartRequest, context: CallContext) {
142
- return await this.instance.start(request, context)
143
- }
144
-
145
- async stop(request: Empty, context: CallContext) {
146
- return await this.instance.stop(request, context)
147
- }
148
-
149
- async processBindings(request: ProcessBindingsRequest, options: CallContext) {
150
- // if (GLOBAL_CONFIG.execution.sequential) {
151
- // request.bindings = request.bindings.sort(dataCompare)
152
- // }
153
-
154
- for (const binding of request.bindings) {
155
- this.adjustDataBinding(binding)
156
- }
157
- try {
158
- const result = await this.instance.processBindings(request, options)
159
- this.adjustResult(result.result as ProcessResult)
160
- if (!result.configUpdated && result.result?.states?.configUpdated) {
161
- result.configUpdated = result.result?.states?.configUpdated
162
- }
163
- return result
164
- } catch (e) {
165
- if (this.sdkVersion.minor <= 16) {
166
- // Old sdk doesn't handle this well
167
- if (
168
- e.code === os.constants.errno.ECONNRESET ||
169
- e.code === os.constants.errno.ECONNREFUSED ||
170
- e.code === os.constants.errno.ECONNABORTED
171
- ) {
172
- process.exit(1)
173
- }
174
- }
175
- throw e
176
- }
177
- }
178
-
179
- async *adjustBindingsStream(requests: AsyncIterable<ProcessStreamRequest>): AsyncIterable<ProcessStreamRequest> {
180
- for await (const request of requests) {
181
- this.adjustDataBinding(request.binding)
182
- yield request
183
- }
184
- }
185
-
186
- async *processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext) {
187
- yield* this.instance.processBindingsStream(this.adjustBindingsStream(requests), context)
188
- }
189
-
190
- async *preprocessBindingsStream(requests: AsyncIterable<PreprocessStreamRequest>, context: CallContext) {
191
- yield* this.instance.preprocessBindingsStream(this.adjustBindingsStream(requests), context)
192
- }
193
-
194
- private adjustResult(res: ProcessResult): void {}
195
-
196
- private adjustDataBinding(dataBinding?: DataBinding): void {
101
+ adjustDataBinding(dataBinding?: DataBinding): void {
197
102
  const isBeforeMoveUseRawVersion = compareSemver(this.sdkVersion, MOVE_USE_RAW_VERSION) < 0
198
103
  // const isBeforeEthUseRawVersion = compareSemver(this.sdkVersion,ETH_USE_RAW_VERSION) < 0
199
104
 
@@ -350,6 +255,127 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
350
255
  break
351
256
  }
352
257
  }
258
+
259
+ patchConfig(config: DeepPartial<ProcessConfigResponse>): void {
260
+ config.executionConfig = ExecutionConfig.fromPartial(GLOBAL_CONFIG.execution)
261
+
262
+ if (config.contractConfigs) {
263
+ for (const contract of config.contractConfigs) {
264
+ // for old fuel processor
265
+ if (
266
+ compareSemver(this.sdkVersion, FUEL_PROTO_NO_FUEL_TRANSACTION_AS_CALL_VERSION) < 0 &&
267
+ contract.fuelCallConfigs
268
+ ) {
269
+ contract.fuelTransactionConfigs = contract.fuelCallConfigs
270
+ contract.fuelCallConfigs = undefined
271
+ }
272
+
273
+ // @ts-ignore convert old fuelLogConfigs to fuelReceiptConfigs
274
+ if (contract.fuelLogConfigs) {
275
+ contract.fuelReceiptConfigs = contract.fuelLogConfigs.map((e) => ({
276
+ handlerId: e.handlerId,
277
+ handlerName: e.handlerName,
278
+ log: {
279
+ logIds: e.logIds
280
+ }
281
+ }))
282
+ }
283
+
284
+ // @ts-ignore old fields
285
+ if (contract.aptosCallConfigs) {
286
+ // @ts-ignore old fields
287
+ contract.moveCallConfigs = contract.aptosCallConfigs
288
+ }
289
+ // @ts-ignore old fields
290
+ if (contract.aptosEventConfigs) {
291
+ // @ts-ignore old fields
292
+ contract.moveEventConfigs = contract.aptosEventConfigs
293
+ }
294
+ }
295
+ }
296
+ }
297
+ }
298
+
299
+ export class FullProcessorServiceImpl implements ProcessorServiceImplementation {
300
+ constructor(instance: ProcessorServiceImplementation) {
301
+ this.instance = instance
302
+ const sdkPackageJson = locatePackageJson('@sentio/sdk')
303
+ const runtimePackageJson = locatePackageJson('@sentio/runtime')
304
+
305
+ console.log('Runtime version:', runtimePackageJson.version, 'SDK version:', sdkPackageJson.version)
306
+
307
+ this.sdkVersion = parseSemver(sdkPackageJson.version)
308
+ }
309
+
310
+ instance: ProcessorServiceImplementation
311
+ sdkVersion: Semver
312
+ patcher: RuntimeServicePatcher = new RuntimeServicePatcher()
313
+
314
+ async getConfig(request: ProcessConfigRequest, context: CallContext) {
315
+ const config = await this.instance.getConfig(request, context)
316
+ this.patcher.patchConfig(config)
317
+
318
+ if (compareSemver(this.sdkVersion, MOVE_USE_RAW_VERSION) < 0) {
319
+ PROCESSED_MOVE_EVENT_TX_HANDLER.clear()
320
+ }
321
+
322
+ return config
323
+ }
324
+
325
+ async start(request: StartRequest, context: CallContext) {
326
+ return await this.instance.start(request, context)
327
+ }
328
+
329
+ async stop(request: Empty, context: CallContext) {
330
+ return await this.instance.stop(request, context)
331
+ }
332
+
333
+ async processBindings(request: ProcessBindingsRequest, options: CallContext) {
334
+ // if (GLOBAL_CONFIG.execution.sequential) {
335
+ // request.bindings = request.bindings.sort(dataCompare)
336
+ // }
337
+
338
+ for (const binding of request.bindings) {
339
+ this.patcher.adjustDataBinding(binding)
340
+ }
341
+ try {
342
+ const result = await this.instance.processBindings(request, options)
343
+ this.adjustResult(result.result as ProcessResult)
344
+ if (!result.configUpdated && result.result?.states?.configUpdated) {
345
+ result.configUpdated = result.result?.states?.configUpdated
346
+ }
347
+ return result
348
+ } catch (e) {
349
+ if (this.sdkVersion.minor <= 16) {
350
+ // Old sdk doesn't handle this well
351
+ if (
352
+ e.code === os.constants.errno.ECONNRESET ||
353
+ e.code === os.constants.errno.ECONNREFUSED ||
354
+ e.code === os.constants.errno.ECONNABORTED
355
+ ) {
356
+ process.exit(1)
357
+ }
358
+ }
359
+ throw e
360
+ }
361
+ }
362
+
363
+ async *adjustBindingsStream(requests: AsyncIterable<ProcessStreamRequest>): AsyncIterable<ProcessStreamRequest> {
364
+ for await (const request of requests) {
365
+ this.patcher.adjustDataBinding(request.binding)
366
+ yield request
367
+ }
368
+ }
369
+
370
+ async *processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext) {
371
+ yield* this.instance.processBindingsStream(this.adjustBindingsStream(requests), context)
372
+ }
373
+
374
+ async *preprocessBindingsStream(requests: AsyncIterable<PreprocessStreamRequest>, context: CallContext) {
375
+ yield* this.instance.preprocessBindingsStream(this.adjustBindingsStream(requests), context)
376
+ }
377
+
378
+ private adjustResult(res: ProcessResult): void {}
353
379
  }
354
380
 
355
381
  // function dataCompare(a: DataBinding, b: DataBinding): number {
@@ -383,3 +409,35 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
383
409
  // d.data?.ethTrace?.trace?.transactionPosition
384
410
  // )
385
411
  // }
412
+
413
+ export class FullProcessorServiceV3Impl implements ProcessorV3ServiceImplementation {
414
+ patcher: RuntimeServicePatcher = new RuntimeServicePatcher()
415
+
416
+ constructor(readonly instance: ProcessorV3ServiceImplementation) {}
417
+
418
+ async init(request: Empty, context: CallContext): Promise<DeepPartial<InitResponse>> {
419
+ const resp = await this.instance.init(request, context)
420
+ resp.executionConfig = ExecutionConfig.fromPartial(GLOBAL_CONFIG.execution)
421
+ return resp
422
+ }
423
+
424
+ async configureHandlers(
425
+ request: ConfigureHandlersRequest,
426
+ context: CallContext
427
+ ): Promise<DeepPartial<ConfigureHandlersResponse>> {
428
+ const config = await this.instance.configureHandlers(request, context)
429
+ this.patcher.patchConfig(config)
430
+ return config
431
+ }
432
+
433
+ async *processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext) {
434
+ yield* this.instance.processBindingsStream(this.adjustBindingsStream(requests), context)
435
+ }
436
+
437
+ async *adjustBindingsStream(requests: AsyncIterable<ProcessStreamRequest>): AsyncIterable<ProcessStreamRequest> {
438
+ for await (const request of requests) {
439
+ this.patcher.adjustDataBinding(request.binding)
440
+ yield request
441
+ }
442
+ }
443
+ }