@sentio/runtime 4.0.0-rc.2 → 4.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chunk-OLNJTVP4.js +15167 -0
- package/lib/chunk-OLNJTVP4.js.map +1 -0
- package/lib/{chunk-MSVN53DI.js → chunk-VVWSRCNO.js} +1 -5
- package/lib/{chunk-MSVN53DI.js.map → chunk-VVWSRCNO.js.map} +1 -1
- package/lib/index.d.ts +62 -408
- package/lib/index.js +21290 -40
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.js +25 -235
- package/lib/processor-runner.js.map +1 -1
- package/package.json +1 -1
- package/src/full-service.ts +0 -35
- package/src/index.ts +1 -1
- package/src/processor-runner.ts +2 -16
- package/src/service-v3.ts +3 -3
- package/src/utils.ts +21 -1
- package/lib/chunk-63SN5KU2.js +0 -38205
- package/lib/chunk-63SN5KU2.js.map +0 -1
- package/src/service.ts +0 -556
package/package.json
CHANGED
package/src/full-service.ts
CHANGED
|
@@ -1,51 +1,16 @@
|
|
|
1
1
|
import { create } from '@bufbuild/protobuf'
|
|
2
2
|
import { type HandlerContext, type ServiceImpl } from '@connectrpc/connect'
|
|
3
3
|
import {
|
|
4
|
-
type Empty,
|
|
5
4
|
ExecutionConfigSchema,
|
|
6
|
-
type PreprocessStreamRequest,
|
|
7
|
-
type ProcessBindingsRequest,
|
|
8
5
|
type ProcessConfigRequest,
|
|
9
|
-
Processor,
|
|
10
6
|
ProcessorV3,
|
|
11
7
|
type ProcessStreamRequest,
|
|
12
8
|
type StartRequest,
|
|
13
9
|
type UpdateTemplatesRequest
|
|
14
10
|
} from '@sentio/protos'
|
|
15
|
-
import { ProcessorServiceImpl } from './service.js'
|
|
16
11
|
import { ProcessorServiceImplV3 } from './service-v3.js'
|
|
17
12
|
import { GLOBAL_CONFIG } from './global-config.js'
|
|
18
13
|
|
|
19
|
-
export class FullProcessorServiceImpl implements ServiceImpl<typeof Processor> {
|
|
20
|
-
constructor(readonly instance: ProcessorServiceImpl) {}
|
|
21
|
-
|
|
22
|
-
async getConfig(request: ProcessConfigRequest, context: HandlerContext) {
|
|
23
|
-
const config = await this.instance.getConfig(request, context)
|
|
24
|
-
config.executionConfig = create(ExecutionConfigSchema, GLOBAL_CONFIG.execution)
|
|
25
|
-
return config
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async start(request: StartRequest, context: HandlerContext) {
|
|
29
|
-
return await this.instance.start(request, context)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async stop(request: Empty, context: HandlerContext) {
|
|
33
|
-
return await this.instance.stop(request, context)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async processBindings(request: ProcessBindingsRequest, context: HandlerContext) {
|
|
37
|
-
return await this.instance.processBindings(request, context)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async *processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: HandlerContext) {
|
|
41
|
-
yield* this.instance.processBindingsStream(requests, context)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async *preprocessBindingsStream(requests: AsyncIterable<PreprocessStreamRequest>, context: HandlerContext) {
|
|
45
|
-
yield* this.instance.preprocessBindingsStream(requests, context)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
14
|
export class FullProcessorServiceV3Impl implements ServiceImpl<typeof ProcessorV3> {
|
|
50
15
|
constructor(readonly instance: ProcessorServiceImplV3) {}
|
|
51
16
|
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './state.js'
|
|
|
3
3
|
export * from './utils.js'
|
|
4
4
|
export * from './endpoints.js'
|
|
5
5
|
export * from './chain-config.js'
|
|
6
|
-
export * from './service.js'
|
|
6
|
+
export * from './service-v3.js'
|
|
7
7
|
export { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'
|
|
8
8
|
export * from './db-context.js'
|
|
9
9
|
export * from './provider.js'
|
package/src/processor-runner.ts
CHANGED
|
@@ -10,14 +10,13 @@ import { Session } from 'node:inspector/promises'
|
|
|
10
10
|
import { fork, ChildProcess } from 'child_process'
|
|
11
11
|
import { fileURLToPath } from 'url'
|
|
12
12
|
|
|
13
|
-
import { ProcessorServiceImpl } from './service.js'
|
|
14
13
|
import { configureEndpoints } from './endpoints.js'
|
|
15
|
-
import {
|
|
14
|
+
import { FullProcessorServiceV3Impl } from './full-service.js'
|
|
16
15
|
import { setupLogger } from './logger.js'
|
|
17
16
|
|
|
18
17
|
import { setupOTLP } from './otlp.js'
|
|
19
18
|
import { ActionServer } from './action-server.js'
|
|
20
|
-
import {
|
|
19
|
+
import { ProcessorV3 } from '@sentio/protos'
|
|
21
20
|
import { ProcessorServiceImplV3 } from './service-v3.js'
|
|
22
21
|
import { dirname, join } from 'path'
|
|
23
22
|
import { program, ProcessorRuntimeOptions } from './processor-runner-program.js'
|
|
@@ -67,7 +66,6 @@ if (!isChildProcess) {
|
|
|
67
66
|
|
|
68
67
|
let server: any
|
|
69
68
|
let processorHttp2Server: http2.Http2Server | undefined
|
|
70
|
-
let baseService: ProcessorServiceImpl
|
|
71
69
|
let httpServer: http.Server | undefined
|
|
72
70
|
|
|
73
71
|
const loader = async () => {
|
|
@@ -82,15 +80,9 @@ if (options.startActionServer) {
|
|
|
82
80
|
} else {
|
|
83
81
|
const shutdown = () => processorHttp2Server?.close()
|
|
84
82
|
|
|
85
|
-
// for V2
|
|
86
|
-
baseService = new ProcessorServiceImpl(loader, options, shutdown)
|
|
87
|
-
const serviceV2 = new FullProcessorServiceImpl(baseService)
|
|
88
|
-
|
|
89
|
-
// for V3
|
|
90
83
|
const serviceV3 = new FullProcessorServiceV3Impl(new ProcessorServiceImplV3(loader, options, shutdown))
|
|
91
84
|
|
|
92
85
|
const routes = (router: ConnectRouter) => {
|
|
93
|
-
router.service(Processor, serviceV2)
|
|
94
86
|
router.service(ProcessorV3, serviceV3)
|
|
95
87
|
}
|
|
96
88
|
|
|
@@ -208,9 +200,6 @@ process
|
|
|
208
200
|
})
|
|
209
201
|
.on('uncaughtException', (err) => {
|
|
210
202
|
console.error('Uncaught Exception, please checking if await is properly used', err)
|
|
211
|
-
if (baseService) {
|
|
212
|
-
baseService.unhandled = err
|
|
213
|
-
}
|
|
214
203
|
// shutdownServers(1)
|
|
215
204
|
})
|
|
216
205
|
.on('unhandledRejection', (reason, _p) => {
|
|
@@ -219,9 +208,6 @@ process
|
|
|
219
208
|
return
|
|
220
209
|
}
|
|
221
210
|
console.error('Unhandled Rejection, please checking if await is properly', reason)
|
|
222
|
-
if (baseService) {
|
|
223
|
-
baseService.unhandled = reason as Error
|
|
224
|
-
}
|
|
225
211
|
// shutdownServers(1)
|
|
226
212
|
})
|
|
227
213
|
|
package/src/service-v3.ts
CHANGED
|
@@ -17,10 +17,9 @@ import { PluginManager } from './plugin.js'
|
|
|
17
17
|
import { Subject } from 'rxjs'
|
|
18
18
|
import { from } from 'ix/asynciterable'
|
|
19
19
|
import { withAbort } from 'ix/asynciterable/operators'
|
|
20
|
-
import { errorString } from './utils.js'
|
|
20
|
+
import { errorString, recordRuntimeInfo } from './utils.js'
|
|
21
21
|
|
|
22
22
|
import { processMetrics } from './metrics.js'
|
|
23
|
-
import { recordRuntimeInfo } from './service.js'
|
|
24
23
|
import { DataBindingContext } from './db-context.js'
|
|
25
24
|
import { freezeGlobalConfig } from './global-config.js'
|
|
26
25
|
import { ProcessorRuntimeOptions } from './processor-runner-program.js'
|
|
@@ -168,6 +167,8 @@ export class ProcessorServiceImplV3 implements ServiceImpl<typeof ProcessorV3> {
|
|
|
168
167
|
PluginManager.INSTANCE.processBinding(binding, undefined, context)
|
|
169
168
|
.then(async (result) => {
|
|
170
169
|
await context.awaitPendings()
|
|
170
|
+
recordRuntimeInfo(result, binding.handlerType)
|
|
171
|
+
|
|
171
172
|
const timeseriesResult = result.timeseriesResult
|
|
172
173
|
for (let i = 0; i < timeseriesResult.length; i += TIME_SERIES_RESULT_BATCH_SIZE) {
|
|
173
174
|
const batch = timeseriesResult.slice(i, i + TIME_SERIES_RESULT_BATCH_SIZE)
|
|
@@ -188,7 +189,6 @@ export class ProcessorServiceImplV3 implements ServiceImpl<typeof ProcessorV3> {
|
|
|
188
189
|
value: WRITE_V2_EVENT_LOGS ? otherResults : create(ProcessResultSchema, { states: result.states })
|
|
189
190
|
}
|
|
190
191
|
})
|
|
191
|
-
recordRuntimeInfo(result, binding.handlerType)
|
|
192
192
|
})
|
|
193
193
|
.catch((e) => {
|
|
194
194
|
console.error(e, e.stack)
|
package/src/utils.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type EthCallParam,
|
|
3
|
+
HandlerType,
|
|
4
|
+
type ProcessResult,
|
|
5
|
+
ProcessResultSchema,
|
|
6
|
+
RuntimeInfoSchema,
|
|
7
|
+
StateResultSchema
|
|
8
|
+
} from '@sentio/protos'
|
|
2
9
|
import { create } from '@bufbuild/protobuf'
|
|
3
10
|
import { createRequire } from 'module'
|
|
4
11
|
|
|
5
12
|
import { Required } from 'utility-types'
|
|
6
13
|
import path from 'path'
|
|
7
14
|
import fs from 'fs'
|
|
15
|
+
;(BigInt.prototype as any).toJSON = function () {
|
|
16
|
+
return this.toString()
|
|
17
|
+
}
|
|
8
18
|
|
|
9
19
|
export function mergeProcessResults(results: ProcessResult[]): Required<ProcessResult, 'states'> {
|
|
10
20
|
const res = create(ProcessResultSchema, {
|
|
@@ -34,6 +44,16 @@ export function mergeProcessResultsInPlace(
|
|
|
34
44
|
return res as Required<ProcessResult, 'states'>
|
|
35
45
|
}
|
|
36
46
|
|
|
47
|
+
export function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {
|
|
48
|
+
for (const list of [results.gauges, results.counters, results.events, results.exports]) {
|
|
49
|
+
list.forEach((e) => {
|
|
50
|
+
e.runtimeInfo = create(RuntimeInfoSchema, {
|
|
51
|
+
from: handlerType
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
37
57
|
function mergeArrayInPlace<T>(dst: T[], src: T[]): T[] {
|
|
38
58
|
const res = dst || []
|
|
39
59
|
if (Array.isArray(src)) {
|