@sentio/runtime 3.0.0-rc.8 → 3.0.0

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.
Files changed (56) hide show
  1. package/lib/chunk-757YRULG.js +38 -0
  2. package/lib/{chunk-CPJKSHSV.js.map → chunk-757YRULG.js.map} +1 -1
  3. package/lib/chunk-AUPVVLD3.js +3 -0
  4. package/lib/chunk-CJDESLYQ.js +3 -0
  5. package/lib/{chunk-L2A6JPIQ.js.map → chunk-CJDESLYQ.js.map} +1 -1
  6. package/lib/chunk-KF7FHZ25.js +117 -0
  7. package/lib/{chunk-6MZJOWMH.js.map → chunk-KF7FHZ25.js.map} +1 -1
  8. package/lib/chunk-TW627LH5.js +3 -0
  9. package/lib/{chunk-MV6JXS2P.js.map → chunk-TW627LH5.js.map} +1 -1
  10. package/lib/chunk-ZTRGPIW7.js +26 -0
  11. package/lib/chunk-ZTRGPIW7.js.map +1 -0
  12. package/lib/getMachineId-bsd-CDSZ2S36.js +3 -0
  13. package/lib/{getMachineId-bsd-ZJR2OQTA.js.map → getMachineId-bsd-CDSZ2S36.js.map} +1 -1
  14. package/lib/getMachineId-darwin-LM5BSWCG.js +4 -0
  15. package/lib/{getMachineId-darwin-OW6SYINH.js.map → getMachineId-darwin-LM5BSWCG.js.map} +1 -1
  16. package/lib/getMachineId-linux-UA53ZQFA.js +3 -0
  17. package/lib/{getMachineId-linux-L5XPRJBN.js.map → getMachineId-linux-UA53ZQFA.js.map} +1 -1
  18. package/lib/getMachineId-unsupported-LDR77GGJ.js +3 -0
  19. package/lib/{getMachineId-unsupported-B3NMIOO3.js.map → getMachineId-unsupported-LDR77GGJ.js.map} +1 -1
  20. package/lib/getMachineId-win-XULW45X4.js +3 -0
  21. package/lib/{getMachineId-win-TT64F63B.js.map → getMachineId-win-XULW45X4.js.map} +1 -1
  22. package/lib/index.d.ts +4 -9
  23. package/lib/index.js +1 -76
  24. package/lib/index.js.map +1 -1
  25. package/lib/{processor-CNHsQeJ6.d.ts → processor-BUTmbpmJ.d.ts} +2 -3
  26. package/lib/processor-runner.js +43 -32947
  27. package/lib/processor-runner.js.map +1 -1
  28. package/lib/service-worker.js +2 -132
  29. package/lib/service-worker.js.map +1 -1
  30. package/lib/test-processor.test.d.ts +1 -1
  31. package/lib/test-processor.test.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/db-context.ts +4 -4
  34. package/src/gen/processor/protos/processor.ts +17 -1
  35. package/src/gen/service/common/protos/common.ts +356 -1
  36. package/src/otlp.ts +20 -12
  37. package/src/plugin.ts +0 -11
  38. package/src/processor-runner.ts +3 -3
  39. package/src/service-manager.ts +0 -8
  40. package/src/service-v3.ts +11 -18
  41. package/src/state.ts +0 -22
  42. package/lib/chunk-6MZJOWMH.js +0 -60145
  43. package/lib/chunk-CPJKSHSV.js +0 -10976
  44. package/lib/chunk-KVSDPGUI.js +0 -50
  45. package/lib/chunk-L2A6JPIQ.js +0 -21
  46. package/lib/chunk-MV6JXS2P.js +0 -1703
  47. package/lib/chunk-N3VEKOPD.js +0 -97
  48. package/lib/chunk-N3VEKOPD.js.map +0 -1
  49. package/lib/chunk-QHFSZVR5.js +0 -25779
  50. package/lib/chunk-QHFSZVR5.js.map +0 -1
  51. package/lib/getMachineId-bsd-ZJR2OQTA.js +0 -41
  52. package/lib/getMachineId-darwin-OW6SYINH.js +0 -41
  53. package/lib/getMachineId-linux-L5XPRJBN.js +0 -33
  54. package/lib/getMachineId-unsupported-B3NMIOO3.js +0 -24
  55. package/lib/getMachineId-win-TT64F63B.js +0 -43
  56. /package/lib/{chunk-KVSDPGUI.js.map → chunk-AUPVVLD3.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable */
2
2
  import Long from "long";
3
3
  import _m0 from "protobufjs/minimal.js";
4
- import { Struct } from "../../../google/protobuf/struct.js";
4
+ import { ListValue, Struct } from "../../../google/protobuf/struct.js";
5
5
  import { Timestamp } from "../../../google/protobuf/timestamp.js";
6
6
  import { Money } from "../../../google/type/money.js";
7
7
 
@@ -311,6 +311,45 @@ export function notificationTypeToJSON(object: NotificationType): string {
311
311
  }
312
312
  }
313
313
 
314
+ export enum ChatType {
315
+ CHAT_TYPE_UNSPECIFIED = 0,
316
+ CHAT_TYPE_CHAT = 1,
317
+ CHAT_TYPE_ACTION = 2,
318
+ UNRECOGNIZED = -1,
319
+ }
320
+
321
+ export function chatTypeFromJSON(object: any): ChatType {
322
+ switch (object) {
323
+ case 0:
324
+ case "CHAT_TYPE_UNSPECIFIED":
325
+ return ChatType.CHAT_TYPE_UNSPECIFIED;
326
+ case 1:
327
+ case "CHAT_TYPE_CHAT":
328
+ return ChatType.CHAT_TYPE_CHAT;
329
+ case 2:
330
+ case "CHAT_TYPE_ACTION":
331
+ return ChatType.CHAT_TYPE_ACTION;
332
+ case -1:
333
+ case "UNRECOGNIZED":
334
+ default:
335
+ return ChatType.UNRECOGNIZED;
336
+ }
337
+ }
338
+
339
+ export function chatTypeToJSON(object: ChatType): string {
340
+ switch (object) {
341
+ case ChatType.CHAT_TYPE_UNSPECIFIED:
342
+ return "CHAT_TYPE_UNSPECIFIED";
343
+ case ChatType.CHAT_TYPE_CHAT:
344
+ return "CHAT_TYPE_CHAT";
345
+ case ChatType.CHAT_TYPE_ACTION:
346
+ return "CHAT_TYPE_ACTION";
347
+ case ChatType.UNRECOGNIZED:
348
+ default:
349
+ return "UNRECOGNIZED";
350
+ }
351
+ }
352
+
314
353
  export interface UsageTracker {
315
354
  apiSku: string;
316
355
  webuiSku: string;
@@ -412,6 +451,8 @@ export interface User {
412
451
  accountStatus: User_AccountStatus;
413
452
  tier: Tier;
414
453
  isOrganization: boolean;
454
+ walletAddress: string;
455
+ identities: string[];
415
456
  }
416
457
 
417
458
  export enum User_AccountStatus {
@@ -2050,6 +2091,23 @@ export interface RequestLog {
2050
2091
  chainId: string;
2051
2092
  }
2052
2093
 
2094
+ export interface HistoryChat {
2095
+ id: string;
2096
+ title: string;
2097
+ messages: Array<any> | undefined;
2098
+ type: ChatType;
2099
+ meta: { [key: string]: any } | undefined;
2100
+ createdAt: Date | undefined;
2101
+ updatedAt: Date | undefined;
2102
+ projectOwner?: string | undefined;
2103
+ projectSlug?: string | undefined;
2104
+ }
2105
+
2106
+ export interface ProjectOwnerAndSlug {
2107
+ ownerName: string;
2108
+ slug: string;
2109
+ }
2110
+
2053
2111
  function createBaseUsageTracker(): UsageTracker {
2054
2112
  return {
2055
2113
  apiSku: "",
@@ -2796,6 +2854,8 @@ function createBaseUser(): User {
2796
2854
  accountStatus: 0,
2797
2855
  tier: 0,
2798
2856
  isOrganization: false,
2857
+ walletAddress: "",
2858
+ identities: [],
2799
2859
  };
2800
2860
  }
2801
2861
 
@@ -2852,6 +2912,12 @@ export const User = {
2852
2912
  if (message.isOrganization !== false) {
2853
2913
  writer.uint32(128).bool(message.isOrganization);
2854
2914
  }
2915
+ if (message.walletAddress !== "") {
2916
+ writer.uint32(138).string(message.walletAddress);
2917
+ }
2918
+ for (const v of message.identities) {
2919
+ writer.uint32(146).string(v!);
2920
+ }
2855
2921
  return writer;
2856
2922
  },
2857
2923
 
@@ -2967,6 +3033,20 @@ export const User = {
2967
3033
 
2968
3034
  message.isOrganization = reader.bool();
2969
3035
  continue;
3036
+ case 17:
3037
+ if (tag !== 138) {
3038
+ break;
3039
+ }
3040
+
3041
+ message.walletAddress = reader.string();
3042
+ continue;
3043
+ case 18:
3044
+ if (tag !== 146) {
3045
+ break;
3046
+ }
3047
+
3048
+ message.identities.push(reader.string());
3049
+ continue;
2970
3050
  }
2971
3051
  if ((tag & 7) === 4 || tag === 0) {
2972
3052
  break;
@@ -2993,6 +3073,10 @@ export const User = {
2993
3073
  accountStatus: isSet(object.accountStatus) ? user_AccountStatusFromJSON(object.accountStatus) : 0,
2994
3074
  tier: isSet(object.tier) ? tierFromJSON(object.tier) : 0,
2995
3075
  isOrganization: isSet(object.isOrganization) ? globalThis.Boolean(object.isOrganization) : false,
3076
+ walletAddress: isSet(object.walletAddress) ? globalThis.String(object.walletAddress) : "",
3077
+ identities: globalThis.Array.isArray(object?.identities)
3078
+ ? object.identities.map((e: any) => globalThis.String(e))
3079
+ : [],
2996
3080
  };
2997
3081
  },
2998
3082
 
@@ -3043,6 +3127,12 @@ export const User = {
3043
3127
  if (message.isOrganization !== false) {
3044
3128
  obj.isOrganization = message.isOrganization;
3045
3129
  }
3130
+ if (message.walletAddress !== "") {
3131
+ obj.walletAddress = message.walletAddress;
3132
+ }
3133
+ if (message.identities?.length) {
3134
+ obj.identities = message.identities;
3135
+ }
3046
3136
  return obj;
3047
3137
  },
3048
3138
 
@@ -3066,6 +3156,8 @@ export const User = {
3066
3156
  message.accountStatus = object.accountStatus ?? 0;
3067
3157
  message.tier = object.tier ?? 0;
3068
3158
  message.isOrganization = object.isOrganization ?? false;
3159
+ message.walletAddress = object.walletAddress ?? "";
3160
+ message.identities = object.identities?.map((e) => e) || [];
3069
3161
  return message;
3070
3162
  },
3071
3163
  };
@@ -14695,6 +14787,269 @@ export const RequestLog = {
14695
14787
  },
14696
14788
  };
14697
14789
 
14790
+ function createBaseHistoryChat(): HistoryChat {
14791
+ return {
14792
+ id: "",
14793
+ title: "",
14794
+ messages: undefined,
14795
+ type: 0,
14796
+ meta: undefined,
14797
+ createdAt: undefined,
14798
+ updatedAt: undefined,
14799
+ projectOwner: undefined,
14800
+ projectSlug: undefined,
14801
+ };
14802
+ }
14803
+
14804
+ export const HistoryChat = {
14805
+ encode(message: HistoryChat, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
14806
+ if (message.id !== "") {
14807
+ writer.uint32(10).string(message.id);
14808
+ }
14809
+ if (message.title !== "") {
14810
+ writer.uint32(18).string(message.title);
14811
+ }
14812
+ if (message.messages !== undefined) {
14813
+ ListValue.encode(ListValue.wrap(message.messages), writer.uint32(34).fork()).ldelim();
14814
+ }
14815
+ if (message.type !== 0) {
14816
+ writer.uint32(40).int32(message.type);
14817
+ }
14818
+ if (message.meta !== undefined) {
14819
+ Struct.encode(Struct.wrap(message.meta), writer.uint32(50).fork()).ldelim();
14820
+ }
14821
+ if (message.createdAt !== undefined) {
14822
+ Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(58).fork()).ldelim();
14823
+ }
14824
+ if (message.updatedAt !== undefined) {
14825
+ Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(66).fork()).ldelim();
14826
+ }
14827
+ if (message.projectOwner !== undefined) {
14828
+ writer.uint32(74).string(message.projectOwner);
14829
+ }
14830
+ if (message.projectSlug !== undefined) {
14831
+ writer.uint32(82).string(message.projectSlug);
14832
+ }
14833
+ return writer;
14834
+ },
14835
+
14836
+ decode(input: _m0.Reader | Uint8Array, length?: number): HistoryChat {
14837
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
14838
+ let end = length === undefined ? reader.len : reader.pos + length;
14839
+ const message = createBaseHistoryChat();
14840
+ while (reader.pos < end) {
14841
+ const tag = reader.uint32();
14842
+ switch (tag >>> 3) {
14843
+ case 1:
14844
+ if (tag !== 10) {
14845
+ break;
14846
+ }
14847
+
14848
+ message.id = reader.string();
14849
+ continue;
14850
+ case 2:
14851
+ if (tag !== 18) {
14852
+ break;
14853
+ }
14854
+
14855
+ message.title = reader.string();
14856
+ continue;
14857
+ case 4:
14858
+ if (tag !== 34) {
14859
+ break;
14860
+ }
14861
+
14862
+ message.messages = ListValue.unwrap(ListValue.decode(reader, reader.uint32()));
14863
+ continue;
14864
+ case 5:
14865
+ if (tag !== 40) {
14866
+ break;
14867
+ }
14868
+
14869
+ message.type = reader.int32() as any;
14870
+ continue;
14871
+ case 6:
14872
+ if (tag !== 50) {
14873
+ break;
14874
+ }
14875
+
14876
+ message.meta = Struct.unwrap(Struct.decode(reader, reader.uint32()));
14877
+ continue;
14878
+ case 7:
14879
+ if (tag !== 58) {
14880
+ break;
14881
+ }
14882
+
14883
+ message.createdAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
14884
+ continue;
14885
+ case 8:
14886
+ if (tag !== 66) {
14887
+ break;
14888
+ }
14889
+
14890
+ message.updatedAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
14891
+ continue;
14892
+ case 9:
14893
+ if (tag !== 74) {
14894
+ break;
14895
+ }
14896
+
14897
+ message.projectOwner = reader.string();
14898
+ continue;
14899
+ case 10:
14900
+ if (tag !== 82) {
14901
+ break;
14902
+ }
14903
+
14904
+ message.projectSlug = reader.string();
14905
+ continue;
14906
+ }
14907
+ if ((tag & 7) === 4 || tag === 0) {
14908
+ break;
14909
+ }
14910
+ reader.skipType(tag & 7);
14911
+ }
14912
+ return message;
14913
+ },
14914
+
14915
+ fromJSON(object: any): HistoryChat {
14916
+ return {
14917
+ id: isSet(object.id) ? globalThis.String(object.id) : "",
14918
+ title: isSet(object.title) ? globalThis.String(object.title) : "",
14919
+ messages: globalThis.Array.isArray(object.messages) ? [...object.messages] : undefined,
14920
+ type: isSet(object.type) ? chatTypeFromJSON(object.type) : 0,
14921
+ meta: isObject(object.meta) ? object.meta : undefined,
14922
+ createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined,
14923
+ updatedAt: isSet(object.updatedAt) ? fromJsonTimestamp(object.updatedAt) : undefined,
14924
+ projectOwner: isSet(object.projectOwner) ? globalThis.String(object.projectOwner) : undefined,
14925
+ projectSlug: isSet(object.projectSlug) ? globalThis.String(object.projectSlug) : undefined,
14926
+ };
14927
+ },
14928
+
14929
+ toJSON(message: HistoryChat): unknown {
14930
+ const obj: any = {};
14931
+ if (message.id !== "") {
14932
+ obj.id = message.id;
14933
+ }
14934
+ if (message.title !== "") {
14935
+ obj.title = message.title;
14936
+ }
14937
+ if (message.messages !== undefined) {
14938
+ obj.messages = message.messages;
14939
+ }
14940
+ if (message.type !== 0) {
14941
+ obj.type = chatTypeToJSON(message.type);
14942
+ }
14943
+ if (message.meta !== undefined) {
14944
+ obj.meta = message.meta;
14945
+ }
14946
+ if (message.createdAt !== undefined) {
14947
+ obj.createdAt = message.createdAt.toISOString();
14948
+ }
14949
+ if (message.updatedAt !== undefined) {
14950
+ obj.updatedAt = message.updatedAt.toISOString();
14951
+ }
14952
+ if (message.projectOwner !== undefined) {
14953
+ obj.projectOwner = message.projectOwner;
14954
+ }
14955
+ if (message.projectSlug !== undefined) {
14956
+ obj.projectSlug = message.projectSlug;
14957
+ }
14958
+ return obj;
14959
+ },
14960
+
14961
+ create(base?: DeepPartial<HistoryChat>): HistoryChat {
14962
+ return HistoryChat.fromPartial(base ?? {});
14963
+ },
14964
+ fromPartial(object: DeepPartial<HistoryChat>): HistoryChat {
14965
+ const message = createBaseHistoryChat();
14966
+ message.id = object.id ?? "";
14967
+ message.title = object.title ?? "";
14968
+ message.messages = object.messages ?? undefined;
14969
+ message.type = object.type ?? 0;
14970
+ message.meta = object.meta ?? undefined;
14971
+ message.createdAt = object.createdAt ?? undefined;
14972
+ message.updatedAt = object.updatedAt ?? undefined;
14973
+ message.projectOwner = object.projectOwner ?? undefined;
14974
+ message.projectSlug = object.projectSlug ?? undefined;
14975
+ return message;
14976
+ },
14977
+ };
14978
+
14979
+ function createBaseProjectOwnerAndSlug(): ProjectOwnerAndSlug {
14980
+ return { ownerName: "", slug: "" };
14981
+ }
14982
+
14983
+ export const ProjectOwnerAndSlug = {
14984
+ encode(message: ProjectOwnerAndSlug, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
14985
+ if (message.ownerName !== "") {
14986
+ writer.uint32(10).string(message.ownerName);
14987
+ }
14988
+ if (message.slug !== "") {
14989
+ writer.uint32(18).string(message.slug);
14990
+ }
14991
+ return writer;
14992
+ },
14993
+
14994
+ decode(input: _m0.Reader | Uint8Array, length?: number): ProjectOwnerAndSlug {
14995
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
14996
+ let end = length === undefined ? reader.len : reader.pos + length;
14997
+ const message = createBaseProjectOwnerAndSlug();
14998
+ while (reader.pos < end) {
14999
+ const tag = reader.uint32();
15000
+ switch (tag >>> 3) {
15001
+ case 1:
15002
+ if (tag !== 10) {
15003
+ break;
15004
+ }
15005
+
15006
+ message.ownerName = reader.string();
15007
+ continue;
15008
+ case 2:
15009
+ if (tag !== 18) {
15010
+ break;
15011
+ }
15012
+
15013
+ message.slug = reader.string();
15014
+ continue;
15015
+ }
15016
+ if ((tag & 7) === 4 || tag === 0) {
15017
+ break;
15018
+ }
15019
+ reader.skipType(tag & 7);
15020
+ }
15021
+ return message;
15022
+ },
15023
+
15024
+ fromJSON(object: any): ProjectOwnerAndSlug {
15025
+ return {
15026
+ ownerName: isSet(object.ownerName) ? globalThis.String(object.ownerName) : "",
15027
+ slug: isSet(object.slug) ? globalThis.String(object.slug) : "",
15028
+ };
15029
+ },
15030
+
15031
+ toJSON(message: ProjectOwnerAndSlug): unknown {
15032
+ const obj: any = {};
15033
+ if (message.ownerName !== "") {
15034
+ obj.ownerName = message.ownerName;
15035
+ }
15036
+ if (message.slug !== "") {
15037
+ obj.slug = message.slug;
15038
+ }
15039
+ return obj;
15040
+ },
15041
+
15042
+ create(base?: DeepPartial<ProjectOwnerAndSlug>): ProjectOwnerAndSlug {
15043
+ return ProjectOwnerAndSlug.fromPartial(base ?? {});
15044
+ },
15045
+ fromPartial(object: DeepPartial<ProjectOwnerAndSlug>): ProjectOwnerAndSlug {
15046
+ const message = createBaseProjectOwnerAndSlug();
15047
+ message.ownerName = object.ownerName ?? "";
15048
+ message.slug = object.slug ?? "";
15049
+ return message;
15050
+ },
15051
+ };
15052
+
14698
15053
  function bytesFromBase64(b64: string): Uint8Array {
14699
15054
  if ((globalThis as any).Buffer) {
14700
15055
  return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
package/src/otlp.ts CHANGED
@@ -1,32 +1,40 @@
1
- import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics'
1
+ import { IMetricReader, MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics'
2
2
  import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc'
3
3
  import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'
4
- import { NodeSDK } from '@opentelemetry/sdk-node'
5
- import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'
6
4
  import { diag, DiagConsoleLogger, DiagLogLevel, metrics } from '@opentelemetry/api'
7
5
 
8
6
  export async function setupOTLP(debug?: boolean) {
7
+ console.log('Setting up OTLP metrics, debug=', !!debug)
9
8
  if (debug) {
10
9
  diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG)
11
10
  }
12
11
 
13
- const sdk = new NodeSDK({
14
- autoDetectResources: true,
15
- traceExporter: new OTLPTraceExporter(),
16
- metricReaders: [
17
- new PeriodicExportingMetricReader({
18
- exporter: new OTLPMetricExporter()
19
- }),
12
+ const readers: IMetricReader[] = [
13
+ new PeriodicExportingMetricReader({
14
+ exporter: new OTLPMetricExporter(),
15
+ exportIntervalMillis: 60000
16
+ })
17
+ ]
18
+ if (debug) {
19
+ readers.push(
20
20
  new PrometheusExporter({
21
21
  host: '0.0.0.0',
22
22
  port: 4041
23
23
  })
24
+ )
25
+ }
26
+ const meterProvider = new MeterProvider({
27
+ readers: [
28
+ new PeriodicExportingMetricReader({
29
+ exporter: new OTLPMetricExporter(),
30
+ exportIntervalMillis: 60000
31
+ })
24
32
  ]
25
33
  })
26
34
 
27
- sdk.start()
35
+ metrics.setGlobalMeterProvider(meterProvider)
28
36
  ;['SIGINT', 'SIGTERM'].forEach((signal) => {
29
- process.on(signal as any, () => sdk.shutdown().catch(console.error))
37
+ process.on(signal as any, () => meterProvider.forceFlush().catch(console.error))
30
38
  })
31
39
 
32
40
  metrics.getMeter('processor').createGauge('up').record(1)
package/src/plugin.ts CHANGED
@@ -8,7 +8,6 @@ import {
8
8
  ProcessStreamResponse_Partitions,
9
9
  ProcessStreamResponse_Partitions_Partition_SysValue,
10
10
  StartRequest,
11
- TemplateInstance,
12
11
  UpdateTemplatesRequest
13
12
  } from '@sentio/protos'
14
13
  import { IDataBindingContext, IStoreContext } from './db-context.js'
@@ -153,14 +152,4 @@ export class PluginManager {
153
152
  })
154
153
  }
155
154
  }
156
-
157
- sendTemplateInstance(instance: TemplateInstance) {
158
- // send template instance within the current db context
159
- // this is only work in user handlers, when dbContextLocalStorage is set
160
- // plugin.Configure does not have db context
161
- const store = this.dbContextLocalStorage.getStore()
162
- if (store && 'sendTemplateRequest' in store) {
163
- store?.sendTemplateRequest([instance])
164
- }
165
- }
166
155
  }
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import fs from 'fs-extra'
4
-
4
+ // import { compressionAlgorithms } from '@grpc/grpc-js'
5
5
  import { createServer } from 'nice-grpc'
6
6
  import { errorDetailsServerMiddleware } from 'nice-grpc-error-details'
7
7
  // import { registry as niceGrpcRegistry } from 'nice-grpc-prometheus'
8
- import { openTelemetryServerMiddleware } from 'nice-grpc-opentelemetry'
8
+ // import { openTelemetryServerMiddleware } from 'nice-grpc-opentelemetry'
9
9
  import http from 'http'
10
10
  // @ts-ignore inspector promises is not included in @type/node
11
11
  import { Session } from 'node:inspector/promises'
@@ -61,7 +61,7 @@ if (options.startActionServer) {
61
61
  // 'grpc.default_compression_algorithm': compressionAlgorithms.gzip
62
62
  })
63
63
  // .use(prometheusServerMiddleware())
64
- .use(openTelemetryServerMiddleware())
64
+ // .use(openTelemetryServerMiddleware())
65
65
  .use(errorDetailsServerMiddleware)
66
66
 
67
67
  if (options.worker > 1) {
@@ -15,7 +15,6 @@ import { Subject } from 'rxjs'
15
15
 
16
16
  import { MessageChannel } from 'node:worker_threads'
17
17
  import { ProcessorServiceImpl } from './service.js'
18
- import { TemplateInstanceState } from './state.js'
19
18
  import { ProcessorRuntimeOptions } from 'processor-runner-program.js'
20
19
  ;(BigInt.prototype as any).toJSON = function () {
21
20
  return this.toString()
@@ -140,13 +139,6 @@ export class ServiceManager extends ProcessorServiceImpl {
140
139
  argv: process.argv,
141
140
  workerData: this.workerData
142
141
  })
143
- // @ts-ignore - Piscina message handling for template instance sync
144
- this.pool.on('message', (msg: any) => {
145
- if (msg.event == 'add_template_instance') {
146
- // sync the template state from worker to the main thread
147
- TemplateInstanceState.INSTANCE.addValue(msg.value)
148
- }
149
- })
150
142
  }
151
143
  }
152
144
 
package/src/service-v3.ts CHANGED
@@ -29,6 +29,9 @@ import { ProcessorRuntimeOptions } from 'processor-runner-program.js'
29
29
 
30
30
  const { process_binding_count, process_binding_time, process_binding_error } = processMetrics
31
31
 
32
+ const WRITE_V2_EVENT_LOGS = process.env.WRITE_V2_EVENT_LOGS !== 'false'
33
+ const TIME_SERIES_RESULT_BATCH_SIZE = 1000
34
+
32
35
  export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation {
33
36
  readonly enablePartition: boolean
34
37
  private readonly loader: () => Promise<any>
@@ -165,35 +168,26 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
165
168
  ) {
166
169
  const context = this.contexts.new(processId, subject)
167
170
  const start = Date.now()
168
- console.debug('process binding', processId)
169
171
  PluginManager.INSTANCE.processBinding(binding, undefined, context)
170
172
  .then(async (result) => {
171
- console.debug(`process binding ${processId} done`)
172
173
  await context.awaitPendings()
173
174
  const { timeseriesResult, ...otherResults } = result
174
- console.debug('sending ts data length:', result.timeseriesResult.length)
175
- for (const ts of timeseriesResult) {
175
+ for (let i = 0; i < timeseriesResult.length; i += TIME_SERIES_RESULT_BATCH_SIZE) {
176
+ const batch = timeseriesResult.slice(i, i + TIME_SERIES_RESULT_BATCH_SIZE)
176
177
  subject.next({
177
178
  processId,
178
179
  tsRequest: {
179
- data: [ts]
180
+ data: batch
180
181
  }
181
182
  })
182
183
  }
183
184
 
184
- /* if (result.states?.configUpdated) {
185
- console.debug('sending tpl updates:')
186
- subject.next({
187
- processId,
188
- tplRequest: {
189
- templates: TemplateInstanceState.INSTANCE.getValues()
190
- }
191
- })
192
- }*/
193
-
194
- console.debug('sending binding result', processId)
195
185
  subject.next({
196
- result: otherResults,
186
+ result: WRITE_V2_EVENT_LOGS
187
+ ? otherResults
188
+ : {
189
+ states: otherResults.states
190
+ },
197
191
  processId: processId
198
192
  })
199
193
  recordRuntimeInfo(result, binding.handlerType)
@@ -207,7 +201,6 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
207
201
  const cost = Date.now() - start
208
202
  process_binding_time.add(cost)
209
203
  this.contexts.delete(processId)
210
- console.debug('process binding done', processId)
211
204
  })
212
205
  }
213
206
 
package/src/state.ts CHANGED
@@ -1,7 +1,3 @@
1
- import { TemplateInstance } from '@sentio/protos'
2
- import { isMainThread, parentPort, threadId } from 'node:worker_threads'
3
- import { PluginManager } from './plugin.js'
4
-
5
1
  export class State {
6
2
  stateMap = new Map<string, any>()
7
3
 
@@ -85,21 +81,3 @@ export abstract class ListStateStorage<T> extends StateStorage<T[]> {
85
81
  return value
86
82
  }
87
83
  }
88
-
89
- export class TemplateInstanceState extends ListStateStorage<TemplateInstance> {
90
- static INSTANCE = new TemplateInstanceState()
91
-
92
- constructor() {
93
- super()
94
- }
95
-
96
- override addValue(value: TemplateInstance): TemplateInstance {
97
- if (!isMainThread) {
98
- // I'm worker thread, should notice the main thread
99
- parentPort?.postMessage({ event: 'add_template_instance', value, from: threadId })
100
- }
101
- const ret = super.addValue(value)
102
- PluginManager.INSTANCE.sendTemplateInstance(ret)
103
- return ret
104
- }
105
- }