@sentio/runtime 2.59.0-rc.21 → 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/lib/service-worker.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
2
2
|
import {
|
3
3
|
setupLogger
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-ZYJXCGEJ.js";
|
5
5
|
import {
|
6
6
|
AbstractStoreContext,
|
7
7
|
configureEndpoints,
|
@@ -10,12 +10,12 @@ import {
|
|
10
10
|
recordRuntimeInfo,
|
11
11
|
require_lib3 as require_lib,
|
12
12
|
require_lib4 as require_lib2
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-3G5TU64H.js";
|
14
14
|
import {
|
15
15
|
PluginManager,
|
16
16
|
ProcessConfigResponse,
|
17
17
|
__toESM
|
18
|
-
} from "./chunk-
|
18
|
+
} from "./chunk-HMNYJB5K.js";
|
19
19
|
|
20
20
|
// src/service-worker.ts
|
21
21
|
var import_nice_grpc = __toESM(require_lib(), 1);
|
package/package.json
CHANGED
@@ -912,12 +912,71 @@ export interface ProcessStreamRequest {
|
|
912
912
|
processId: number;
|
913
913
|
binding?: DataBinding | undefined;
|
914
914
|
dbResult?: DBResponse | undefined;
|
915
|
+
start?: boolean | undefined;
|
915
916
|
}
|
916
917
|
|
917
918
|
export interface ProcessStreamResponse {
|
918
919
|
processId: number;
|
919
920
|
dbRequest?: DBRequest | undefined;
|
920
921
|
result?: ProcessResult | undefined;
|
922
|
+
partitions?: ProcessStreamResponse_Partitions | undefined;
|
923
|
+
}
|
924
|
+
|
925
|
+
export interface ProcessStreamResponse_Partitions {
|
926
|
+
partitions: { [key: number]: ProcessStreamResponse_Partitions_Partition };
|
927
|
+
}
|
928
|
+
|
929
|
+
export interface ProcessStreamResponse_Partitions_Partition {
|
930
|
+
userValue?: string | undefined;
|
931
|
+
sysValue?: ProcessStreamResponse_Partitions_Partition_SysValue | undefined;
|
932
|
+
}
|
933
|
+
|
934
|
+
export enum ProcessStreamResponse_Partitions_Partition_SysValue {
|
935
|
+
BLOCK_NUMBER = 0,
|
936
|
+
SEQ_MODE = 1,
|
937
|
+
UNIQUE_VALUE = 2,
|
938
|
+
UNRECOGNIZED = -1,
|
939
|
+
}
|
940
|
+
|
941
|
+
export function processStreamResponse_Partitions_Partition_SysValueFromJSON(
|
942
|
+
object: any,
|
943
|
+
): ProcessStreamResponse_Partitions_Partition_SysValue {
|
944
|
+
switch (object) {
|
945
|
+
case 0:
|
946
|
+
case "BLOCK_NUMBER":
|
947
|
+
return ProcessStreamResponse_Partitions_Partition_SysValue.BLOCK_NUMBER;
|
948
|
+
case 1:
|
949
|
+
case "SEQ_MODE":
|
950
|
+
return ProcessStreamResponse_Partitions_Partition_SysValue.SEQ_MODE;
|
951
|
+
case 2:
|
952
|
+
case "UNIQUE_VALUE":
|
953
|
+
return ProcessStreamResponse_Partitions_Partition_SysValue.UNIQUE_VALUE;
|
954
|
+
case -1:
|
955
|
+
case "UNRECOGNIZED":
|
956
|
+
default:
|
957
|
+
return ProcessStreamResponse_Partitions_Partition_SysValue.UNRECOGNIZED;
|
958
|
+
}
|
959
|
+
}
|
960
|
+
|
961
|
+
export function processStreamResponse_Partitions_Partition_SysValueToJSON(
|
962
|
+
object: ProcessStreamResponse_Partitions_Partition_SysValue,
|
963
|
+
): string {
|
964
|
+
switch (object) {
|
965
|
+
case ProcessStreamResponse_Partitions_Partition_SysValue.BLOCK_NUMBER:
|
966
|
+
return "BLOCK_NUMBER";
|
967
|
+
case ProcessStreamResponse_Partitions_Partition_SysValue.SEQ_MODE:
|
968
|
+
return "SEQ_MODE";
|
969
|
+
case ProcessStreamResponse_Partitions_Partition_SysValue.UNIQUE_VALUE:
|
970
|
+
return "UNIQUE_VALUE";
|
971
|
+
case ProcessStreamResponse_Partitions_Partition_SysValue.UNRECOGNIZED:
|
972
|
+
default:
|
973
|
+
return "UNRECOGNIZED";
|
974
|
+
}
|
975
|
+
}
|
976
|
+
|
977
|
+
export interface ProcessStreamResponse_Partitions_PartitionsEntry {
|
978
|
+
key: number;
|
979
|
+
value: ProcessStreamResponse_Partitions_Partition | undefined;
|
921
980
|
}
|
922
981
|
|
923
982
|
export interface PreprocessStreamRequest {
|
@@ -7999,7 +8058,7 @@ export const ProcessBindingResponse = {
|
|
7999
8058
|
};
|
8000
8059
|
|
8001
8060
|
function createBaseProcessStreamRequest(): ProcessStreamRequest {
|
8002
|
-
return { processId: 0, binding: undefined, dbResult: undefined };
|
8061
|
+
return { processId: 0, binding: undefined, dbResult: undefined, start: undefined };
|
8003
8062
|
}
|
8004
8063
|
|
8005
8064
|
export const ProcessStreamRequest = {
|
@@ -8013,6 +8072,9 @@ export const ProcessStreamRequest = {
|
|
8013
8072
|
if (message.dbResult !== undefined) {
|
8014
8073
|
DBResponse.encode(message.dbResult, writer.uint32(26).fork()).ldelim();
|
8015
8074
|
}
|
8075
|
+
if (message.start !== undefined) {
|
8076
|
+
writer.uint32(32).bool(message.start);
|
8077
|
+
}
|
8016
8078
|
return writer;
|
8017
8079
|
},
|
8018
8080
|
|
@@ -8044,6 +8106,13 @@ export const ProcessStreamRequest = {
|
|
8044
8106
|
|
8045
8107
|
message.dbResult = DBResponse.decode(reader, reader.uint32());
|
8046
8108
|
continue;
|
8109
|
+
case 4:
|
8110
|
+
if (tag !== 32) {
|
8111
|
+
break;
|
8112
|
+
}
|
8113
|
+
|
8114
|
+
message.start = reader.bool();
|
8115
|
+
continue;
|
8047
8116
|
}
|
8048
8117
|
if ((tag & 7) === 4 || tag === 0) {
|
8049
8118
|
break;
|
@@ -8058,6 +8127,7 @@ export const ProcessStreamRequest = {
|
|
8058
8127
|
processId: isSet(object.processId) ? globalThis.Number(object.processId) : 0,
|
8059
8128
|
binding: isSet(object.binding) ? DataBinding.fromJSON(object.binding) : undefined,
|
8060
8129
|
dbResult: isSet(object.dbResult) ? DBResponse.fromJSON(object.dbResult) : undefined,
|
8130
|
+
start: isSet(object.start) ? globalThis.Boolean(object.start) : undefined,
|
8061
8131
|
};
|
8062
8132
|
},
|
8063
8133
|
|
@@ -8072,6 +8142,9 @@ export const ProcessStreamRequest = {
|
|
8072
8142
|
if (message.dbResult !== undefined) {
|
8073
8143
|
obj.dbResult = DBResponse.toJSON(message.dbResult);
|
8074
8144
|
}
|
8145
|
+
if (message.start !== undefined) {
|
8146
|
+
obj.start = message.start;
|
8147
|
+
}
|
8075
8148
|
return obj;
|
8076
8149
|
},
|
8077
8150
|
|
@@ -8087,12 +8160,13 @@ export const ProcessStreamRequest = {
|
|
8087
8160
|
message.dbResult = (object.dbResult !== undefined && object.dbResult !== null)
|
8088
8161
|
? DBResponse.fromPartial(object.dbResult)
|
8089
8162
|
: undefined;
|
8163
|
+
message.start = object.start ?? undefined;
|
8090
8164
|
return message;
|
8091
8165
|
},
|
8092
8166
|
};
|
8093
8167
|
|
8094
8168
|
function createBaseProcessStreamResponse(): ProcessStreamResponse {
|
8095
|
-
return { processId: 0, dbRequest: undefined, result: undefined };
|
8169
|
+
return { processId: 0, dbRequest: undefined, result: undefined, partitions: undefined };
|
8096
8170
|
}
|
8097
8171
|
|
8098
8172
|
export const ProcessStreamResponse = {
|
@@ -8106,6 +8180,9 @@ export const ProcessStreamResponse = {
|
|
8106
8180
|
if (message.result !== undefined) {
|
8107
8181
|
ProcessResult.encode(message.result, writer.uint32(26).fork()).ldelim();
|
8108
8182
|
}
|
8183
|
+
if (message.partitions !== undefined) {
|
8184
|
+
ProcessStreamResponse_Partitions.encode(message.partitions, writer.uint32(34).fork()).ldelim();
|
8185
|
+
}
|
8109
8186
|
return writer;
|
8110
8187
|
},
|
8111
8188
|
|
@@ -8137,6 +8214,13 @@ export const ProcessStreamResponse = {
|
|
8137
8214
|
|
8138
8215
|
message.result = ProcessResult.decode(reader, reader.uint32());
|
8139
8216
|
continue;
|
8217
|
+
case 4:
|
8218
|
+
if (tag !== 34) {
|
8219
|
+
break;
|
8220
|
+
}
|
8221
|
+
|
8222
|
+
message.partitions = ProcessStreamResponse_Partitions.decode(reader, reader.uint32());
|
8223
|
+
continue;
|
8140
8224
|
}
|
8141
8225
|
if ((tag & 7) === 4 || tag === 0) {
|
8142
8226
|
break;
|
@@ -8151,6 +8235,7 @@ export const ProcessStreamResponse = {
|
|
8151
8235
|
processId: isSet(object.processId) ? globalThis.Number(object.processId) : 0,
|
8152
8236
|
dbRequest: isSet(object.dbRequest) ? DBRequest.fromJSON(object.dbRequest) : undefined,
|
8153
8237
|
result: isSet(object.result) ? ProcessResult.fromJSON(object.result) : undefined,
|
8238
|
+
partitions: isSet(object.partitions) ? ProcessStreamResponse_Partitions.fromJSON(object.partitions) : undefined,
|
8154
8239
|
};
|
8155
8240
|
},
|
8156
8241
|
|
@@ -8165,6 +8250,9 @@ export const ProcessStreamResponse = {
|
|
8165
8250
|
if (message.result !== undefined) {
|
8166
8251
|
obj.result = ProcessResult.toJSON(message.result);
|
8167
8252
|
}
|
8253
|
+
if (message.partitions !== undefined) {
|
8254
|
+
obj.partitions = ProcessStreamResponse_Partitions.toJSON(message.partitions);
|
8255
|
+
}
|
8168
8256
|
return obj;
|
8169
8257
|
},
|
8170
8258
|
|
@@ -8180,6 +8268,254 @@ export const ProcessStreamResponse = {
|
|
8180
8268
|
message.result = (object.result !== undefined && object.result !== null)
|
8181
8269
|
? ProcessResult.fromPartial(object.result)
|
8182
8270
|
: undefined;
|
8271
|
+
message.partitions = (object.partitions !== undefined && object.partitions !== null)
|
8272
|
+
? ProcessStreamResponse_Partitions.fromPartial(object.partitions)
|
8273
|
+
: undefined;
|
8274
|
+
return message;
|
8275
|
+
},
|
8276
|
+
};
|
8277
|
+
|
8278
|
+
function createBaseProcessStreamResponse_Partitions(): ProcessStreamResponse_Partitions {
|
8279
|
+
return { partitions: {} };
|
8280
|
+
}
|
8281
|
+
|
8282
|
+
export const ProcessStreamResponse_Partitions = {
|
8283
|
+
encode(message: ProcessStreamResponse_Partitions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
8284
|
+
Object.entries(message.partitions).forEach(([key, value]) => {
|
8285
|
+
ProcessStreamResponse_Partitions_PartitionsEntry.encode({ key: key as any, value }, writer.uint32(10).fork())
|
8286
|
+
.ldelim();
|
8287
|
+
});
|
8288
|
+
return writer;
|
8289
|
+
},
|
8290
|
+
|
8291
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): ProcessStreamResponse_Partitions {
|
8292
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
8293
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
8294
|
+
const message = createBaseProcessStreamResponse_Partitions();
|
8295
|
+
while (reader.pos < end) {
|
8296
|
+
const tag = reader.uint32();
|
8297
|
+
switch (tag >>> 3) {
|
8298
|
+
case 1:
|
8299
|
+
if (tag !== 10) {
|
8300
|
+
break;
|
8301
|
+
}
|
8302
|
+
|
8303
|
+
const entry1 = ProcessStreamResponse_Partitions_PartitionsEntry.decode(reader, reader.uint32());
|
8304
|
+
if (entry1.value !== undefined) {
|
8305
|
+
message.partitions[entry1.key] = entry1.value;
|
8306
|
+
}
|
8307
|
+
continue;
|
8308
|
+
}
|
8309
|
+
if ((tag & 7) === 4 || tag === 0) {
|
8310
|
+
break;
|
8311
|
+
}
|
8312
|
+
reader.skipType(tag & 7);
|
8313
|
+
}
|
8314
|
+
return message;
|
8315
|
+
},
|
8316
|
+
|
8317
|
+
fromJSON(object: any): ProcessStreamResponse_Partitions {
|
8318
|
+
return {
|
8319
|
+
partitions: isObject(object.partitions)
|
8320
|
+
? Object.entries(object.partitions).reduce<{ [key: number]: ProcessStreamResponse_Partitions_Partition }>(
|
8321
|
+
(acc, [key, value]) => {
|
8322
|
+
acc[globalThis.Number(key)] = ProcessStreamResponse_Partitions_Partition.fromJSON(value);
|
8323
|
+
return acc;
|
8324
|
+
},
|
8325
|
+
{},
|
8326
|
+
)
|
8327
|
+
: {},
|
8328
|
+
};
|
8329
|
+
},
|
8330
|
+
|
8331
|
+
toJSON(message: ProcessStreamResponse_Partitions): unknown {
|
8332
|
+
const obj: any = {};
|
8333
|
+
if (message.partitions) {
|
8334
|
+
const entries = Object.entries(message.partitions);
|
8335
|
+
if (entries.length > 0) {
|
8336
|
+
obj.partitions = {};
|
8337
|
+
entries.forEach(([k, v]) => {
|
8338
|
+
obj.partitions[k] = ProcessStreamResponse_Partitions_Partition.toJSON(v);
|
8339
|
+
});
|
8340
|
+
}
|
8341
|
+
}
|
8342
|
+
return obj;
|
8343
|
+
},
|
8344
|
+
|
8345
|
+
create(base?: DeepPartial<ProcessStreamResponse_Partitions>): ProcessStreamResponse_Partitions {
|
8346
|
+
return ProcessStreamResponse_Partitions.fromPartial(base ?? {});
|
8347
|
+
},
|
8348
|
+
fromPartial(object: DeepPartial<ProcessStreamResponse_Partitions>): ProcessStreamResponse_Partitions {
|
8349
|
+
const message = createBaseProcessStreamResponse_Partitions();
|
8350
|
+
message.partitions = Object.entries(object.partitions ?? {}).reduce<
|
8351
|
+
{ [key: number]: ProcessStreamResponse_Partitions_Partition }
|
8352
|
+
>((acc, [key, value]) => {
|
8353
|
+
if (value !== undefined) {
|
8354
|
+
acc[globalThis.Number(key)] = ProcessStreamResponse_Partitions_Partition.fromPartial(value);
|
8355
|
+
}
|
8356
|
+
return acc;
|
8357
|
+
}, {});
|
8358
|
+
return message;
|
8359
|
+
},
|
8360
|
+
};
|
8361
|
+
|
8362
|
+
function createBaseProcessStreamResponse_Partitions_Partition(): ProcessStreamResponse_Partitions_Partition {
|
8363
|
+
return { userValue: undefined, sysValue: undefined };
|
8364
|
+
}
|
8365
|
+
|
8366
|
+
export const ProcessStreamResponse_Partitions_Partition = {
|
8367
|
+
encode(message: ProcessStreamResponse_Partitions_Partition, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
8368
|
+
if (message.userValue !== undefined) {
|
8369
|
+
writer.uint32(10).string(message.userValue);
|
8370
|
+
}
|
8371
|
+
if (message.sysValue !== undefined) {
|
8372
|
+
writer.uint32(16).int32(message.sysValue);
|
8373
|
+
}
|
8374
|
+
return writer;
|
8375
|
+
},
|
8376
|
+
|
8377
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): ProcessStreamResponse_Partitions_Partition {
|
8378
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
8379
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
8380
|
+
const message = createBaseProcessStreamResponse_Partitions_Partition();
|
8381
|
+
while (reader.pos < end) {
|
8382
|
+
const tag = reader.uint32();
|
8383
|
+
switch (tag >>> 3) {
|
8384
|
+
case 1:
|
8385
|
+
if (tag !== 10) {
|
8386
|
+
break;
|
8387
|
+
}
|
8388
|
+
|
8389
|
+
message.userValue = reader.string();
|
8390
|
+
continue;
|
8391
|
+
case 2:
|
8392
|
+
if (tag !== 16) {
|
8393
|
+
break;
|
8394
|
+
}
|
8395
|
+
|
8396
|
+
message.sysValue = reader.int32() as any;
|
8397
|
+
continue;
|
8398
|
+
}
|
8399
|
+
if ((tag & 7) === 4 || tag === 0) {
|
8400
|
+
break;
|
8401
|
+
}
|
8402
|
+
reader.skipType(tag & 7);
|
8403
|
+
}
|
8404
|
+
return message;
|
8405
|
+
},
|
8406
|
+
|
8407
|
+
fromJSON(object: any): ProcessStreamResponse_Partitions_Partition {
|
8408
|
+
return {
|
8409
|
+
userValue: isSet(object.userValue) ? globalThis.String(object.userValue) : undefined,
|
8410
|
+
sysValue: isSet(object.sysValue)
|
8411
|
+
? processStreamResponse_Partitions_Partition_SysValueFromJSON(object.sysValue)
|
8412
|
+
: undefined,
|
8413
|
+
};
|
8414
|
+
},
|
8415
|
+
|
8416
|
+
toJSON(message: ProcessStreamResponse_Partitions_Partition): unknown {
|
8417
|
+
const obj: any = {};
|
8418
|
+
if (message.userValue !== undefined) {
|
8419
|
+
obj.userValue = message.userValue;
|
8420
|
+
}
|
8421
|
+
if (message.sysValue !== undefined) {
|
8422
|
+
obj.sysValue = processStreamResponse_Partitions_Partition_SysValueToJSON(message.sysValue);
|
8423
|
+
}
|
8424
|
+
return obj;
|
8425
|
+
},
|
8426
|
+
|
8427
|
+
create(base?: DeepPartial<ProcessStreamResponse_Partitions_Partition>): ProcessStreamResponse_Partitions_Partition {
|
8428
|
+
return ProcessStreamResponse_Partitions_Partition.fromPartial(base ?? {});
|
8429
|
+
},
|
8430
|
+
fromPartial(
|
8431
|
+
object: DeepPartial<ProcessStreamResponse_Partitions_Partition>,
|
8432
|
+
): ProcessStreamResponse_Partitions_Partition {
|
8433
|
+
const message = createBaseProcessStreamResponse_Partitions_Partition();
|
8434
|
+
message.userValue = object.userValue ?? undefined;
|
8435
|
+
message.sysValue = object.sysValue ?? undefined;
|
8436
|
+
return message;
|
8437
|
+
},
|
8438
|
+
};
|
8439
|
+
|
8440
|
+
function createBaseProcessStreamResponse_Partitions_PartitionsEntry(): ProcessStreamResponse_Partitions_PartitionsEntry {
|
8441
|
+
return { key: 0, value: undefined };
|
8442
|
+
}
|
8443
|
+
|
8444
|
+
export const ProcessStreamResponse_Partitions_PartitionsEntry = {
|
8445
|
+
encode(
|
8446
|
+
message: ProcessStreamResponse_Partitions_PartitionsEntry,
|
8447
|
+
writer: _m0.Writer = _m0.Writer.create(),
|
8448
|
+
): _m0.Writer {
|
8449
|
+
if (message.key !== 0) {
|
8450
|
+
writer.uint32(8).int32(message.key);
|
8451
|
+
}
|
8452
|
+
if (message.value !== undefined) {
|
8453
|
+
ProcessStreamResponse_Partitions_Partition.encode(message.value, writer.uint32(18).fork()).ldelim();
|
8454
|
+
}
|
8455
|
+
return writer;
|
8456
|
+
},
|
8457
|
+
|
8458
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): ProcessStreamResponse_Partitions_PartitionsEntry {
|
8459
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
8460
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
8461
|
+
const message = createBaseProcessStreamResponse_Partitions_PartitionsEntry();
|
8462
|
+
while (reader.pos < end) {
|
8463
|
+
const tag = reader.uint32();
|
8464
|
+
switch (tag >>> 3) {
|
8465
|
+
case 1:
|
8466
|
+
if (tag !== 8) {
|
8467
|
+
break;
|
8468
|
+
}
|
8469
|
+
|
8470
|
+
message.key = reader.int32();
|
8471
|
+
continue;
|
8472
|
+
case 2:
|
8473
|
+
if (tag !== 18) {
|
8474
|
+
break;
|
8475
|
+
}
|
8476
|
+
|
8477
|
+
message.value = ProcessStreamResponse_Partitions_Partition.decode(reader, reader.uint32());
|
8478
|
+
continue;
|
8479
|
+
}
|
8480
|
+
if ((tag & 7) === 4 || tag === 0) {
|
8481
|
+
break;
|
8482
|
+
}
|
8483
|
+
reader.skipType(tag & 7);
|
8484
|
+
}
|
8485
|
+
return message;
|
8486
|
+
},
|
8487
|
+
|
8488
|
+
fromJSON(object: any): ProcessStreamResponse_Partitions_PartitionsEntry {
|
8489
|
+
return {
|
8490
|
+
key: isSet(object.key) ? globalThis.Number(object.key) : 0,
|
8491
|
+
value: isSet(object.value) ? ProcessStreamResponse_Partitions_Partition.fromJSON(object.value) : undefined,
|
8492
|
+
};
|
8493
|
+
},
|
8494
|
+
|
8495
|
+
toJSON(message: ProcessStreamResponse_Partitions_PartitionsEntry): unknown {
|
8496
|
+
const obj: any = {};
|
8497
|
+
if (message.key !== 0) {
|
8498
|
+
obj.key = Math.round(message.key);
|
8499
|
+
}
|
8500
|
+
if (message.value !== undefined) {
|
8501
|
+
obj.value = ProcessStreamResponse_Partitions_Partition.toJSON(message.value);
|
8502
|
+
}
|
8503
|
+
return obj;
|
8504
|
+
},
|
8505
|
+
|
8506
|
+
create(
|
8507
|
+
base?: DeepPartial<ProcessStreamResponse_Partitions_PartitionsEntry>,
|
8508
|
+
): ProcessStreamResponse_Partitions_PartitionsEntry {
|
8509
|
+
return ProcessStreamResponse_Partitions_PartitionsEntry.fromPartial(base ?? {});
|
8510
|
+
},
|
8511
|
+
fromPartial(
|
8512
|
+
object: DeepPartial<ProcessStreamResponse_Partitions_PartitionsEntry>,
|
8513
|
+
): ProcessStreamResponse_Partitions_PartitionsEntry {
|
8514
|
+
const message = createBaseProcessStreamResponse_Partitions_PartitionsEntry();
|
8515
|
+
message.key = object.key ?? 0;
|
8516
|
+
message.value = (object.value !== undefined && object.value !== null)
|
8517
|
+
? ProcessStreamResponse_Partitions_Partition.fromPartial(object.value)
|
8518
|
+
: undefined;
|
8183
8519
|
return message;
|
8184
8520
|
},
|
8185
8521
|
};
|
package/src/plugin.ts
CHANGED
@@ -5,6 +5,8 @@ import {
|
|
5
5
|
PreprocessResult,
|
6
6
|
ProcessConfigResponse,
|
7
7
|
ProcessResult,
|
8
|
+
ProcessStreamResponse_Partitions,
|
9
|
+
ProcessStreamResponse_Partitions_Partition_SysValue,
|
8
10
|
StartRequest
|
9
11
|
} from '@sentio/protos'
|
10
12
|
import { IStoreContext, StoreContext } from './db-context.js'
|
@@ -33,6 +35,20 @@ export abstract class Plugin {
|
|
33
35
|
return PreprocessResult.create()
|
34
36
|
}
|
35
37
|
|
38
|
+
async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {
|
39
|
+
return {
|
40
|
+
partitions: request.handlerIds.reduce(
|
41
|
+
(acc, id) => ({
|
42
|
+
...acc,
|
43
|
+
[id]: {
|
44
|
+
sysValue: ProcessStreamResponse_Partitions_Partition_SysValue.UNRECOGNIZED
|
45
|
+
}
|
46
|
+
}),
|
47
|
+
{}
|
48
|
+
)
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
36
52
|
/**
|
37
53
|
* method used by action server only
|
38
54
|
* @param port
|
@@ -104,6 +120,14 @@ export class PluginManager {
|
|
104
120
|
})
|
105
121
|
}
|
106
122
|
|
123
|
+
async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {
|
124
|
+
const plugin = this.typesToPlugin.get(request.handlerType)
|
125
|
+
if (!plugin) {
|
126
|
+
throw new Error(`No plugin for ${request.handlerType}`)
|
127
|
+
}
|
128
|
+
return plugin.partition(request)
|
129
|
+
}
|
130
|
+
|
107
131
|
preprocessBinding(
|
108
132
|
request: DataBinding,
|
109
133
|
preprocessStore: { [k: string]: any },
|
package/src/service-manager.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CallContext } from 'nice-grpc'
|
1
|
+
import { CallContext, ServerError, Status } from 'nice-grpc'
|
2
2
|
import { Piscina } from 'piscina'
|
3
3
|
import {
|
4
4
|
DataBinding,
|
@@ -22,6 +22,7 @@ import { processMetrics } from './metrics.js'
|
|
22
22
|
import { MessageChannel } from 'node:worker_threads'
|
23
23
|
import { ProcessorServiceImpl } from './service.js'
|
24
24
|
import { TemplateInstanceState } from './state.js'
|
25
|
+
import { PluginManager } from './plugin.js'
|
25
26
|
|
26
27
|
const { process_binding_count, process_binding_time, process_binding_error } = processMetrics
|
27
28
|
|
@@ -70,17 +71,6 @@ export class ServiceManager extends ProcessorServiceImpl {
|
|
70
71
|
return await super.stop(request, context)
|
71
72
|
}
|
72
73
|
|
73
|
-
async process(request: DataBinding, dbContext?: ChannelStoreContext): Promise<ProcessResult> {
|
74
|
-
if (!this.pool) {
|
75
|
-
await this.initPool()
|
76
|
-
}
|
77
|
-
|
78
|
-
return this.pool.run(
|
79
|
-
{ request, workerPort: dbContext?.workerPort },
|
80
|
-
{ transferList: dbContext?.workerPort ? [dbContext?.workerPort] : [] }
|
81
|
-
)
|
82
|
-
}
|
83
|
-
|
84
74
|
private readonly contexts = new Contexts()
|
85
75
|
|
86
76
|
protected async handleRequests(
|
@@ -88,6 +78,8 @@ export class ServiceManager extends ProcessorServiceImpl {
|
|
88
78
|
subject: Subject<DeepPartial<ProcessStreamResponse>>
|
89
79
|
) {
|
90
80
|
for await (const request of requests) {
|
81
|
+
let lastBinding: DataBinding | undefined = undefined
|
82
|
+
|
91
83
|
try {
|
92
84
|
// console.debug('received request:', request)
|
93
85
|
if (request.binding) {
|
@@ -103,27 +95,22 @@ export class ServiceManager extends ProcessorServiceImpl {
|
|
103
95
|
continue
|
104
96
|
}
|
105
97
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
this.process(binding, dbContext)
|
112
|
-
.then(async (result) => {
|
113
|
-
subject.next({
|
114
|
-
result,
|
115
|
-
processId: request.processId
|
116
|
-
})
|
117
|
-
})
|
118
|
-
.catch((e) => {
|
119
|
-
dbContext.error(request.processId, e)
|
120
|
-
process_binding_error.add(1)
|
121
|
-
})
|
122
|
-
.finally(() => {
|
123
|
-
const cost = Date.now() - start
|
124
|
-
process_binding_time.add(cost)
|
125
|
-
this.contexts.delete(request.processId)
|
98
|
+
if (this.enablePartition) {
|
99
|
+
const partitions = await PluginManager.INSTANCE.partition(request.binding)
|
100
|
+
subject.next({
|
101
|
+
processId: request.processId,
|
102
|
+
partitions
|
126
103
|
})
|
104
|
+
lastBinding = request.binding
|
105
|
+
} else {
|
106
|
+
this.doProcess(request.processId, request.binding, subject)
|
107
|
+
}
|
108
|
+
}
|
109
|
+
if (request.start) {
|
110
|
+
if (!lastBinding) {
|
111
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'start request received without binding')
|
112
|
+
}
|
113
|
+
this.doProcess(request.processId, lastBinding, subject)
|
127
114
|
}
|
128
115
|
if (request.dbResult) {
|
129
116
|
const dbContext = this.contexts.get(request.processId)
|
@@ -140,6 +127,39 @@ export class ServiceManager extends ProcessorServiceImpl {
|
|
140
127
|
}
|
141
128
|
}
|
142
129
|
|
130
|
+
private doProcess(processId: number, binding: DataBinding, subject: Subject<DeepPartial<ProcessStreamResponse>>) {
|
131
|
+
const dbContext = this.contexts.new(processId, subject)
|
132
|
+
|
133
|
+
const start = Date.now()
|
134
|
+
this.process(binding, dbContext)
|
135
|
+
.then(async (result) => {
|
136
|
+
subject.next({
|
137
|
+
result,
|
138
|
+
processId: processId
|
139
|
+
})
|
140
|
+
})
|
141
|
+
.catch((e) => {
|
142
|
+
dbContext.error(processId, e)
|
143
|
+
process_binding_error.add(1)
|
144
|
+
})
|
145
|
+
.finally(() => {
|
146
|
+
const cost = Date.now() - start
|
147
|
+
process_binding_time.add(cost)
|
148
|
+
this.contexts.delete(processId)
|
149
|
+
})
|
150
|
+
}
|
151
|
+
|
152
|
+
async process(request: DataBinding, dbContext?: ChannelStoreContext): Promise<ProcessResult> {
|
153
|
+
if (!this.pool) {
|
154
|
+
await this.initPool()
|
155
|
+
}
|
156
|
+
|
157
|
+
return this.pool.run(
|
158
|
+
{ request, workerPort: dbContext?.workerPort },
|
159
|
+
{ transferList: dbContext?.workerPort ? [dbContext?.workerPort] : [] }
|
160
|
+
)
|
161
|
+
}
|
162
|
+
|
143
163
|
private async initPool() {
|
144
164
|
if (this.pool) {
|
145
165
|
await this.pool.close()
|