@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.
@@ -6,7 +6,7 @@ import {
6
6
  __require,
7
7
  __toCommonJS,
8
8
  __toESM
9
- } from "./chunk-45FF2A6M.js";
9
+ } from "./chunk-HMNYJB5K.js";
10
10
 
11
11
  // ../../node_modules/.pnpm/logform@2.6.0/node_modules/logform/format.js
12
12
  var require_format = __commonJS({
@@ -10972,4 +10972,4 @@ export {
10972
10972
  safe-buffer/index.js:
10973
10973
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
10974
10974
  */
10975
- //# sourceMappingURL=chunk-GWKJGG55.js.map
10975
+ //# sourceMappingURL=chunk-ZYJXCGEJ.js.map
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _sentio_protos from '@sentio/protos';
2
- import { DeepPartial as DeepPartial$1, DBResponse, ProcessStreamResponse, DBRequest_DBUpsert, DBRequest, HandlerType, ProcessConfigResponse, StartRequest, DataBinding, PreparedData, ProcessResult, PreprocessResult, TemplateInstance, EthCallParam, ProcessorServiceImplementation, ProcessConfigRequest, Empty, ProcessBindingsRequest, ProcessBindingResponse, ProcessStreamRequest, PreprocessStreamRequest, PreprocessStreamResponse } from '@sentio/protos';
2
+ import { DeepPartial as DeepPartial$1, DBResponse, ProcessStreamResponse, DBRequest_DBUpsert, DBRequest, HandlerType, ProcessConfigResponse, StartRequest, DataBinding, PreparedData, ProcessResult, PreprocessResult, ProcessStreamResponse_Partitions, TemplateInstance, EthCallParam, ProcessorServiceImplementation, ProcessConfigRequest, Empty, ProcessBindingsRequest, ProcessBindingResponse, ProcessStreamRequest, PreprocessStreamRequest, PreprocessStreamResponse } from '@sentio/protos';
3
3
  import { Subject } from 'rxjs';
4
4
  import { AsyncLocalStorage } from 'node:async_hooks';
5
5
  import { Required } from 'utility-types';
@@ -65,6 +65,7 @@ declare abstract class Plugin {
65
65
  preprocessBinding(request: DataBinding, preprocessStore: {
66
66
  [k: string]: any;
67
67
  }): Promise<PreprocessResult>;
68
+ partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions>;
68
69
  /**
69
70
  * method used by action server only
70
71
  * @param port
@@ -90,6 +91,7 @@ declare class PluginManager {
90
91
  */
91
92
  stateDiff(config: ProcessConfigResponse): boolean;
92
93
  processBinding(request: DataBinding, preparedData: PreparedData | undefined, dbContext?: IStoreContext): Promise<ProcessResult>;
94
+ partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions>;
93
95
  preprocessBinding(request: DataBinding, preprocessStore: {
94
96
  [k: string]: any;
95
97
  }, dbContext?: StoreContext): Promise<PreprocessResult>;
@@ -162,6 +164,7 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
162
164
  private readonly shutdownHandler?;
163
165
  private readonly enablePreprocess;
164
166
  private preparedData;
167
+ readonly enablePartition: boolean;
165
168
  constructor(loader: () => Promise<any>, shutdownHandler?: () => void);
166
169
  getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse>;
167
170
  start(request: StartRequest, context: CallContext): Promise<Empty>;
@@ -519,6 +522,14 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
519
522
  } | undefined;
520
523
  }[] | undefined;
521
524
  } | undefined;
525
+ partitions?: {
526
+ partitions?: {
527
+ [x: number]: {
528
+ userValue?: string | undefined;
529
+ sysValue?: _sentio_protos.ProcessStreamResponse_Partitions_Partition_SysValue | undefined;
530
+ } | undefined;
531
+ } | undefined;
532
+ } | undefined;
522
533
  }, void, undefined>;
523
534
  handlePreprocessRequests(requests: AsyncIterable<PreprocessStreamRequest>, subject: Subject<DeepPartial$1<PreprocessStreamResponse>>): Promise<void>;
524
535
  preprocessBindingsStream(requests: AsyncIterable<PreprocessStreamRequest>, context: CallContext): AsyncGenerator<{
@@ -654,6 +665,7 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
654
665
  } | undefined;
655
666
  }, void, undefined>;
656
667
  protected handleRequests(requests: AsyncIterable<ProcessStreamRequest>, subject: Subject<DeepPartial$1<ProcessStreamResponse>>): Promise<void>;
668
+ private startProcess;
657
669
  }
658
670
  declare function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType): void;
659
671
 
package/lib/index.js CHANGED
@@ -28,11 +28,11 @@ import {
28
28
  providerMetrics,
29
29
  recordRuntimeInfo,
30
30
  timeoutError
31
- } from "./chunk-EPAMG3V5.js";
31
+ } from "./chunk-3G5TU64H.js";
32
32
  import {
33
33
  Plugin,
34
34
  PluginManager
35
- } from "./chunk-45FF2A6M.js";
35
+ } from "./chunk-HMNYJB5K.js";
36
36
 
37
37
  // src/chain-config.ts
38
38
  import("node:process").then((p) => p.stdout.write(""));
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-6XHWJ2VS.js";
6
6
  import {
7
7
  setupLogger
8
- } from "./chunk-GWKJGG55.js";
8
+ } from "./chunk-ZYJXCGEJ.js";
9
9
  import {
10
10
  DiagConsoleLogger,
11
11
  DiagLogLevel,
@@ -44,7 +44,7 @@ import {
44
44
  require_lodash,
45
45
  require_src,
46
46
  trace
47
- } from "./chunk-EPAMG3V5.js";
47
+ } from "./chunk-3G5TU64H.js";
48
48
  import {
49
49
  ExecutionConfig,
50
50
  HandlerType,
@@ -60,7 +60,7 @@ import {
60
60
  __toCommonJS,
61
61
  __toESM,
62
62
  require_minimal2 as require_minimal
63
- } from "./chunk-45FF2A6M.js";
63
+ } from "./chunk-HMNYJB5K.js";
64
64
 
65
65
  // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.25.1/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js
66
66
  // @__NO_SIDE_EFFECTS__
@@ -12966,19 +12966,19 @@ var require_root = __commonJS({
12966
12966
  return Span2;
12967
12967
  }();
12968
12968
  v1.Status = function() {
12969
- function Status(properties) {
12969
+ function Status2(properties) {
12970
12970
  if (properties) {
12971
12971
  for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
12972
12972
  if (properties[keys[i]] != null)
12973
12973
  this[keys[i]] = properties[keys[i]];
12974
12974
  }
12975
12975
  }
12976
- Status.prototype.message = null;
12977
- Status.prototype.code = null;
12978
- Status.create = function create(properties) {
12979
- return new Status(properties);
12976
+ Status2.prototype.message = null;
12977
+ Status2.prototype.code = null;
12978
+ Status2.create = function create(properties) {
12979
+ return new Status2(properties);
12980
12980
  };
12981
- Status.encode = function encode(message, writer) {
12981
+ Status2.encode = function encode(message, writer) {
12982
12982
  if (!writer)
12983
12983
  writer = $Writer.create();
12984
12984
  if (message.message != null && Object.hasOwnProperty.call(message, "message"))
@@ -12993,10 +12993,10 @@ var require_root = __commonJS({
12993
12993
  ).int32(message.code);
12994
12994
  return writer;
12995
12995
  };
12996
- Status.encodeDelimited = function encodeDelimited(message, writer) {
12996
+ Status2.encodeDelimited = function encodeDelimited(message, writer) {
12997
12997
  return this.encode(message, writer).ldelim();
12998
12998
  };
12999
- Status.decode = function decode(reader, length) {
12999
+ Status2.decode = function decode(reader, length) {
13000
13000
  if (!(reader instanceof $Reader))
13001
13001
  reader = $Reader.create(reader);
13002
13002
  var end = length === void 0 ? reader.len : reader.pos + length, message = new $root.opentelemetry.proto.trace.v1.Status();
@@ -13018,12 +13018,12 @@ var require_root = __commonJS({
13018
13018
  }
13019
13019
  return message;
13020
13020
  };
13021
- Status.decodeDelimited = function decodeDelimited(reader) {
13021
+ Status2.decodeDelimited = function decodeDelimited(reader) {
13022
13022
  if (!(reader instanceof $Reader))
13023
13023
  reader = new $Reader(reader);
13024
13024
  return this.decode(reader, reader.uint32());
13025
13025
  };
13026
- Status.verify = function verify(message) {
13026
+ Status2.verify = function verify(message) {
13027
13027
  if (typeof message !== "object" || message === null)
13028
13028
  return "object expected";
13029
13029
  if (message.message != null && message.hasOwnProperty("message")) {
@@ -13041,7 +13041,7 @@ var require_root = __commonJS({
13041
13041
  }
13042
13042
  return null;
13043
13043
  };
13044
- Status.fromObject = function fromObject(object) {
13044
+ Status2.fromObject = function fromObject(object) {
13045
13045
  if (object instanceof $root.opentelemetry.proto.trace.v1.Status)
13046
13046
  return object;
13047
13047
  var message = new $root.opentelemetry.proto.trace.v1.Status();
@@ -13069,7 +13069,7 @@ var require_root = __commonJS({
13069
13069
  }
13070
13070
  return message;
13071
13071
  };
13072
- Status.toObject = function toObject(message, options2) {
13072
+ Status2.toObject = function toObject(message, options2) {
13073
13073
  if (!options2)
13074
13074
  options2 = {};
13075
13075
  var object = {};
@@ -13083,23 +13083,23 @@ var require_root = __commonJS({
13083
13083
  object.code = options2.enums === String ? $root.opentelemetry.proto.trace.v1.Status.StatusCode[message.code] === void 0 ? message.code : $root.opentelemetry.proto.trace.v1.Status.StatusCode[message.code] : message.code;
13084
13084
  return object;
13085
13085
  };
13086
- Status.prototype.toJSON = function toJSON() {
13086
+ Status2.prototype.toJSON = function toJSON() {
13087
13087
  return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
13088
13088
  };
13089
- Status.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
13089
+ Status2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
13090
13090
  if (typeUrlPrefix === void 0) {
13091
13091
  typeUrlPrefix = "type.googleapis.com";
13092
13092
  }
13093
13093
  return typeUrlPrefix + "/opentelemetry.proto.trace.v1.Status";
13094
13094
  };
13095
- Status.StatusCode = function() {
13095
+ Status2.StatusCode = function() {
13096
13096
  var valuesById = {}, values = Object.create(valuesById);
13097
13097
  values[valuesById[0] = "STATUS_CODE_UNSET"] = 0;
13098
13098
  values[valuesById[1] = "STATUS_CODE_OK"] = 1;
13099
13099
  values[valuesById[2] = "STATUS_CODE_ERROR"] = 2;
13100
13100
  return values;
13101
13101
  }();
13102
- return Status;
13102
+ return Status2;
13103
13103
  }();
13104
13104
  return v1;
13105
13105
  }();
@@ -25945,7 +25945,7 @@ function commandLineArgs(optionDefinitions2, options2) {
25945
25945
  var command_line_args_default = commandLineArgs;
25946
25946
 
25947
25947
  // src/processor-runner.ts
25948
- var import_nice_grpc = __toESM(require_lib3(), 1);
25948
+ var import_nice_grpc2 = __toESM(require_lib3(), 1);
25949
25949
  var import_nice_grpc_error_details = __toESM(require_lib4(), 1);
25950
25950
  var import_nice_grpc_opentelemetry = __toESM(require_lib5(), 1);
25951
25951
  import http2 from "http";
@@ -26256,6 +26256,7 @@ var ActionServer = class {
26256
26256
  import("node:process").then((p) => p.stdout.write(""));
26257
26257
 
26258
26258
  // src/service-manager.ts
26259
+ var import_nice_grpc = __toESM(require_lib3(), 1);
26259
26260
  import { Piscina } from "piscina";
26260
26261
  import { MessageChannel } from "node:worker_threads";
26261
26262
  var { process_binding_count, process_binding_time, process_binding_error } = processMetrics;
@@ -26290,18 +26291,10 @@ var ServiceManager = class extends ProcessorServiceImpl {
26290
26291
  await this.pool?.destroy();
26291
26292
  return await super.stop(request3, context2);
26292
26293
  }
26293
- async process(request3, dbContext) {
26294
- if (!this.pool) {
26295
- await this.initPool();
26296
- }
26297
- return this.pool.run(
26298
- { request: request3, workerPort: dbContext?.workerPort },
26299
- { transferList: dbContext?.workerPort ? [dbContext?.workerPort] : [] }
26300
- );
26301
- }
26302
26294
  contexts = new Contexts();
26303
26295
  async handleRequests(requests, subject) {
26304
26296
  for await (const request3 of requests) {
26297
+ let lastBinding = void 0;
26305
26298
  try {
26306
26299
  if (request3.binding) {
26307
26300
  process_binding_count.add(1);
@@ -26312,22 +26305,22 @@ var ServiceManager = class extends ProcessorServiceImpl {
26312
26305
  });
26313
26306
  continue;
26314
26307
  }
26315
- const binding = request3.binding;
26316
- const dbContext = this.contexts.new(request3.processId, subject);
26317
- const start = Date.now();
26318
- this.process(binding, dbContext).then(async (result) => {
26308
+ if (this.enablePartition) {
26309
+ const partitions = await PluginManager.INSTANCE.partition(request3.binding);
26319
26310
  subject.next({
26320
- result,
26321
- processId: request3.processId
26311
+ processId: request3.processId,
26312
+ partitions
26322
26313
  });
26323
- }).catch((e) => {
26324
- dbContext.error(request3.processId, e);
26325
- process_binding_error.add(1);
26326
- }).finally(() => {
26327
- const cost = Date.now() - start;
26328
- process_binding_time.add(cost);
26329
- this.contexts.delete(request3.processId);
26330
- });
26314
+ lastBinding = request3.binding;
26315
+ } else {
26316
+ this.doProcess(request3.processId, request3.binding, subject);
26317
+ }
26318
+ }
26319
+ if (request3.start) {
26320
+ if (!lastBinding) {
26321
+ throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "start request received without binding");
26322
+ }
26323
+ this.doProcess(request3.processId, lastBinding, subject);
26331
26324
  }
26332
26325
  if (request3.dbResult) {
26333
26326
  const dbContext = this.contexts.get(request3.processId);
@@ -26342,6 +26335,32 @@ var ServiceManager = class extends ProcessorServiceImpl {
26342
26335
  }
26343
26336
  }
26344
26337
  }
26338
+ doProcess(processId, binding, subject) {
26339
+ const dbContext = this.contexts.new(processId, subject);
26340
+ const start = Date.now();
26341
+ this.process(binding, dbContext).then(async (result) => {
26342
+ subject.next({
26343
+ result,
26344
+ processId
26345
+ });
26346
+ }).catch((e) => {
26347
+ dbContext.error(processId, e);
26348
+ process_binding_error.add(1);
26349
+ }).finally(() => {
26350
+ const cost = Date.now() - start;
26351
+ process_binding_time.add(cost);
26352
+ this.contexts.delete(processId);
26353
+ });
26354
+ }
26355
+ async process(request3, dbContext) {
26356
+ if (!this.pool) {
26357
+ await this.initPool();
26358
+ }
26359
+ return this.pool.run(
26360
+ { request: request3, workerPort: dbContext?.workerPort },
26361
+ { transferList: dbContext?.workerPort ? [dbContext?.workerPort] : [] }
26362
+ );
26363
+ }
26345
26364
  async initPool() {
26346
26365
  if (this.pool) {
26347
26366
  await this.pool.close();
@@ -26466,7 +26485,7 @@ if (options["start-action-server"]) {
26466
26485
  server = new ActionServer(loader);
26467
26486
  server.listen(options.port);
26468
26487
  } else {
26469
- server = (0, import_nice_grpc.createServer)({
26488
+ server = (0, import_nice_grpc2.createServer)({
26470
26489
  "grpc.max_send_message_length": 768 * 1024 * 1024,
26471
26490
  "grpc.max_receive_message_length": 768 * 1024 * 1024,
26472
26491
  "grpc.default_compression_algorithm": import_grpc_js.compressionAlgorithms.gzip