@sentio/runtime 2.59.0-rc.31 → 2.59.0-rc.33

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/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  providerMetrics,
29
29
  recordRuntimeInfo,
30
30
  timeoutError
31
- } from "./chunk-X2VTMTYL.js";
31
+ } from "./chunk-QWKQ7U4H.js";
32
32
  import {
33
33
  Plugin,
34
34
  PluginManager
@@ -44,7 +44,7 @@ import {
44
44
  require_lodash,
45
45
  require_src,
46
46
  trace
47
- } from "./chunk-X2VTMTYL.js";
47
+ } from "./chunk-QWKQ7U4H.js";
48
48
  import {
49
49
  ExecutionConfig,
50
50
  HandlerType,
@@ -26328,6 +26328,7 @@ var ServiceManager = class extends ProcessorServiceImpl {
26328
26328
  for await (const request3 of requests) {
26329
26329
  try {
26330
26330
  if (request3.binding) {
26331
+ lastBinding = request3.binding;
26331
26332
  process_binding_count.add(1);
26332
26333
  if (request3.binding.handlerType === HandlerType.UNKNOWN) {
26333
26334
  subject.next({
@@ -26337,13 +26338,7 @@ var ServiceManager = class extends ProcessorServiceImpl {
26337
26338
  continue;
26338
26339
  }
26339
26340
  if (this.enablePartition) {
26340
- PluginManager.INSTANCE.partition(request3.binding).then((partitions) => {
26341
- subject.next({
26342
- processId: request3.processId,
26343
- partitions
26344
- });
26345
- });
26346
- lastBinding = request3.binding;
26341
+ this.doPartition(request3.processId, request3.binding, subject);
26347
26342
  } else {
26348
26343
  this.doProcess(request3.processId, request3.binding, subject);
26349
26344
  }
@@ -26367,10 +26362,33 @@ var ServiceManager = class extends ProcessorServiceImpl {
26367
26362
  }
26368
26363
  }
26369
26364
  }
26365
+ async doPartition(processId, binding, subject) {
26366
+ if (!this.pool) {
26367
+ await this.initPool();
26368
+ }
26369
+ const dbContext = this.contexts.new(processId, subject);
26370
+ const start = Date.now();
26371
+ this.process(binding, processId, dbContext, true).then(async (result) => {
26372
+ console.debug("partition", processId, "finished, took:", Date.now() - start);
26373
+ subject.next({
26374
+ result,
26375
+ processId
26376
+ });
26377
+ }).catch((e) => {
26378
+ dbContext.error(processId, e);
26379
+ process_binding_error.add(1);
26380
+ console.error("partition", processId, "failed, took:", Date.now() - start);
26381
+ }).finally(() => {
26382
+ const cost = Date.now() - start;
26383
+ process_binding_time.add(cost);
26384
+ this.contexts.delete(processId);
26385
+ });
26386
+ }
26370
26387
  doProcess(processId, binding, subject) {
26371
26388
  const dbContext = this.contexts.new(processId, subject);
26372
26389
  const start = Date.now();
26373
- this.process(binding, dbContext).then(async (result) => {
26390
+ this.process(binding, processId, dbContext, false).then(async (result) => {
26391
+ console.debug("process", processId, "finished, took:", Date.now() - start);
26374
26392
  subject.next({
26375
26393
  result,
26376
26394
  processId
@@ -26378,18 +26396,19 @@ var ServiceManager = class extends ProcessorServiceImpl {
26378
26396
  }).catch((e) => {
26379
26397
  dbContext.error(processId, e);
26380
26398
  process_binding_error.add(1);
26399
+ console.error("process", processId, "failed, took:", Date.now() - start);
26381
26400
  }).finally(() => {
26382
26401
  const cost = Date.now() - start;
26383
26402
  process_binding_time.add(cost);
26384
26403
  this.contexts.delete(processId);
26385
26404
  });
26386
26405
  }
26387
- async process(request3, dbContext) {
26406
+ async process(request3, processId, dbContext, partition = false) {
26388
26407
  if (!this.pool) {
26389
26408
  await this.initPool();
26390
26409
  }
26391
26410
  return this.pool.run(
26392
- { request: request3, workerPort: dbContext?.workerPort },
26411
+ { request: request3, workerPort: dbContext?.workerPort, partition, processId },
26393
26412
  { transferList: dbContext?.workerPort ? [dbContext?.workerPort] : [] }
26394
26413
  );
26395
26414
  }
@@ -26418,7 +26437,11 @@ var Contexts = class {
26418
26437
  return this.contexts.get(processId);
26419
26438
  }
26420
26439
  new(processId, subject) {
26421
- const context2 = new ChannelStoreContext(subject, processId);
26440
+ let context2 = this.get(processId);
26441
+ if (context2) {
26442
+ return context2;
26443
+ }
26444
+ context2 = new ChannelStoreContext(subject, processId);
26422
26445
  this.contexts.set(processId, context2);
26423
26446
  return context2;
26424
26447
  }
@@ -26496,7 +26519,9 @@ var optionDefinitions = [
26496
26519
  { name: "debug", type: Boolean, defaultValue: false },
26497
26520
  { name: "otlp-debug", type: Boolean, defaultValue: false },
26498
26521
  { name: "start-action-server", type: Boolean, defaultValue: false },
26499
- { name: "worker", type: Number, defaultValue: workerNum }
26522
+ { name: "worker", type: Number, defaultValue: workerNum },
26523
+ { name: "process-timeout", type: Number, defaultValue: 60 }
26524
+ // 60 seconds
26500
26525
  ];
26501
26526
  var options = command_line_args_default(optionDefinitions, { partial: true });
26502
26527
  var logLevel = process.env["LOG_LEVEL"]?.toLowerCase();