@hotmeshio/hotmesh 0.4.0 → 0.4.1
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/build/modules/enums.d.ts +110 -0
- package/build/modules/enums.js +134 -0
- package/build/modules/errors.d.ts +124 -0
- package/build/modules/errors.js +191 -0
- package/build/modules/key.d.ts +66 -0
- package/build/modules/key.js +190 -0
- package/build/modules/storage.d.ts +3 -0
- package/build/modules/storage.js +5 -0
- package/build/modules/utils.d.ts +119 -0
- package/build/modules/utils.js +374 -0
- package/build/package.json +1 -1
- package/build/services/activities/activity.d.ts +104 -0
- package/build/services/activities/activity.js +549 -0
- package/build/services/activities/await.d.ts +12 -0
- package/build/services/activities/await.js +114 -0
- package/build/services/activities/cycle.d.ts +19 -0
- package/build/services/activities/cycle.js +112 -0
- package/build/services/activities/hook.d.ts +27 -0
- package/build/services/activities/hook.js +168 -0
- package/build/services/activities/index.d.ts +19 -0
- package/build/services/activities/index.js +20 -0
- package/build/services/activities/interrupt.d.ts +16 -0
- package/build/services/activities/interrupt.js +158 -0
- package/build/services/activities/signal.d.ts +20 -0
- package/build/services/activities/signal.js +134 -0
- package/build/services/activities/trigger.d.ts +37 -0
- package/build/services/activities/trigger.js +246 -0
- package/build/services/activities/worker.d.ts +12 -0
- package/build/services/activities/worker.js +106 -0
- package/build/services/collator/index.d.ts +111 -0
- package/build/services/collator/index.js +293 -0
- package/build/services/compiler/deployer.d.ts +40 -0
- package/build/services/compiler/deployer.js +488 -0
- package/build/services/compiler/index.d.ts +32 -0
- package/build/services/compiler/index.js +112 -0
- package/build/services/compiler/validator.d.ts +34 -0
- package/build/services/compiler/validator.js +147 -0
- package/build/services/connector/factory.d.ts +22 -0
- package/build/services/connector/factory.js +99 -0
- package/build/services/connector/index.d.ts +30 -0
- package/build/services/connector/index.js +54 -0
- package/build/services/connector/providers/ioredis.d.ts +9 -0
- package/build/services/connector/providers/ioredis.js +26 -0
- package/build/services/connector/providers/nats.d.ts +9 -0
- package/build/services/connector/providers/nats.js +34 -0
- package/build/services/connector/providers/postgres.d.ts +20 -0
- package/build/services/connector/providers/postgres.js +102 -0
- package/build/services/connector/providers/redis.d.ts +9 -0
- package/build/services/connector/providers/redis.js +38 -0
- package/build/services/engine/index.d.ts +264 -0
- package/build/services/engine/index.js +761 -0
- package/build/services/exporter/index.d.ts +44 -0
- package/build/services/exporter/index.js +126 -0
- package/build/services/hotmesh/index.d.ts +483 -0
- package/build/services/hotmesh/index.js +622 -0
- package/build/services/logger/index.d.ts +16 -0
- package/build/services/logger/index.js +54 -0
- package/build/services/mapper/index.d.ts +28 -0
- package/build/services/mapper/index.js +81 -0
- package/build/services/memflow/client.d.ts +108 -0
- package/build/services/memflow/client.js +372 -0
- package/build/services/memflow/connection.d.ts +23 -0
- package/build/services/memflow/connection.js +33 -0
- package/build/services/memflow/context.d.ts +143 -0
- package/build/services/memflow/context.js +299 -0
- package/build/services/memflow/exporter.d.ts +51 -0
- package/build/services/memflow/exporter.js +215 -0
- package/build/services/memflow/handle.d.ts +90 -0
- package/build/services/memflow/handle.js +176 -0
- package/build/services/memflow/index.d.ts +116 -0
- package/build/services/memflow/index.js +122 -0
- package/build/services/memflow/schemas/factory.d.ts +29 -0
- package/build/services/memflow/schemas/factory.js +2492 -0
- package/build/services/memflow/search.d.ts +142 -0
- package/build/services/memflow/search.js +320 -0
- package/build/services/memflow/worker.d.ts +124 -0
- package/build/services/memflow/worker.js +514 -0
- package/build/services/memflow/workflow/all.d.ts +7 -0
- package/build/services/memflow/workflow/all.js +15 -0
- package/build/services/memflow/workflow/common.d.ts +20 -0
- package/build/services/memflow/workflow/common.js +47 -0
- package/build/services/memflow/workflow/context.d.ts +6 -0
- package/build/services/memflow/workflow/context.js +45 -0
- package/build/services/memflow/workflow/contextMethods.d.ts +14 -0
- package/build/services/memflow/workflow/contextMethods.js +33 -0
- package/build/services/memflow/workflow/didRun.d.ts +7 -0
- package/build/services/memflow/workflow/didRun.js +22 -0
- package/build/services/memflow/workflow/emit.d.ts +11 -0
- package/build/services/memflow/workflow/emit.js +29 -0
- package/build/services/memflow/workflow/enrich.d.ts +9 -0
- package/build/services/memflow/workflow/enrich.js +17 -0
- package/build/services/memflow/workflow/execChild.d.ts +18 -0
- package/build/services/memflow/workflow/execChild.js +102 -0
- package/build/services/memflow/workflow/execHook.d.ts +65 -0
- package/build/services/memflow/workflow/execHook.js +73 -0
- package/build/services/memflow/workflow/hook.d.ts +9 -0
- package/build/services/memflow/workflow/hook.js +56 -0
- package/build/services/memflow/workflow/index.d.ts +74 -0
- package/build/services/memflow/workflow/index.js +87 -0
- package/build/services/memflow/workflow/interrupt.d.ts +9 -0
- package/build/services/memflow/workflow/interrupt.js +24 -0
- package/build/services/memflow/workflow/isSideEffectAllowed.d.ts +10 -0
- package/build/services/memflow/workflow/isSideEffectAllowed.js +33 -0
- package/build/services/memflow/workflow/proxyActivities.d.ts +20 -0
- package/build/services/memflow/workflow/proxyActivities.js +97 -0
- package/build/services/memflow/workflow/random.d.ts +6 -0
- package/build/services/memflow/workflow/random.js +16 -0
- package/build/services/memflow/workflow/searchMethods.d.ts +6 -0
- package/build/services/memflow/workflow/searchMethods.js +25 -0
- package/build/services/memflow/workflow/signal.d.ts +7 -0
- package/build/services/memflow/workflow/signal.js +28 -0
- package/build/services/memflow/workflow/sleepFor.d.ts +8 -0
- package/build/services/memflow/workflow/sleepFor.js +35 -0
- package/build/services/memflow/workflow/trace.d.ts +14 -0
- package/build/services/memflow/workflow/trace.js +33 -0
- package/build/services/memflow/workflow/waitFor.d.ts +8 -0
- package/build/services/memflow/workflow/waitFor.js +35 -0
- package/build/services/meshcall/index.d.ts +194 -0
- package/build/services/meshcall/index.js +452 -0
- package/build/services/meshcall/schemas/factory.d.ts +9 -0
- package/build/services/meshcall/schemas/factory.js +189 -0
- package/build/services/meshdata/index.d.ts +795 -0
- package/build/services/meshdata/index.js +1235 -0
- package/build/services/meshos/index.d.ts +293 -0
- package/build/services/meshos/index.js +547 -0
- package/build/services/pipe/functions/array.d.ts +17 -0
- package/build/services/pipe/functions/array.js +74 -0
- package/build/services/pipe/functions/bitwise.d.ts +9 -0
- package/build/services/pipe/functions/bitwise.js +24 -0
- package/build/services/pipe/functions/conditional.d.ts +13 -0
- package/build/services/pipe/functions/conditional.js +36 -0
- package/build/services/pipe/functions/cron.d.ts +12 -0
- package/build/services/pipe/functions/cron.js +40 -0
- package/build/services/pipe/functions/date.d.ts +58 -0
- package/build/services/pipe/functions/date.js +171 -0
- package/build/services/pipe/functions/index.d.ts +29 -0
- package/build/services/pipe/functions/index.js +30 -0
- package/build/services/pipe/functions/json.d.ts +5 -0
- package/build/services/pipe/functions/json.js +12 -0
- package/build/services/pipe/functions/logical.d.ts +5 -0
- package/build/services/pipe/functions/logical.js +12 -0
- package/build/services/pipe/functions/math.d.ts +42 -0
- package/build/services/pipe/functions/math.js +184 -0
- package/build/services/pipe/functions/number.d.ts +21 -0
- package/build/services/pipe/functions/number.js +60 -0
- package/build/services/pipe/functions/object.d.ts +25 -0
- package/build/services/pipe/functions/object.js +81 -0
- package/build/services/pipe/functions/string.d.ts +23 -0
- package/build/services/pipe/functions/string.js +69 -0
- package/build/services/pipe/functions/symbol.d.ts +12 -0
- package/build/services/pipe/functions/symbol.js +33 -0
- package/build/services/pipe/functions/unary.d.ts +7 -0
- package/build/services/pipe/functions/unary.js +18 -0
- package/build/services/pipe/index.d.ts +48 -0
- package/build/services/pipe/index.js +242 -0
- package/build/services/quorum/index.d.ts +90 -0
- package/build/services/quorum/index.js +263 -0
- package/build/services/reporter/index.d.ts +50 -0
- package/build/services/reporter/index.js +348 -0
- package/build/services/router/config/index.d.ts +11 -0
- package/build/services/router/config/index.js +36 -0
- package/build/services/router/consumption/index.d.ts +34 -0
- package/build/services/router/consumption/index.js +395 -0
- package/build/services/router/error-handling/index.d.ts +8 -0
- package/build/services/router/error-handling/index.js +98 -0
- package/build/services/router/index.d.ts +57 -0
- package/build/services/router/index.js +121 -0
- package/build/services/router/lifecycle/index.d.ts +27 -0
- package/build/services/router/lifecycle/index.js +80 -0
- package/build/services/router/telemetry/index.d.ts +11 -0
- package/build/services/router/telemetry/index.js +32 -0
- package/build/services/router/throttling/index.d.ts +23 -0
- package/build/services/router/throttling/index.js +76 -0
- package/build/services/search/factory.d.ts +7 -0
- package/build/services/search/factory.js +24 -0
- package/build/services/search/index.d.ts +23 -0
- package/build/services/search/index.js +10 -0
- package/build/services/search/providers/postgres/postgres.d.ts +25 -0
- package/build/services/search/providers/postgres/postgres.js +149 -0
- package/build/services/search/providers/redis/ioredis.d.ts +19 -0
- package/build/services/search/providers/redis/ioredis.js +121 -0
- package/build/services/search/providers/redis/redis.d.ts +19 -0
- package/build/services/search/providers/redis/redis.js +134 -0
- package/build/services/serializer/index.d.ts +42 -0
- package/build/services/serializer/index.js +282 -0
- package/build/services/store/cache.d.ts +67 -0
- package/build/services/store/cache.js +128 -0
- package/build/services/store/factory.d.ts +8 -0
- package/build/services/store/factory.js +24 -0
- package/build/services/store/index.d.ts +89 -0
- package/build/services/store/index.js +9 -0
- package/build/services/store/providers/postgres/kvsql.d.ts +168 -0
- package/build/services/store/providers/postgres/kvsql.js +198 -0
- package/build/services/store/providers/postgres/kvtables.d.ts +20 -0
- package/build/services/store/providers/postgres/kvtables.js +441 -0
- package/build/services/store/providers/postgres/kvtransaction.d.ts +36 -0
- package/build/services/store/providers/postgres/kvtransaction.js +248 -0
- package/build/services/store/providers/postgres/kvtypes/hash.d.ts +60 -0
- package/build/services/store/providers/postgres/kvtypes/hash.js +1287 -0
- package/build/services/store/providers/postgres/kvtypes/list.d.ts +33 -0
- package/build/services/store/providers/postgres/kvtypes/list.js +194 -0
- package/build/services/store/providers/postgres/kvtypes/string.d.ts +20 -0
- package/build/services/store/providers/postgres/kvtypes/string.js +115 -0
- package/build/services/store/providers/postgres/kvtypes/zset.d.ts +41 -0
- package/build/services/store/providers/postgres/kvtypes/zset.js +214 -0
- package/build/services/store/providers/postgres/postgres.d.ts +145 -0
- package/build/services/store/providers/postgres/postgres.js +1036 -0
- package/build/services/store/providers/redis/_base.d.ts +137 -0
- package/build/services/store/providers/redis/_base.js +980 -0
- package/build/services/store/providers/redis/ioredis.d.ts +20 -0
- package/build/services/store/providers/redis/ioredis.js +180 -0
- package/build/services/store/providers/redis/redis.d.ts +18 -0
- package/build/services/store/providers/redis/redis.js +199 -0
- package/build/services/store/providers/store-initializable.d.ts +5 -0
- package/build/services/store/providers/store-initializable.js +2 -0
- package/build/services/stream/factory.d.ts +8 -0
- package/build/services/stream/factory.js +37 -0
- package/build/services/stream/index.d.ts +69 -0
- package/build/services/stream/index.js +11 -0
- package/build/services/stream/providers/nats/nats.d.ts +60 -0
- package/build/services/stream/providers/nats/nats.js +225 -0
- package/build/services/stream/providers/postgres/kvtables.d.ts +3 -0
- package/build/services/stream/providers/postgres/kvtables.js +146 -0
- package/build/services/stream/providers/postgres/postgres.d.ts +107 -0
- package/build/services/stream/providers/postgres/postgres.js +519 -0
- package/build/services/stream/providers/redis/ioredis.d.ts +61 -0
- package/build/services/stream/providers/redis/ioredis.js +272 -0
- package/build/services/stream/providers/redis/redis.d.ts +61 -0
- package/build/services/stream/providers/redis/redis.js +305 -0
- package/build/services/stream/providers/stream-initializable.d.ts +4 -0
- package/build/services/stream/providers/stream-initializable.js +2 -0
- package/build/services/sub/factory.d.ts +7 -0
- package/build/services/sub/factory.js +29 -0
- package/build/services/sub/index.d.ts +22 -0
- package/build/services/sub/index.js +10 -0
- package/build/services/sub/providers/nats/nats.d.ts +19 -0
- package/build/services/sub/providers/nats/nats.js +105 -0
- package/build/services/sub/providers/postgres/postgres.d.ts +19 -0
- package/build/services/sub/providers/postgres/postgres.js +92 -0
- package/build/services/sub/providers/redis/ioredis.d.ts +17 -0
- package/build/services/sub/providers/redis/ioredis.js +81 -0
- package/build/services/sub/providers/redis/redis.d.ts +17 -0
- package/build/services/sub/providers/redis/redis.js +72 -0
- package/build/services/task/index.d.ts +36 -0
- package/build/services/task/index.js +206 -0
- package/build/services/telemetry/index.d.ts +52 -0
- package/build/services/telemetry/index.js +306 -0
- package/build/services/worker/index.d.ts +77 -0
- package/build/services/worker/index.js +197 -0
- package/package.json +1 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/typedoc.json +0 -47
- package/types/activity.ts +0 -268
- package/types/app.ts +0 -20
- package/types/async.ts +0 -6
- package/types/cache.ts +0 -1
- package/types/collator.ts +0 -9
- package/types/error.ts +0 -56
- package/types/exporter.ts +0 -102
- package/types/hook.ts +0 -44
- package/types/hotmesh.ts +0 -314
- package/types/index.ts +0 -306
- package/types/job.ts +0 -233
- package/types/logger.ts +0 -8
- package/types/manifest.ts +0 -70
- package/types/map.ts +0 -5
- package/types/memflow.ts +0 -645
- package/types/meshcall.ts +0 -235
- package/types/meshdata.ts +0 -278
- package/types/ms.d.ts +0 -7
- package/types/nats.ts +0 -270
- package/types/pipe.ts +0 -90
- package/types/postgres.ts +0 -114
- package/types/provider.ts +0 -161
- package/types/quorum.ts +0 -167
- package/types/redis.ts +0 -404
- package/types/serializer.ts +0 -40
- package/types/stats.ts +0 -117
- package/types/stream.ts +0 -231
- package/types/task.ts +0 -7
- package/types/telemetry.ts +0 -16
- package/types/transition.ts +0 -20
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkerService = void 0;
|
|
4
|
+
const key_1 = require("../../modules/key");
|
|
5
|
+
const utils_1 = require("../../modules/utils");
|
|
6
|
+
const factory_1 = require("../connector/factory");
|
|
7
|
+
const router_1 = require("../router");
|
|
8
|
+
const stream_1 = require("../../types/stream");
|
|
9
|
+
const enums_1 = require("../../modules/enums");
|
|
10
|
+
const factory_2 = require("../stream/factory");
|
|
11
|
+
const factory_3 = require("../sub/factory");
|
|
12
|
+
const factory_4 = require("../store/factory");
|
|
13
|
+
class WorkerService {
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
constructor() {
|
|
18
|
+
this.reporting = false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
static async init(namespace, appId, guid, config, logger) {
|
|
24
|
+
const services = [];
|
|
25
|
+
if (Array.isArray(config.workers)) {
|
|
26
|
+
for (const worker of config.workers) {
|
|
27
|
+
await factory_1.ConnectorService.initClients(worker);
|
|
28
|
+
const service = new WorkerService();
|
|
29
|
+
service.verifyWorkerFields(worker);
|
|
30
|
+
service.namespace = namespace;
|
|
31
|
+
service.appId = appId;
|
|
32
|
+
service.guid = guid;
|
|
33
|
+
service.callback = worker.callback;
|
|
34
|
+
service.topic = worker.topic;
|
|
35
|
+
service.config = config;
|
|
36
|
+
service.logger = logger;
|
|
37
|
+
await service.initStoreChannel(service, worker.store);
|
|
38
|
+
await service.initSubChannel(service, worker.sub, worker.pub ?? worker.store);
|
|
39
|
+
await service.subscribe.subscribe(key_1.KeyType.QUORUM, service.subscriptionHandler(), appId);
|
|
40
|
+
await service.subscribe.subscribe(key_1.KeyType.QUORUM, service.subscriptionHandler(), appId, service.topic);
|
|
41
|
+
await service.subscribe.subscribe(key_1.KeyType.QUORUM, service.subscriptionHandler(), appId, service.guid);
|
|
42
|
+
await service.initStreamChannel(service, worker.stream, worker.store);
|
|
43
|
+
service.router = await service.initRouter(worker, logger);
|
|
44
|
+
const key = service.store.mintKey(key_1.KeyType.STREAMS, {
|
|
45
|
+
appId: service.appId,
|
|
46
|
+
topic: worker.topic,
|
|
47
|
+
});
|
|
48
|
+
await service.router.consumeMessages(key, 'WORKER', service.guid, worker.callback);
|
|
49
|
+
service.inited = (0, utils_1.formatISODate)(new Date());
|
|
50
|
+
services.push(service);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return services;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
verifyWorkerFields(worker) {
|
|
59
|
+
if (!(0, utils_1.identifyProvider)(worker.store) ||
|
|
60
|
+
!(0, utils_1.identifyProvider)(worker.stream) ||
|
|
61
|
+
!(0, utils_1.identifyProvider)(worker.sub) ||
|
|
62
|
+
!(worker.topic && worker.callback)) {
|
|
63
|
+
throw new Error('worker must include `store`, `stream`, and `sub` fields along with a callback function and topic.');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
async initStoreChannel(service, store) {
|
|
70
|
+
service.store = await factory_4.StoreServiceFactory.init(store, service.namespace, service.appId, service.logger);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
async initSubChannel(service, sub, store) {
|
|
76
|
+
service.subscribe = await factory_3.SubServiceFactory.init(sub, store, service.namespace, service.appId, service.guid, service.logger);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
async initStreamChannel(service, stream, store) {
|
|
82
|
+
service.stream = await factory_2.StreamServiceFactory.init(stream, store, service.namespace, service.appId, service.logger);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
async initRouter(worker, logger) {
|
|
88
|
+
const throttle = await this.store.getThrottleRate(worker.topic);
|
|
89
|
+
return new router_1.Router({
|
|
90
|
+
namespace: this.namespace,
|
|
91
|
+
appId: this.appId,
|
|
92
|
+
guid: this.guid,
|
|
93
|
+
role: stream_1.StreamRole.WORKER,
|
|
94
|
+
topic: worker.topic,
|
|
95
|
+
reclaimDelay: worker.reclaimDelay,
|
|
96
|
+
reclaimCount: worker.reclaimCount,
|
|
97
|
+
throttle,
|
|
98
|
+
}, this.stream, logger);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
subscriptionHandler() {
|
|
104
|
+
const self = this;
|
|
105
|
+
return async (topic, message) => {
|
|
106
|
+
self.logger.debug('worker-event-received', { topic, type: message.type });
|
|
107
|
+
if (message.type === 'throttle') {
|
|
108
|
+
if (message.topic !== null) {
|
|
109
|
+
//undefined allows passthrough
|
|
110
|
+
self.throttle(message.throttle);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (message.type === 'ping') {
|
|
114
|
+
self.sayPong(self.appId, self.guid, message.originator, message.details);
|
|
115
|
+
}
|
|
116
|
+
else if (message.type === 'rollcall') {
|
|
117
|
+
if (message.topic !== null) {
|
|
118
|
+
//undefined allows passthrough
|
|
119
|
+
self.doRollCall(message);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A quorum-wide command to broadcaset system details.
|
|
126
|
+
*
|
|
127
|
+
*/
|
|
128
|
+
async doRollCall(message) {
|
|
129
|
+
let iteration = 0;
|
|
130
|
+
const max = !isNaN(message.max) ? message.max : enums_1.HMSH_QUORUM_ROLLCALL_CYCLES;
|
|
131
|
+
if (this.rollCallInterval)
|
|
132
|
+
clearTimeout(this.rollCallInterval);
|
|
133
|
+
const base = message.interval / 2;
|
|
134
|
+
const amount = base + Math.ceil(Math.random() * base);
|
|
135
|
+
do {
|
|
136
|
+
await (0, utils_1.sleepFor)(Math.ceil(Math.random() * 1000));
|
|
137
|
+
await this.sayPong(this.appId, this.guid, null, true, message.signature);
|
|
138
|
+
if (!message.interval)
|
|
139
|
+
return;
|
|
140
|
+
const { promise, timerId } = (0, utils_1.XSleepFor)(amount * 1000);
|
|
141
|
+
this.rollCallInterval = timerId;
|
|
142
|
+
await promise;
|
|
143
|
+
} while (this.rollCallInterval && iteration++ < max - 1);
|
|
144
|
+
}
|
|
145
|
+
cancelRollCall() {
|
|
146
|
+
if (this.rollCallInterval) {
|
|
147
|
+
clearTimeout(this.rollCallInterval);
|
|
148
|
+
delete this.rollCallInterval;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @private
|
|
153
|
+
*/
|
|
154
|
+
stop() {
|
|
155
|
+
this.cancelRollCall();
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @private
|
|
159
|
+
*/
|
|
160
|
+
async sayPong(appId, guid, originator, details = false, signature = false) {
|
|
161
|
+
let profile;
|
|
162
|
+
if (details) {
|
|
163
|
+
const params = {
|
|
164
|
+
appId: this.appId,
|
|
165
|
+
topic: this.topic,
|
|
166
|
+
};
|
|
167
|
+
profile = {
|
|
168
|
+
engine_id: this.guid,
|
|
169
|
+
namespace: this.namespace,
|
|
170
|
+
app_id: this.appId,
|
|
171
|
+
worker_topic: this.topic,
|
|
172
|
+
stream: this.store.mintKey(key_1.KeyType.STREAMS, params),
|
|
173
|
+
counts: this.router?.counts,
|
|
174
|
+
timestamp: (0, utils_1.formatISODate)(new Date()),
|
|
175
|
+
inited: this.inited,
|
|
176
|
+
throttle: this.router?.throttle,
|
|
177
|
+
reclaimDelay: this.router?.reclaimDelay,
|
|
178
|
+
reclaimCount: this.router?.reclaimCount,
|
|
179
|
+
system: await (0, utils_1.getSystemHealth)(),
|
|
180
|
+
signature: signature ? this.callback.toString() : undefined,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
this.subscribe.publish(key_1.KeyType.QUORUM, {
|
|
184
|
+
type: 'pong',
|
|
185
|
+
guid,
|
|
186
|
+
originator,
|
|
187
|
+
profile,
|
|
188
|
+
}, appId);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* @private
|
|
192
|
+
*/
|
|
193
|
+
async throttle(delayInMillis) {
|
|
194
|
+
this.router?.setThrottle(delayInMillis);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.WorkerService = WorkerService;
|
package/package.json
CHANGED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Create a report to help us improve
|
|
4
|
-
title: ''
|
|
5
|
-
labels: ''
|
|
6
|
-
assignees: ''
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Describe the bug**
|
|
11
|
-
A clear and concise description of what the bug is.
|
|
12
|
-
|
|
13
|
-
**To Reproduce**
|
|
14
|
-
Steps to reproduce the behavior:
|
|
15
|
-
1. Go to '...'
|
|
16
|
-
2. Click on '....'
|
|
17
|
-
3. Scroll down to '....'
|
|
18
|
-
4. See error
|
|
19
|
-
|
|
20
|
-
**Expected behavior**
|
|
21
|
-
A clear and concise description of what you expected to happen.
|
|
22
|
-
|
|
23
|
-
**Screenshots**
|
|
24
|
-
If applicable, add screenshots to help explain your problem.
|
|
25
|
-
|
|
26
|
-
**Desktop (please complete the following information):**
|
|
27
|
-
- OS: [e.g. iOS]
|
|
28
|
-
- Browser [e.g. chrome, safari]
|
|
29
|
-
- Version [e.g. 22]
|
|
30
|
-
|
|
31
|
-
**Smartphone (please complete the following information):**
|
|
32
|
-
- Device: [e.g. iPhone6]
|
|
33
|
-
- OS: [e.g. iOS8.1]
|
|
34
|
-
- Browser [e.g. stock browser, safari]
|
|
35
|
-
- Version [e.g. 22]
|
|
36
|
-
|
|
37
|
-
**Additional context**
|
|
38
|
-
Add any other context about the problem here.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Feature request
|
|
3
|
-
about: Suggest an idea for this project
|
|
4
|
-
title: ''
|
|
5
|
-
labels: ''
|
|
6
|
-
assignees: ''
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Is your feature request related to a problem? Please describe.**
|
|
11
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
-
|
|
13
|
-
**Describe the solution you'd like**
|
|
14
|
-
A clear and concise description of what you want to happen.
|
|
15
|
-
|
|
16
|
-
**Describe alternatives you've considered**
|
|
17
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
-
|
|
19
|
-
**Additional context**
|
|
20
|
-
Add any other context or screenshots about the feature request here.
|
package/typedoc.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"entryPoints": [
|
|
3
|
-
"modules/enums.ts",
|
|
4
|
-
"modules/errors.ts",
|
|
5
|
-
"modules/key.ts",
|
|
6
|
-
"modules/utils.ts",
|
|
7
|
-
"services/connector/factory.ts",
|
|
8
|
-
"services/connector/index.ts",
|
|
9
|
-
"services/hotmesh/index.ts",
|
|
10
|
-
"services/meshcall/index.ts",
|
|
11
|
-
"services/meshdata/index.ts",
|
|
12
|
-
"services/memflow/index.ts",
|
|
13
|
-
"services/memflow/client.ts",
|
|
14
|
-
"services/memflow/handle.ts",
|
|
15
|
-
"services/memflow/search.ts",
|
|
16
|
-
"services/memflow/context.ts",
|
|
17
|
-
"services/memflow/worker.ts",
|
|
18
|
-
"services/memflow/workflow.ts",
|
|
19
|
-
"services/memflow/connection.ts",
|
|
20
|
-
"services/meshos/index.ts",
|
|
21
|
-
"services/search/index.ts",
|
|
22
|
-
"services/store/index.ts",
|
|
23
|
-
"services/stream/index.ts",
|
|
24
|
-
"services/sub/index.ts",
|
|
25
|
-
"types/*.ts",
|
|
26
|
-
"index.ts"
|
|
27
|
-
],
|
|
28
|
-
"highlightLanguages": [
|
|
29
|
-
"bash",
|
|
30
|
-
"console",
|
|
31
|
-
"css",
|
|
32
|
-
"html",
|
|
33
|
-
"javascript",
|
|
34
|
-
"json",
|
|
35
|
-
"jsonc",
|
|
36
|
-
"json5",
|
|
37
|
-
"tsx",
|
|
38
|
-
"typescript",
|
|
39
|
-
"yaml"
|
|
40
|
-
],
|
|
41
|
-
"exclude": ["types/index.ts"],
|
|
42
|
-
"out": "docs/hotmesh",
|
|
43
|
-
"name": "",
|
|
44
|
-
"excludePrivate": true,
|
|
45
|
-
"theme": "default",
|
|
46
|
-
"customCss": "docs/css/custom.css"
|
|
47
|
-
}
|
package/types/activity.ts
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { MetricTypes } from './stats';
|
|
2
|
-
import { StreamRetryPolicy } from './stream';
|
|
3
|
-
|
|
4
|
-
type ActivityExecutionType =
|
|
5
|
-
| 'trigger'
|
|
6
|
-
| 'await'
|
|
7
|
-
| 'worker'
|
|
8
|
-
| 'activity'
|
|
9
|
-
| 'emit'
|
|
10
|
-
| 'interrupt'
|
|
11
|
-
| 'cycle'
|
|
12
|
-
| 'signal'
|
|
13
|
-
| 'hook';
|
|
14
|
-
|
|
15
|
-
type Consumes = Record<string, string[]>;
|
|
16
|
-
|
|
17
|
-
interface BaseActivity {
|
|
18
|
-
title?: string;
|
|
19
|
-
type?: ActivityExecutionType;
|
|
20
|
-
subtype?: string;
|
|
21
|
-
statusThreshold?: number; //default is 0; set to 1 to ensure not last standing; message will be ignored as if too late to process
|
|
22
|
-
statusThresholdType?: 'stop' | 'throw' | 'stall'; //default is stop; must explicitly set to throw to throw an error or stall to stall
|
|
23
|
-
input?: Record<string, any>;
|
|
24
|
-
output?: Record<string, any>;
|
|
25
|
-
settings?: Record<string, any>;
|
|
26
|
-
job?: Record<string, any>;
|
|
27
|
-
hook?: Record<string, any>;
|
|
28
|
-
telemetry?: Record<string, any>;
|
|
29
|
-
emit?: boolean; //if true, the activity will emit a message to the `publishes` topic immediately before transitioning to adjacent activities
|
|
30
|
-
sleep?: number; //@pipe /in seconds
|
|
31
|
-
expire?: number; //-1 forever; 0 persists the flow until the parent flow that expired it is dismissed; 15 seconds is the default (copied from the YAML at compile time)
|
|
32
|
-
persistent?: boolean; //if true, the job will persist beyond completion (copied from the YAML at compile time)
|
|
33
|
-
persist?: boolean; //when true, the activity will emit the job completed event and start the `persistence countdown`, using the 'expire' value
|
|
34
|
-
retry?: StreamRetryPolicy;
|
|
35
|
-
cycle?: boolean; //if true, the `notary` will leave leg 2 open, so it can be re/cycled
|
|
36
|
-
collationInt?: number; //compiler
|
|
37
|
-
consumes?: Consumes; //compiler
|
|
38
|
-
PRODUCES?: string[]; //compiler
|
|
39
|
-
produces?: string[]; //compiler
|
|
40
|
-
publishes?: string; //compiler
|
|
41
|
-
subscribes?: string; //compiler
|
|
42
|
-
trigger?: string; //compiler
|
|
43
|
-
parent?: string; //compiler
|
|
44
|
-
ancestors?: string[]; //compiler
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface Measure {
|
|
48
|
-
measure: MetricTypes;
|
|
49
|
-
target: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface TriggerActivityStats {
|
|
53
|
-
/**
|
|
54
|
-
* dependent parent job id; including this allows the parent's
|
|
55
|
-
* expiration/interruption events to cascade; set
|
|
56
|
-
* `expire` in the YAML for the dependent graph
|
|
57
|
-
* to 0 and provide the parent for dependent,
|
|
58
|
-
* cascading interruption and cleanup
|
|
59
|
-
*/
|
|
60
|
-
parent?: string;
|
|
61
|
-
/**
|
|
62
|
-
* adjacent parent job id; this is the actual adjacent
|
|
63
|
-
* parent in the graph, but it is not used for cascading expiration
|
|
64
|
-
*/
|
|
65
|
-
adjacent?: string;
|
|
66
|
-
id?: { [key: string]: unknown } | string;
|
|
67
|
-
key?: { [key: string]: unknown } | string;
|
|
68
|
-
/**
|
|
69
|
-
* @deprecated
|
|
70
|
-
* return 'infinity' to disable; default behavior
|
|
71
|
-
* is to always segment keys by time to ensure
|
|
72
|
-
* indexes (Redis LIST) never grow unbounded
|
|
73
|
-
* as a default behavior; for now, 5m is default
|
|
74
|
-
* and infinity can be set to override
|
|
75
|
-
*/
|
|
76
|
-
granularity?: string;
|
|
77
|
-
/**
|
|
78
|
-
* @deprecated
|
|
79
|
-
* what to capture
|
|
80
|
-
*/
|
|
81
|
-
measures?: Measure[];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
interface TriggerActivity extends BaseActivity {
|
|
85
|
-
type: 'trigger';
|
|
86
|
-
stats?: TriggerActivityStats;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
interface AwaitActivity extends BaseActivity {
|
|
90
|
-
type: 'await';
|
|
91
|
-
eventName: string;
|
|
92
|
-
timeout: number;
|
|
93
|
-
await?: boolean; //if exlicitly false do not await the response
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
interface WorkerActivity extends BaseActivity {
|
|
97
|
-
type: 'worker';
|
|
98
|
-
topic: string;
|
|
99
|
-
timeout: number;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
interface CycleActivity extends BaseActivity {
|
|
103
|
-
type: 'cycle';
|
|
104
|
-
ancestor: string; //ancestor activity id
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
interface HookActivity extends BaseActivity {
|
|
108
|
-
type: 'hook';
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
interface SignalActivity extends BaseActivity {
|
|
112
|
-
type: 'signal'; //signal activities call hook/hookAll
|
|
113
|
-
subtype: 'one' | 'all'; //trigger: hook(One) or hookAll
|
|
114
|
-
topic: string; //e.g., 'hook.resume'
|
|
115
|
-
key_name?: string; //e.g., 'parent_job_id'
|
|
116
|
-
key_value?: string; //e.g., '1234567890'
|
|
117
|
-
scrub?: boolean; //if true, the index will be deleted after use
|
|
118
|
-
signal?: Record<string, any>; //used to define/map the signal input data (what to send/singnal into the job(s))
|
|
119
|
-
resolver?: Record<string, any>; //used to define/map the signal key resolver (the key used to lookup the job(s that are assigned to the key)
|
|
120
|
-
status?: string; //pending, success (default), error
|
|
121
|
-
code?: number; //202, 200 (default)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
interface InterruptActivity extends BaseActivity {
|
|
125
|
-
type: 'interrupt';
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Optional Reason; will be used as the error `message` when thrown
|
|
129
|
-
* @default 'Job Interrupted'
|
|
130
|
-
*/
|
|
131
|
-
reason?: string;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* throw JobInterrupted error upon interrupting
|
|
135
|
-
* @default true
|
|
136
|
-
*/
|
|
137
|
-
throw?: boolean;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Interrupt child/descendant jobs
|
|
141
|
-
* @default false
|
|
142
|
-
*/
|
|
143
|
-
descend?: boolean;
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Target job id (if not present the current job will be targeted)
|
|
147
|
-
*/
|
|
148
|
-
target?: string;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Optional topic to publish the interrupt message (if not present the current job topic will be used
|
|
152
|
-
*/
|
|
153
|
-
topic?: string;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Optional Error Code; will be used as the error `code` when thrown
|
|
157
|
-
* @default 410
|
|
158
|
-
*/
|
|
159
|
-
code?: number;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Optional stack trace
|
|
163
|
-
*/
|
|
164
|
-
stack?: string;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
type ActivityType =
|
|
168
|
-
| BaseActivity
|
|
169
|
-
| TriggerActivity
|
|
170
|
-
| AwaitActivity
|
|
171
|
-
| WorkerActivity
|
|
172
|
-
| InterruptActivity
|
|
173
|
-
| HookActivity
|
|
174
|
-
| SignalActivity
|
|
175
|
-
| CycleActivity;
|
|
176
|
-
|
|
177
|
-
type ActivityData = Record<string, any>;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Type definition for activity metadata.
|
|
181
|
-
*/
|
|
182
|
-
type ActivityMetadata = {
|
|
183
|
-
/**
|
|
184
|
-
* Unique identifier for the activity.
|
|
185
|
-
*/
|
|
186
|
-
aid: string;
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Type of the activity.
|
|
190
|
-
*/
|
|
191
|
-
atp: string;
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Subtype of the activity.
|
|
195
|
-
*/
|
|
196
|
-
stp: string;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Timestamp when the activity was created, in GMT.
|
|
200
|
-
*/
|
|
201
|
-
ac: string;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Timestamp when the activity was last updated, in GMT.
|
|
205
|
-
*/
|
|
206
|
-
au: string;
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Optional stringified JSON containing error details such as message, code, and an optional error object.
|
|
210
|
-
*/
|
|
211
|
-
err?: string;
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* OpenTelemetry span context for the first leg of the activity.
|
|
215
|
-
*/
|
|
216
|
-
l1s?: string;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* OpenTelemetry span context for the second leg of the activity.
|
|
220
|
-
*/
|
|
221
|
-
l2s?: string;
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Dimensional address, used for additional metadata.
|
|
225
|
-
*/
|
|
226
|
-
dad?: string;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Status of the activity, could be codes representing different states.
|
|
230
|
-
*/
|
|
231
|
-
as?: string;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
type ActivityContext = {
|
|
235
|
-
data?: ActivityData | null;
|
|
236
|
-
metadata: ActivityMetadata;
|
|
237
|
-
hook?: ActivityData;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
type ActivityDuplex = 1 | 2;
|
|
241
|
-
|
|
242
|
-
type ActivityDataType = {
|
|
243
|
-
data?: Record<string, unknown>;
|
|
244
|
-
metadata?: Record<string, unknown>;
|
|
245
|
-
hook?: Record<string, unknown>;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
type ActivityLeg = 1 | 2;
|
|
249
|
-
|
|
250
|
-
export {
|
|
251
|
-
ActivityContext,
|
|
252
|
-
ActivityData,
|
|
253
|
-
ActivityDataType,
|
|
254
|
-
ActivityDuplex,
|
|
255
|
-
ActivityLeg,
|
|
256
|
-
ActivityMetadata,
|
|
257
|
-
ActivityType,
|
|
258
|
-
Consumes,
|
|
259
|
-
TriggerActivityStats,
|
|
260
|
-
AwaitActivity,
|
|
261
|
-
CycleActivity,
|
|
262
|
-
HookActivity,
|
|
263
|
-
SignalActivity,
|
|
264
|
-
BaseActivity,
|
|
265
|
-
InterruptActivity,
|
|
266
|
-
TriggerActivity,
|
|
267
|
-
WorkerActivity,
|
|
268
|
-
};
|
package/types/app.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
interface App {
|
|
2
|
-
name: string;
|
|
3
|
-
title: string;
|
|
4
|
-
description: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
type AppVID = {
|
|
8
|
-
version: string;
|
|
9
|
-
id: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type AppTransitions = {
|
|
13
|
-
[key: string]: Record<string, unknown>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type AppSubscriptions = {
|
|
17
|
-
[key: string]: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { App, AppVID, AppTransitions, AppSubscriptions };
|
package/types/async.ts
DELETED
package/types/cache.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type CacheMode = 'nocache' | 'cache';
|
package/types/collator.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type CollationStage = 'enter' | 'exit' | 'confirm';
|
|
2
|
-
|
|
3
|
-
export enum CollationFaultType {
|
|
4
|
-
MISSING = 'missing', //`as` uninitialized; leg1 entry not allowed
|
|
5
|
-
DUPLICATE = 'duplicate', //1st digit < 8
|
|
6
|
-
INACTIVE = 'inactive', //3rd digit is 8
|
|
7
|
-
INVALID = 'invalid', //unknown value (corrupt for unknown reasons)
|
|
8
|
-
FORBIDDEN = 'forbidden', //leg 1 not completed; reentry (leg 2) not allowed
|
|
9
|
-
}
|
package/types/error.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export type MemFlowChildErrorType = {
|
|
2
|
-
arguments: string[];
|
|
3
|
-
await?: boolean;
|
|
4
|
-
backoffCoefficient?: number;
|
|
5
|
-
index: number;
|
|
6
|
-
expire?: number;
|
|
7
|
-
persistent?: boolean;
|
|
8
|
-
signalIn?: boolean;
|
|
9
|
-
maximumAttempts?: number;
|
|
10
|
-
maximumInterval?: number;
|
|
11
|
-
originJobId: string | null;
|
|
12
|
-
parentWorkflowId: string;
|
|
13
|
-
workflowDimension: string;
|
|
14
|
-
workflowId: string;
|
|
15
|
-
workflowTopic: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type MemFlowWaitForAllErrorType = {
|
|
19
|
-
items: string[];
|
|
20
|
-
workflowId: string;
|
|
21
|
-
workflowTopic: string;
|
|
22
|
-
parentWorkflowId: string;
|
|
23
|
-
originJobId: string | null;
|
|
24
|
-
size: number;
|
|
25
|
-
index: number;
|
|
26
|
-
workflowDimension: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type MemFlowProxyErrorType = {
|
|
30
|
-
arguments: string[];
|
|
31
|
-
activityName: string;
|
|
32
|
-
backoffCoefficient?: number;
|
|
33
|
-
index: number;
|
|
34
|
-
expire?: number;
|
|
35
|
-
maximumAttempts?: number;
|
|
36
|
-
maximumInterval?: number;
|
|
37
|
-
originJobId: string | null;
|
|
38
|
-
parentWorkflowId: string;
|
|
39
|
-
workflowDimension: string;
|
|
40
|
-
workflowId: string;
|
|
41
|
-
workflowTopic: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type MemFlowWaitForErrorType = {
|
|
45
|
-
signalId: string;
|
|
46
|
-
index: number;
|
|
47
|
-
workflowDimension: string;
|
|
48
|
-
workflowId: string;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export type MemFlowSleepErrorType = {
|
|
52
|
-
duration: number;
|
|
53
|
-
index: number;
|
|
54
|
-
workflowDimension: string;
|
|
55
|
-
workflowId: string;
|
|
56
|
-
};
|