@sentio/runtime 2.44.3-rc.9 → 2.44.4-rc.1
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-4JZFB6MP.js +131 -0
- package/lib/chunk-4JZFB6MP.js.map +1 -0
- package/lib/index.d.ts +8 -2
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.js +29 -29
- package/lib/processor-runner.js.map +1 -1
- package/package.json +3 -4
- package/src/plugin.ts +13 -3
- package/src/processor-runner.ts +44 -23
- package/lib/chunk-52BOUMA2.js +0 -131
- package/lib/chunk-52BOUMA2.js.map +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/runtime",
|
3
|
-
"version": "2.44.
|
3
|
+
"version": "2.44.4-rc.1",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -19,11 +19,10 @@
|
|
19
19
|
"@types/command-line-args": "^5.2.3",
|
20
20
|
"@types/command-line-usage": "^5.0.4",
|
21
21
|
"@types/fs-extra": "^11.0.4",
|
22
|
-
"@types/google-protobuf": "^3.15.12"
|
23
|
-
"tslib": "^2.6.2"
|
22
|
+
"@types/google-protobuf": "^3.15.12"
|
24
23
|
},
|
25
24
|
"engines": {
|
26
|
-
"node": ">=
|
25
|
+
"node": ">=20"
|
27
26
|
},
|
28
27
|
"scripts": {
|
29
28
|
"build": "pnpm tsc --noEmit && pnpm bundle",
|
package/src/plugin.ts
CHANGED
@@ -15,7 +15,13 @@ export abstract class Plugin {
|
|
15
15
|
supportedHandlers: HandlerType[] = []
|
16
16
|
|
17
17
|
async configure(config: ProcessConfigResponse): Promise<void> {}
|
18
|
-
async start(start: StartRequest): Promise<void> {}
|
18
|
+
async start(start: StartRequest, actionServerPort?: number): Promise<void> {}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* method used by action server only
|
22
|
+
* @param port
|
23
|
+
*/
|
24
|
+
async startServer(port?: number): Promise<void> {}
|
19
25
|
|
20
26
|
/**
|
21
27
|
* @deprecated The method should not be used, use ctx.states instead
|
@@ -59,8 +65,12 @@ export class PluginManager {
|
|
59
65
|
return Promise.all(this.plugins.map((plugin) => plugin.configure(config)))
|
60
66
|
}
|
61
67
|
|
62
|
-
start(start: StartRequest) {
|
63
|
-
return Promise.all(this.plugins.map((plugin) => plugin.start(start)))
|
68
|
+
start(start: StartRequest, actionServerPort?: number) {
|
69
|
+
return Promise.all(this.plugins.map((plugin) => plugin.start(start, actionServerPort)))
|
70
|
+
}
|
71
|
+
|
72
|
+
startServer(port?: number) {
|
73
|
+
return Promise.all(this.plugins.map((plugin) => plugin.startServer(port)))
|
64
74
|
}
|
65
75
|
|
66
76
|
/**
|
package/src/processor-runner.ts
CHANGED
@@ -5,11 +5,10 @@ import fs from 'fs-extra'
|
|
5
5
|
|
6
6
|
import { compressionAlgorithms } from '@grpc/grpc-js'
|
7
7
|
import commandLineArgs from 'command-line-args'
|
8
|
-
import { createServer } from 'nice-grpc'
|
8
|
+
import { createServer, Server } from 'nice-grpc'
|
9
9
|
import { errorDetailsServerMiddleware } from 'nice-grpc-error-details'
|
10
10
|
// import { registry as niceGrpcRegistry } from 'nice-grpc-prometheus'
|
11
11
|
import { openTelemetryServerMiddleware } from 'nice-grpc-opentelemetry'
|
12
|
-
// import { register as globalRegistry, Registry } from 'prom-client'
|
13
12
|
import http from 'http'
|
14
13
|
// @ts-ignore inspector promises is not included in @type/node
|
15
14
|
import { Session } from 'node:inspector/promises'
|
@@ -22,6 +21,8 @@ import { ChainConfig } from './chain-config.js'
|
|
22
21
|
import { setupLogger } from './logger.js'
|
23
22
|
|
24
23
|
import { setupOTLP } from './otlp.js'
|
24
|
+
import { PluginManager } from './plugin.js'
|
25
|
+
import { ProcessConfigResponse } from '@sentio/protos'
|
25
26
|
|
26
27
|
// const mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry])
|
27
28
|
|
@@ -40,7 +41,8 @@ const optionDefinitions = [
|
|
40
41
|
{ name: 'chainquery-server', type: String, defaultValue: '' },
|
41
42
|
{ name: 'pricefeed-server', type: String, defaultValue: '' },
|
42
43
|
{ name: 'log-format', type: String, defaultValue: 'console' },
|
43
|
-
{ name: 'debug', type: Boolean, defaultValue: false }
|
44
|
+
{ name: 'debug', type: Boolean, defaultValue: false },
|
45
|
+
{ name: 'start-action-server', type: Boolean, defaultValue: false }
|
44
46
|
]
|
45
47
|
|
46
48
|
const options = commandLineArgs(optionDefinitions, { partial: true })
|
@@ -85,26 +87,41 @@ for (const [id, config] of Object.entries(chainsConfig)) {
|
|
85
87
|
|
86
88
|
console.debug('Starting Server', options)
|
87
89
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
}
|
101
|
-
|
90
|
+
let server: Server
|
91
|
+
let baseService: ProcessorServiceImpl
|
92
|
+
|
93
|
+
if (options.startActionServer) {
|
94
|
+
const pluginManager = PluginManager.INSTANCE
|
95
|
+
pluginManager
|
96
|
+
.configure(ProcessConfigResponse.create())
|
97
|
+
.then(() => {
|
98
|
+
return pluginManager.startServer(options.port)
|
99
|
+
})
|
100
|
+
.catch((err) => {
|
101
|
+
console.error('Error starting action server', err)
|
102
|
+
})
|
103
|
+
} else {
|
104
|
+
server = createServer({
|
105
|
+
'grpc.max_send_message_length': 384 * 1024 * 1024,
|
106
|
+
'grpc.max_receive_message_length': 384 * 1024 * 1024,
|
107
|
+
'grpc.default_compression_algorithm': compressionAlgorithms.gzip
|
108
|
+
})
|
109
|
+
// .use(prometheusServerMiddleware())
|
110
|
+
.use(openTelemetryServerMiddleware())
|
111
|
+
.use(errorDetailsServerMiddleware)
|
112
|
+
baseService = new ProcessorServiceImpl(async () => {
|
113
|
+
const m = await import(options.target)
|
114
|
+
console.debug('Module loaded', m)
|
115
|
+
return m
|
116
|
+
}, server.shutdown)
|
117
|
+
const service = new FullProcessorServiceImpl(baseService)
|
102
118
|
|
103
|
-
server.add(ProcessorDefinition, service)
|
119
|
+
server.add(ProcessorDefinition, service)
|
104
120
|
|
105
|
-
server.listen('0.0.0.0:' + options.port)
|
121
|
+
server.listen('0.0.0.0:' + options.port)
|
106
122
|
|
107
|
-
console.log('Processor Server Started at:', options.port)
|
123
|
+
console.log('Processor Server Started at:', options.port)
|
124
|
+
}
|
108
125
|
|
109
126
|
const metricsPort = 4040
|
110
127
|
const httpServer = http
|
@@ -155,7 +172,9 @@ process
|
|
155
172
|
})
|
156
173
|
.on('uncaughtException', (err) => {
|
157
174
|
console.error('Uncaught Exception, please checking if await is properly used', err)
|
158
|
-
baseService
|
175
|
+
if (baseService) {
|
176
|
+
baseService.unhandled = err
|
177
|
+
}
|
159
178
|
// shutdownServers(1)
|
160
179
|
})
|
161
180
|
.on('unhandledRejection', (reason, p) => {
|
@@ -164,12 +183,14 @@ process
|
|
164
183
|
return
|
165
184
|
}
|
166
185
|
console.error('Unhandled Rejection, please checking if await is properly', reason)
|
167
|
-
baseService
|
186
|
+
if (baseService) {
|
187
|
+
baseService.unhandled = reason as Error
|
188
|
+
}
|
168
189
|
// shutdownServers(1)
|
169
190
|
})
|
170
191
|
|
171
192
|
function shutdownServers(exitCode: number) {
|
172
|
-
server
|
193
|
+
server?.forceShutdown()
|
173
194
|
console.log('RPC server shut down')
|
174
195
|
|
175
196
|
httpServer.close(function () {
|