@sentio/runtime 2.0.0-rc.20 → 2.0.0-rc.22
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/full-service.js +4 -4
- package/lib/full-service.js.map +1 -1
- package/lib/processor-runner.js +1 -0
- package/lib/processor-runner.js.map +1 -1
- package/lib/service.js +21 -15
- package/lib/service.js.map +1 -1
- package/package.json +10 -9
- package/src/full-service.ts +4 -4
- package/src/processor-runner.ts +1 -0
- package/src/service.ts +20 -14
package/lib/full-service.js
CHANGED
@@ -25,19 +25,19 @@ export class FullProcessorServiceImpl {
|
|
25
25
|
instance;
|
26
26
|
sdkMinorVersion;
|
27
27
|
async getConfig(request, context) {
|
28
|
-
return this.instance.getConfig(request, context);
|
28
|
+
return await this.instance.getConfig(request, context);
|
29
29
|
}
|
30
30
|
async start(request, context) {
|
31
|
-
return this.instance.start(request, context);
|
31
|
+
return await this.instance.start(request, context);
|
32
32
|
}
|
33
33
|
async stop(request, context) {
|
34
|
-
return this.instance.stop(request, context);
|
34
|
+
return await this.instance.stop(request, context);
|
35
35
|
}
|
36
36
|
async processBindings(request, options) {
|
37
37
|
for (const binding of request.bindings) {
|
38
38
|
this.adjustDataBinding(binding);
|
39
39
|
}
|
40
|
-
return this.instance.processBindings(request, options);
|
40
|
+
return await this.instance.processBindings(request, options);
|
41
41
|
}
|
42
42
|
async *processBindingsStream(requests, context) {
|
43
43
|
throw new Error('Not Implemented for streaming');
|
package/lib/full-service.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"full-service.js","sourceRoot":"","sources":["../src/full-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C,sCAAsC;AACtC,OAAO,EAEL,WAAW,GAKZ,MAAM,qCAAqC,CAAA;AAG5C,O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ACnD,IAAI;iBACL;gBACD,MAAK;YACP,KAAK,WAAW,CAAC,OAAO;gBACtB,IAAI,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE;oBAC9B,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;wBACrC,gGAAgG;wBAChG,sBAAsB;wBACtB,WAAW,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;qBACjG;iBACF;gBACD,MAAK;YACP;gBACE,MAAK;SACR;IACH,CAAC;CACF","sourcesContent":["import { CallContext } from 'nice-grpc'\nimport { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\n\n// Different than the simple one which\nimport {\n DataBinding,\n HandlerType,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessorServiceImplementation,\n StartRequest,\n} from './gen/processor/protos/processor.js'\n\nimport { Empty } from '@sentio/protos'\nimport fs from 'fs-extra'\nimport * as assert from 'assert'\nimport path from 'path'\n\nfunction locatePackageJson(pkgId: string) {\n const m = require.resolve(pkgId)\n\n let dir = path.dirname(m)\n while (!fs.existsSync(path.join(dir, 'package.json'))) {\n dir = path.dirname(dir)\n }\n const content = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n return JSON.parse(content)\n}\n\nexport class FullProcessorServiceImpl implements ProcessorServiceImplementation {\n constructor(instance: ProcessorServiceImplementation) {\n this.instance = instance\n const sdkPackageJson = locatePackageJson('@sentio/sdk')\n const runtimePackageJson = locatePackageJson('@sentio/runtime')\n\n console.log('Runtime version:', runtimePackageJson.version, 'SDK version:', sdkPackageJson.version)\n\n const version = sdkPackageJson.version.split('.')\n this.sdkMinorVersion = parseInt(version[1])\n }\n\n instance: ProcessorServiceImplementation\n sdkMinorVersion: number\n\n async getConfig(request: ProcessConfigRequest, context: CallContext) {\n return await this.instance.getConfig(request, context)\n }\n\n async start(request: StartRequest, context: CallContext) {\n return await this.instance.start(request, context)\n }\n\n async stop(request: Empty, context: CallContext) {\n return await this.instance.stop(request, context)\n }\n\n async processBindings(request: ProcessBindingsRequest, options: CallContext) {\n for (const binding of request.bindings) {\n this.adjustDataBinding(binding)\n }\n return await this.instance.processBindings(request, options)\n }\n\n async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {\n throw new Error('Not Implemented for streaming')\n // y this.instance.processBindingsStream(requests, context)\n }\n\n protected adjustDataBinding(dataBinding: DataBinding): void {\n switch (dataBinding.handlerType) {\n case HandlerType.APT_EVENT:\n if (dataBinding.data?.aptEvent) {\n // const aptEvent = dataBinding.data.aptEvent\n // if (aptEvent.event && this.sdkMinorVersion < 40) {\n // assert.ok(aptEvent.transaction, 'No Transaction')\n // aptEvent.transaction.events = [aptEvent.event]\n // }\n }\n break\n case HandlerType.UNKNOWN:\n if (dataBinding.data?.ethBlock) {\n if (dataBinding.data.raw.length === 0) {\n // This is actually not needed in current system, just as initla test propose, move to test only\n // when this is stable\n dataBinding.data.raw = new TextEncoder().encode(JSON.stringify(dataBinding.data.ethBlock.block))\n }\n }\n break\n default:\n break\n }\n }\n}\n"]}
|
package/lib/processor-runner.js
CHANGED
@@ -82,6 +82,7 @@ const baseService = new ProcessorServiceImpl(async () => {
|
|
82
82
|
}, server.shutdown);
|
83
83
|
const service = new FullProcessorServiceImpl(baseService);
|
84
84
|
server.add(ProcessorDefinition, service);
|
85
|
+
console.log('Listen on', options.port);
|
85
86
|
server.listen('0.0.0.0:' + options.port);
|
86
87
|
console.log('Processor Server Started');
|
87
88
|
//# sourceMappingURL=processor-runner.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,KAAK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E,OAAO,CAAC,CAAA;CACxC;AAED,MAAM,MAAM,GAAG,YAAY,CAAC;IAC1B,8BAA8B,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IACjD,iCAAiC,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IACpD,oCAAoC,EAAE,qBAAqB,CAAC,IAAI;CACjE,CAAC,CAAA;AAEF,yCAAyC;AACzC,iBAAiB;AAEjB,MAAM,WAAW,GAAG,IAAI,oBAAoB,CAAC,KAAK,IAAI,EAAE;IACtD,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACtC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IAC5B,OAAO,CAAC,CAAA;AACV,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AACnB,MAAM,OAAO,GAAG,IAAI,wBAAwB,CAAC,WAAW,CAAC,CAAA;AAEzD,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAExC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport * as util from 'util'\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { createLogger, transports, format } from 'winston'\nimport { compressionAlgorithms } from '@grpc/grpc-js'\n\nimport { ProcessorDefinition } from '@sentio/protos'\nimport { ProcessorServiceImpl } from './service.js'\nimport { State } from './state.js'\nimport { Endpoints } from './endpoints.js'\n\nimport { FullProcessorServiceImpl } from './full-service.js'\nimport { ChainConfig } from './chain-config.js'\n\nState.reset()\n// Endpoints.reset()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n // { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n { name: 'chainquery-server', type: String, defaultValue: '' },\n { name: 'pricefeed-server', type: String, defaultValue: '' },\n { name: 'log-format', type: String, defaultValue: 'console' },\n { name: 'debug', type: Boolean, defaultValue: false },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nif (options['log-format'] === 'json') {\n const utilFormatter = {\n transform: (info: any) => {\n const args = info[Symbol.for('splat')]\n if (args) {\n info.message = util.format(info.message, ...args)\n }\n return info\n },\n }\n const logger = createLogger({\n format: format.combine(\n format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ss.SSSZ' }),\n utilFormatter,\n format.errors({ stack: true }),\n format.json()\n ),\n transports: [new transports.Console()],\n })\n\n console.log = (...args) => logger.info.call(logger, ...args)\n console.info = (...args) => logger.info.call(logger, ...args)\n console.warn = (...args) => logger.warn.call(logger, ...args)\n console.error = (...args) => logger.error.call(logger, ...args)\n console.debug = (...args) => logger.debug.call(logger, ...args)\n}\nif (options.debug) {\n console.log('Starting with', options.target)\n}\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\n// setProvider(chainsConfig, options.concurrency, options['use-chainserver'])\nEndpoints.INSTANCE.concurrency = options.concurrency\nEndpoints.INSTANCE.chainQueryAPI = options['chainquery-server']\nEndpoints.INSTANCE.priceFeedAPI = options['pricefeed-server']\n\nfor (const [id, config] of Object.entries(chainsConfig)) {\n const chainConfig = config as ChainConfig\n if (chainConfig.ChainServer) {\n Endpoints.INSTANCE.chainServer.set(id, chainConfig.ChainServer)\n }\n}\n\nif (options.debug) {\n console.log('Starting Server', options)\n}\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': compressionAlgorithms.gzip,\n})\n\n// const m = await import(options.target)\n// console.log(m)\n\nconst baseService = new ProcessorServiceImpl(async () => {\n const m = await import(options.target)\n console.log('module loaded')\n return m\n}, server.shutdown)\nconst service = new FullProcessorServiceImpl(baseService)\n\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n\nconsole.log('Processor Server Started')\n"]}
|
1
|
+
{"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAG5D,KAAK,CAAC,KAAK,EAAE,CAAA;AACb,oBAAoB;AAEpB,MAAM,iBAAiB,GAAG;IACxB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE;IACrD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IAChE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE;IACtD,mEAAmE;I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'\nimport fs from 'fs-extra'\nimport * as util from 'util'\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { createLogger, transports, format } from 'winston'\nimport { compressionAlgorithms } from '@grpc/grpc-js'\n\nimport { ProcessorDefinition } from '@sentio/protos'\nimport { ProcessorServiceImpl } from './service.js'\nimport { State } from './state.js'\nimport { Endpoints } from './endpoints.js'\n\nimport { FullProcessorServiceImpl } from './full-service.js'\nimport { ChainConfig } from './chain-config.js'\n\nState.reset()\n// Endpoints.reset()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n // { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n { name: 'chainquery-server', type: String, defaultValue: '' },\n { name: 'pricefeed-server', type: String, defaultValue: '' },\n { name: 'log-format', type: String, defaultValue: 'console' },\n { name: 'debug', type: Boolean, defaultValue: false },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nif (options['log-format'] === 'json') {\n const utilFormatter = {\n transform: (info: any) => {\n const args = info[Symbol.for('splat')]\n if (args) {\n info.message = util.format(info.message, ...args)\n }\n return info\n },\n }\n const logger = createLogger({\n format: format.combine(\n format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ss.SSSZ' }),\n utilFormatter,\n format.errors({ stack: true }),\n format.json()\n ),\n transports: [new transports.Console()],\n })\n\n console.log = (...args) => logger.info.call(logger, ...args)\n console.info = (...args) => logger.info.call(logger, ...args)\n console.warn = (...args) => logger.warn.call(logger, ...args)\n console.error = (...args) => logger.error.call(logger, ...args)\n console.debug = (...args) => logger.debug.call(logger, ...args)\n}\nif (options.debug) {\n console.log('Starting with', options.target)\n}\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\n// setProvider(chainsConfig, options.concurrency, options['use-chainserver'])\nEndpoints.INSTANCE.concurrency = options.concurrency\nEndpoints.INSTANCE.chainQueryAPI = options['chainquery-server']\nEndpoints.INSTANCE.priceFeedAPI = options['pricefeed-server']\n\nfor (const [id, config] of Object.entries(chainsConfig)) {\n const chainConfig = config as ChainConfig\n if (chainConfig.ChainServer) {\n Endpoints.INSTANCE.chainServer.set(id, chainConfig.ChainServer)\n }\n}\n\nif (options.debug) {\n console.log('Starting Server', options)\n}\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': compressionAlgorithms.gzip,\n})\n\n// const m = await import(options.target)\n// console.log(m)\n\nconst baseService = new ProcessorServiceImpl(async () => {\n const m = await import(options.target)\n console.log('module loaded')\n return m\n}, server.shutdown)\nconst service = new FullProcessorServiceImpl(baseService)\n\nserver.add(ProcessorDefinition, service)\n\nconsole.log('Listen on', options.port)\nserver.listen('0.0.0.0:' + options.port)\n\nconsole.log('Processor Server Started')\n"]}
|
package/lib/service.js
CHANGED
@@ -32,20 +32,19 @@ export class ProcessorServiceImpl {
|
|
32
32
|
return {};
|
33
33
|
}
|
34
34
|
try {
|
35
|
-
for (const plugin of ['@sentio/sdk']) {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
for (const plugin of ['@sentio/sdk/aptos', '@sentio/sdk/solana']) {
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
35
|
+
// for (const plugin of ['@sentio/sdk', '@sentio/sdk/eth']) {
|
36
|
+
// try {
|
37
|
+
// await import(plugin)
|
38
|
+
// } catch (e) {
|
39
|
+
// console.error('Failed to load plugin: ', plugin)
|
40
|
+
// }
|
41
|
+
// }
|
42
|
+
//
|
43
|
+
// for (const plugin of ['@sentio/sdk/aptos', '@sentio/sdk/solana']) {
|
44
|
+
// try {
|
45
|
+
// await import(plugin)
|
46
|
+
// } catch (e) {}
|
47
|
+
// }
|
49
48
|
await this.loader();
|
50
49
|
}
|
51
50
|
catch (e) {
|
@@ -73,7 +72,14 @@ export class ProcessorServiceImpl {
|
|
73
72
|
throw new ServerError(Status.UNAVAILABLE, 'Service Not started.');
|
74
73
|
}
|
75
74
|
const promises = request.bindings.map((binding) => this.processBinding(binding));
|
76
|
-
|
75
|
+
let promise;
|
76
|
+
try {
|
77
|
+
promise = await Promise.all(promises);
|
78
|
+
}
|
79
|
+
catch (e) {
|
80
|
+
throw e;
|
81
|
+
}
|
82
|
+
const result = mergeProcessResults(promise);
|
77
83
|
let updated = false;
|
78
84
|
if (PluginManager.INSTANCE.stateDiff(this.processorConfig)) {
|
79
85
|
await this.configure();
|
package/lib/service.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE5D,OAAO,EAML,qBAAqB,GAKtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAC5D;AAAC,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,OAAO,oBAAoB;IACvB,OAAO,GAAG,KAAK,CAAA;IACf,eAAe,CAAuB;IAE7B,MAAM,CAAoB;IAE1B,eAAe,CAAa;IAE7C,YAAY,MAA0B,EAAE,eAA4B;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAA6B,EAAE,OAAoB;QACjE,IAAI,CAAC,IAAI,CAAC,O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QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;QACnE,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;QAC9C,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK,CAAC,CAAC,qBAAqB,CAAC,QAAoC,EAAE,OAAoB;QACrF,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,QAAQ,EAAE;YACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YACjD,IAAI,OAAO,GAAG,KAAK,CAAA;YACnB,IAAI,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;gBAC1D,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;gBACtB,OAAO,GAAG,IAAI,CAAA;aACf;YACD,MAAM;gBACJ,MAAM;gBACN,aAAa,EAAE,OAAO;aACvB,CAAA;SACF;IACH,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACpG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACjB,CAAC,CAAC,WAAW,GAAG;gBACd,IAAI,EAAE,WAAW;aAClB,CAAA;QACH,CAAC,CAAC,CAAA;KACH;AACH,CAAC","sourcesContent":["import { CallContext, ServerError, Status } from 'nice-grpc'\n\nimport {\n DataBinding,\n HandlerType,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessorServiceImplementation,\n ProcessResult,\n StartRequest,\n Empty,\n} from '@sentio/protos'\n\nimport { PluginManager } from './plugin.js'\nimport { errorString, mergeProcessResults } from './utils.js'\n;(BigInt.prototype as any).toJSON = function () {\n return this.toString()\n}\n\nexport class ProcessorServiceImpl implements ProcessorServiceImplementation {\n private started = false\n private processorConfig: ProcessConfigResponse\n\n private readonly loader: () => Promise<any>\n\n private readonly shutdownHandler?: () => void\n\n constructor(loader: () => Promise<any>, shutdownHandler?: () => void) {\n this.loader = loader\n this.shutdownHandler = shutdownHandler\n }\n\n async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n if (!this.processorConfig) {\n throw new ServerError(Status.INTERNAL, 'Process config empty.')\n }\n return this.processorConfig\n }\n\n async configure() {\n this.processorConfig = ProcessConfigResponse.fromPartial({})\n await PluginManager.INSTANCE.configure(this.processorConfig)\n }\n\n async start(request: StartRequest, context: CallContext): Promise<Empty> {\n if (this.started) {\n return {}\n }\n\n try {\n // for (const plugin of ['@sentio/sdk', '@sentio/sdk/eth']) {\n // try {\n // await import(plugin)\n // } catch (e) {\n // console.error('Failed to load plugin: ', plugin)\n // }\n // }\n //\n // for (const plugin of ['@sentio/sdk/aptos', '@sentio/sdk/solana']) {\n // try {\n // await import(plugin)\n // } catch (e) {}\n // }\n\n await this.loader()\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n await PluginManager.INSTANCE.start(request)\n\n try {\n await this.configure()\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'Failed to start processor : ' + errorString(e))\n }\n this.started = true\n return {}\n }\n\n async stop(request: Empty, context: CallContext): Promise<Empty> {\n console.log('Server Shutting down in 5 seconds')\n if (this.shutdownHandler) {\n setTimeout(this.shutdownHandler, 5000)\n }\n return {}\n }\n\n async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.bindings.map((binding) => this.processBinding(binding))\n let promise\n try {\n promise = await Promise.all(promises)\n } catch (e) {\n throw e\n }\n const result = mergeProcessResults(promise)\n\n let updated = false\n if (PluginManager.INSTANCE.stateDiff(this.processorConfig)) {\n await this.configure()\n updated = true\n }\n\n return {\n result,\n configUpdated: updated,\n }\n }\n\n async processBinding(request: DataBinding, options?: CallContext): Promise<ProcessResult> {\n const result = await PluginManager.INSTANCE.processBinding(request)\n recordRuntimeInfo(result, request.handlerType)\n return result\n }\n\n async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {\n for await (const request of requests) {\n const result = await this.processBinding(request)\n let updated = false\n if (PluginManager.INSTANCE.stateDiff(this.processorConfig)) {\n await this.configure()\n updated = true\n }\n yield {\n result,\n configUpdated: updated,\n }\n }\n }\n}\n\nfunction recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {\n for (const list of [results.gauges, results.counters, results.logs, results.events, results.exports]) {\n list.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/runtime",
|
3
3
|
"license": "Apache-2.0",
|
4
|
-
"version": "2.0.0-rc.
|
4
|
+
"version": "2.0.0-rc.22",
|
5
5
|
"scripts": {
|
6
6
|
"compile": "tsc",
|
7
7
|
"build": "yarn compile",
|
@@ -10,17 +10,16 @@
|
|
10
10
|
"run": "ts-node-esm --files src/processor-runner.ts --log-format=json",
|
11
11
|
"run-benchmark": "ts-node-esm --files src/decode-benchmark.ts",
|
12
12
|
"start_ts": "ts-node-esm --files ./src/processor-runner.ts --log-format=json ../../../examples/x2y2/src/processor.ts",
|
13
|
-
"start_js": "ts-node-esm --files ./src/processor-runner.ts
|
13
|
+
"start_js": "ts-node-esm --files ./src/processor-runner.ts /Users/fuyaoz/src/goldfinch/dist/lib.js"
|
14
14
|
},
|
15
15
|
"dependencies": {
|
16
|
-
"@sentio/protos": "^2.0.0-rc.
|
16
|
+
"@sentio/protos": "^2.0.0-rc.22",
|
17
17
|
"command-line-args": "^5.2.1",
|
18
18
|
"command-line-usage": "^6.1.3",
|
19
19
|
"fs-extra": "^11.0.0",
|
20
20
|
"google-protobuf": "^3.15.8",
|
21
|
-
"nice-grpc": "^2.
|
22
|
-
"nice-grpc-client-middleware-retry": "^2.0.
|
23
|
-
"nice-grpc-error-details": "^0.1.4",
|
21
|
+
"nice-grpc": "^2.1.0",
|
22
|
+
"nice-grpc-client-middleware-retry": "^2.0.2",
|
24
23
|
"winston": "^3.8.2"
|
25
24
|
},
|
26
25
|
"devDependencies": {
|
@@ -29,8 +28,7 @@
|
|
29
28
|
"@types/command-line-usage": "^5.0.2",
|
30
29
|
"@types/expect": "^24.3.0",
|
31
30
|
"@types/fs-extra": "^11.0.1",
|
32
|
-
"@types/google-protobuf": "^3.15.6"
|
33
|
-
"@types/node": "^18.0.4"
|
31
|
+
"@types/google-protobuf": "^3.15.6"
|
34
32
|
},
|
35
33
|
"bin": {
|
36
34
|
"processor-runner": "./lib/processor-runner.js"
|
@@ -39,10 +37,13 @@
|
|
39
37
|
"exports": {
|
40
38
|
".": "./lib/index.js"
|
41
39
|
},
|
40
|
+
"resolutions": {
|
41
|
+
"@grpc/grpc-js": "^1.8.7"
|
42
|
+
},
|
42
43
|
"files": [
|
43
44
|
"{lib,src}",
|
44
45
|
"!{lib,src}/tests",
|
45
46
|
"!**/*.test.{js,ts}"
|
46
47
|
],
|
47
|
-
"gitHead": "
|
48
|
+
"gitHead": "6e28f01925cdb5c1142a342d57144221d36967fd"
|
48
49
|
}
|
package/src/full-service.ts
CHANGED
@@ -44,22 +44,22 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
44
44
|
sdkMinorVersion: number
|
45
45
|
|
46
46
|
async getConfig(request: ProcessConfigRequest, context: CallContext) {
|
47
|
-
return this.instance.getConfig(request, context)
|
47
|
+
return await this.instance.getConfig(request, context)
|
48
48
|
}
|
49
49
|
|
50
50
|
async start(request: StartRequest, context: CallContext) {
|
51
|
-
return this.instance.start(request, context)
|
51
|
+
return await this.instance.start(request, context)
|
52
52
|
}
|
53
53
|
|
54
54
|
async stop(request: Empty, context: CallContext) {
|
55
|
-
return this.instance.stop(request, context)
|
55
|
+
return await this.instance.stop(request, context)
|
56
56
|
}
|
57
57
|
|
58
58
|
async processBindings(request: ProcessBindingsRequest, options: CallContext) {
|
59
59
|
for (const binding of request.bindings) {
|
60
60
|
this.adjustDataBinding(binding)
|
61
61
|
}
|
62
|
-
return this.instance.processBindings(request, options)
|
62
|
+
return await this.instance.processBindings(request, options)
|
63
63
|
}
|
64
64
|
|
65
65
|
async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {
|
package/src/processor-runner.ts
CHANGED
package/src/service.ts
CHANGED
@@ -53,19 +53,19 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
53
53
|
}
|
54
54
|
|
55
55
|
try {
|
56
|
-
for (const plugin of ['@sentio/sdk']) {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
}
|
63
|
-
|
64
|
-
for (const plugin of ['@sentio/sdk/aptos', '@sentio/sdk/solana']) {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}
|
56
|
+
// for (const plugin of ['@sentio/sdk', '@sentio/sdk/eth']) {
|
57
|
+
// try {
|
58
|
+
// await import(plugin)
|
59
|
+
// } catch (e) {
|
60
|
+
// console.error('Failed to load plugin: ', plugin)
|
61
|
+
// }
|
62
|
+
// }
|
63
|
+
//
|
64
|
+
// for (const plugin of ['@sentio/sdk/aptos', '@sentio/sdk/solana']) {
|
65
|
+
// try {
|
66
|
+
// await import(plugin)
|
67
|
+
// } catch (e) {}
|
68
|
+
// }
|
69
69
|
|
70
70
|
await this.loader()
|
71
71
|
} catch (e) {
|
@@ -97,7 +97,13 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
97
97
|
}
|
98
98
|
|
99
99
|
const promises = request.bindings.map((binding) => this.processBinding(binding))
|
100
|
-
|
100
|
+
let promise
|
101
|
+
try {
|
102
|
+
promise = await Promise.all(promises)
|
103
|
+
} catch (e) {
|
104
|
+
throw e
|
105
|
+
}
|
106
|
+
const result = mergeProcessResults(promise)
|
101
107
|
|
102
108
|
let updated = false
|
103
109
|
if (PluginManager.INSTANCE.stateDiff(this.processorConfig)) {
|