@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.
@@ -21,7 +21,7 @@ import {
21
21
  require_roots,
22
22
  require_rpc,
23
23
  require_writer
24
- } from "./chunk-45FF2A6M.js";
24
+ } from "./chunk-HMNYJB5K.js";
25
25
 
26
26
  // ../../node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js
27
27
  var require_universalify = __commonJS({
@@ -59366,10 +59366,12 @@ var ProcessorServiceImpl = class {
59366
59366
  shutdownHandler;
59367
59367
  enablePreprocess;
59368
59368
  preparedData;
59369
+ enablePartition;
59369
59370
  constructor(loader, shutdownHandler) {
59370
59371
  this.loader = loader;
59371
59372
  this.shutdownHandler = shutdownHandler;
59372
59373
  this.enablePreprocess = process.env["ENABLE_PREPROCESS"] ? process.env["ENABLE_PREPROCESS"].toLowerCase() == "true" : false;
59374
+ this.enablePartition = process.env["SENTIO_ENABLE_BINDING_DATA_PARTITION"] == "true";
59373
59375
  }
59374
59376
  async getConfig(request, context2) {
59375
59377
  if (!this.started) {
@@ -59626,6 +59628,7 @@ var ProcessorServiceImpl = class {
59626
59628
  }
59627
59629
  async handleRequests(requests, subject) {
59628
59630
  const contexts = new Contexts();
59631
+ let lastBinding = void 0;
59629
59632
  for await (const request of requests) {
59630
59633
  try {
59631
59634
  if (request.binding) {
@@ -59637,25 +59640,22 @@ var ProcessorServiceImpl = class {
59637
59640
  });
59638
59641
  continue;
59639
59642
  }
59640
- const binding = request.binding;
59641
- const dbContext = contexts.new(request.processId, subject);
59642
- const start = Date.now();
59643
- PluginManager.INSTANCE.processBinding(binding, this.preparedData, dbContext).then(async (result) => {
59644
- await dbContext.awaitPendings();
59643
+ lastBinding = request.binding;
59644
+ if (this.enablePartition) {
59645
+ const partitions = await PluginManager.INSTANCE.partition(request.binding);
59645
59646
  subject.next({
59646
- result,
59647
- processId: request.processId
59647
+ processId: request.processId,
59648
+ partitions
59648
59649
  });
59649
- recordRuntimeInfo(result, binding.handlerType);
59650
- }).catch((e) => {
59651
- console.debug(e);
59652
- dbContext.error(request.processId, e);
59653
- process_binding_error.add(1);
59654
- }).finally(() => {
59655
- const cost = Date.now() - start;
59656
- process_binding_time.add(cost);
59657
- contexts.delete(request.processId);
59658
- });
59650
+ } else {
59651
+ this.startProcess(request.processId, request.binding, contexts, subject);
59652
+ }
59653
+ }
59654
+ if (request.start) {
59655
+ if (!lastBinding) {
59656
+ throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "start request received without binding");
59657
+ }
59658
+ this.startProcess(request.processId, lastBinding, contexts, subject);
59659
59659
  }
59660
59660
  if (request.dbResult) {
59661
59661
  const dbContext = contexts.get(request.processId);
@@ -59670,6 +59670,26 @@ var ProcessorServiceImpl = class {
59670
59670
  }
59671
59671
  }
59672
59672
  }
59673
+ startProcess(processId, binding, contexts, subject) {
59674
+ const dbContext = contexts.new(processId, subject);
59675
+ const start = Date.now();
59676
+ PluginManager.INSTANCE.processBinding(binding, this.preparedData, dbContext).then(async (result) => {
59677
+ await dbContext.awaitPendings();
59678
+ subject.next({
59679
+ result,
59680
+ processId
59681
+ });
59682
+ recordRuntimeInfo(result, binding.handlerType);
59683
+ }).catch((e) => {
59684
+ console.debug(e);
59685
+ dbContext.error(processId, e);
59686
+ process_binding_error.add(1);
59687
+ }).finally(() => {
59688
+ const cost = Date.now() - start;
59689
+ process_binding_time.add(cost);
59690
+ contexts.delete(processId);
59691
+ });
59692
+ }
59673
59693
  };
59674
59694
  function recordRuntimeInfo(results, handlerType) {
59675
59695
  for (const list of [results.gauges, results.counters, results.events, results.exports]) {
@@ -59835,4 +59855,4 @@ long/umd/index.js:
59835
59855
  @noble/curves/esm/secp256k1.js:
59836
59856
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
59837
59857
  */
59838
- //# sourceMappingURL=chunk-EPAMG3V5.js.map
59858
+ //# sourceMappingURL=chunk-3G5TU64H.js.map