@sentio/runtime 2.59.0-rc.22 → 2.59.0-rc.23
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-EPAMG3V5.js → chunk-3G5TU64H.js} +39 -19
- package/lib/{chunk-EPAMG3V5.js.map → chunk-3G5TU64H.js.map} +1 -1
- package/lib/{chunk-45FF2A6M.js → chunk-HMNYJB5K.js} +294 -5
- package/lib/chunk-HMNYJB5K.js.map +1 -0
- package/lib/{chunk-GWKJGG55.js → chunk-ZYJXCGEJ.js} +2 -2
- package/lib/index.d.ts +13 -1
- package/lib/index.js +2 -2
- package/lib/processor-runner.js +63 -44
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.js +3 -3
- package/package.json +1 -1
- package/src/gen/processor/protos/processor.ts +338 -2
- package/src/plugin.ts +24 -0
- package/src/service-manager.ts +52 -32
- package/src/service.ts +51 -22
- package/lib/chunk-45FF2A6M.js.map +0 -1
- /package/lib/{chunk-GWKJGG55.js.map → chunk-ZYJXCGEJ.js.map} +0 -0
package/src/service.ts
CHANGED
@@ -56,6 +56,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
56
56
|
private readonly enablePreprocess: boolean
|
57
57
|
|
58
58
|
private preparedData: PreparedData | undefined
|
59
|
+
readonly enablePartition: boolean
|
59
60
|
|
60
61
|
constructor(loader: () => Promise<any>, shutdownHandler?: () => void) {
|
61
62
|
this.loader = loader
|
@@ -64,6 +65,8 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
64
65
|
this.enablePreprocess = process.env['ENABLE_PREPROCESS']
|
65
66
|
? process.env['ENABLE_PREPROCESS'].toLowerCase() == 'true'
|
66
67
|
: false
|
68
|
+
|
69
|
+
this.enablePartition = process.env['SENTIO_ENABLE_BINDING_DATA_PARTITION'] == 'true'
|
67
70
|
}
|
68
71
|
|
69
72
|
async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {
|
@@ -418,6 +421,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
418
421
|
subject: Subject<DeepPartial<ProcessStreamResponse>>
|
419
422
|
) {
|
420
423
|
const contexts = new Contexts()
|
424
|
+
let lastBinding: DataBinding | undefined = undefined
|
421
425
|
for await (const request of requests) {
|
422
426
|
try {
|
423
427
|
// console.debug('received request:', request)
|
@@ -433,31 +437,26 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
433
437
|
})
|
434
438
|
continue
|
435
439
|
}
|
440
|
+
lastBinding = request.binding
|
436
441
|
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
// await all pending db requests
|
443
|
-
await dbContext.awaitPendings()
|
444
|
-
subject.next({
|
445
|
-
result,
|
446
|
-
processId: request.processId
|
447
|
-
})
|
448
|
-
recordRuntimeInfo(result, binding.handlerType)
|
449
|
-
})
|
450
|
-
.catch((e) => {
|
451
|
-
console.debug(e)
|
452
|
-
dbContext.error(request.processId, e)
|
453
|
-
process_binding_error.add(1)
|
454
|
-
})
|
455
|
-
.finally(() => {
|
456
|
-
const cost = Date.now() - start
|
457
|
-
process_binding_time.add(cost)
|
458
|
-
contexts.delete(request.processId)
|
442
|
+
if (this.enablePartition) {
|
443
|
+
const partitions = await PluginManager.INSTANCE.partition(request.binding)
|
444
|
+
subject.next({
|
445
|
+
processId: request.processId,
|
446
|
+
partitions
|
459
447
|
})
|
448
|
+
} else {
|
449
|
+
this.startProcess(request.processId, request.binding, contexts, subject)
|
450
|
+
}
|
451
|
+
}
|
452
|
+
|
453
|
+
if (request.start) {
|
454
|
+
if (!lastBinding) {
|
455
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'start request received without binding')
|
456
|
+
}
|
457
|
+
this.startProcess(request.processId, lastBinding, contexts, subject)
|
460
458
|
}
|
459
|
+
|
461
460
|
if (request.dbResult) {
|
462
461
|
const dbContext = contexts.get(request.processId)
|
463
462
|
try {
|
@@ -472,6 +471,36 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
472
471
|
}
|
473
472
|
}
|
474
473
|
}
|
474
|
+
|
475
|
+
private startProcess(
|
476
|
+
processId: number,
|
477
|
+
binding: DataBinding,
|
478
|
+
contexts: Contexts,
|
479
|
+
subject: Subject<DeepPartial<ProcessStreamResponse>>
|
480
|
+
) {
|
481
|
+
const dbContext = contexts.new(processId, subject)
|
482
|
+
const start = Date.now()
|
483
|
+
PluginManager.INSTANCE.processBinding(binding, this.preparedData, dbContext)
|
484
|
+
.then(async (result) => {
|
485
|
+
// await all pending db requests
|
486
|
+
await dbContext.awaitPendings()
|
487
|
+
subject.next({
|
488
|
+
result,
|
489
|
+
processId: processId
|
490
|
+
})
|
491
|
+
recordRuntimeInfo(result, binding.handlerType)
|
492
|
+
})
|
493
|
+
.catch((e) => {
|
494
|
+
console.debug(e)
|
495
|
+
dbContext.error(processId, e)
|
496
|
+
process_binding_error.add(1)
|
497
|
+
})
|
498
|
+
.finally(() => {
|
499
|
+
const cost = Date.now() - start
|
500
|
+
process_binding_time.add(cost)
|
501
|
+
contexts.delete(processId)
|
502
|
+
})
|
503
|
+
}
|
475
504
|
}
|
476
505
|
|
477
506
|
export function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {
|