@hotmeshio/hotmesh 0.4.0 → 0.4.2
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/README.md +39 -14
- 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 +29 -0
- package/build/services/memflow/workflow/signal.js +50 -0
- package/build/services/memflow/workflow/sleepFor.d.ts +24 -0
- package/build/services/memflow/workflow/sleepFor.js +51 -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 +29 -0
- package/build/services/memflow/workflow/waitFor.js +56 -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 +178 -0
- package/build/services/store/providers/postgres/postgres.js +1244 -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 +48 -0
- package/build/services/task/index.js +253 -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,66 @@
|
|
|
1
|
+
import { KeyStoreParams, KeyType } from '../types/hotmesh';
|
|
2
|
+
/**
|
|
3
|
+
* Keys
|
|
4
|
+
*
|
|
5
|
+
* hmsh -> {hash} hotmesh config {version: "0.0.1", namespace: "hmsh"}
|
|
6
|
+
* hmsh:a:<appid> -> {hash} app profile { "id": "appid", "version": "2", "versions/1": "GMT", "versions/2": "GMT"}
|
|
7
|
+
* hmsh:<appid>:r: -> {hash} throttle rates {':': '23', 'topic.thing': '555'} => {':i': 'all', 'topic.thing': '555seconds'}
|
|
8
|
+
* hmsh:<appid>:w: -> {zset} work items/tasks an engine must do like garbage collect or hook a set of matching records (hookAll)
|
|
9
|
+
* hmsh:<appid>:t: -> {zset} an ordered set of list (work lists) ids
|
|
10
|
+
* hmsh:<appid>:t:<timeValue?> -> {list} a worklist of `jobId+activityId` items that should be awakened
|
|
11
|
+
* hmsh:<appid>:q: -> {hash} quorum-wide messages
|
|
12
|
+
* hmsh:<appid>:q:<ngnid> -> {hash} engine-targeted messages (targeted quorum-oriented message)
|
|
13
|
+
* hmsh:<appid>:j:<jobid> -> {hash} job data
|
|
14
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime> -> {hash} job stats (general)
|
|
15
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime>:mdn:<field/path>:<fieldvalue> -> {zset} job stats (median)
|
|
16
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime>:index:<field/path>:<fieldvalue> -> {list} job stats (index of jobid[])
|
|
17
|
+
* hmsh:<appid>:v:<version>:activities -> {hash} schemas [cache]
|
|
18
|
+
* hmsh:<appid>:v:<version>:transitions -> {hash} transitions [cache]
|
|
19
|
+
* hmsh:<appid>:v:<version>:subscriptions -> {hash} subscriptions [cache]
|
|
20
|
+
* hmsh:<appid>:x: -> {xstream} when an engine is sent or reads a buffered task (engines read from their custom topic)
|
|
21
|
+
* hmsh:<appid>:x:<topic> -> {xstream} when a worker is sent or reads a buffered task (workers read from their custom topic)
|
|
22
|
+
* hmsh:<appid>:hooks -> {hash} hook patterns/rules; set at compile time
|
|
23
|
+
* hmsh:<appid>:signals -> {string} dynamic hook signals (hget/hdel); expirable
|
|
24
|
+
* hmsh:<appid>:sym:keys: -> {hash} list of symbol ranges and :cursor assigned at version deploy time for job keys
|
|
25
|
+
* hmsh:<appid>:sym:keys:<activityid|$subscribes> -> {hash} list of symbols based upon schema enums (initially) and adaptively optimized (later) during runtime; if '$subscribes' is used as the activityid, it is a top-level `job` symbol set (for job keys)
|
|
26
|
+
* hmsh:<appid>:sym:vals: -> {hash} list of symbols for job values across all app versions
|
|
27
|
+
*/
|
|
28
|
+
declare const HMNS = "hmsh";
|
|
29
|
+
declare const KEYSEP = ":";
|
|
30
|
+
declare const VALSEP = "::";
|
|
31
|
+
declare const WEBSEP = "::";
|
|
32
|
+
declare const TYPSEP = "::";
|
|
33
|
+
declare class KeyService {
|
|
34
|
+
/**
|
|
35
|
+
* Returns a key that can be used to access a value in the key/value store
|
|
36
|
+
* appropriate for the given key type; the keys have an implicit hierarchy
|
|
37
|
+
* and are used to organize data in the store in a tree-like structure
|
|
38
|
+
* via the use of colons as separators.
|
|
39
|
+
* @param namespace
|
|
40
|
+
* @param keyType
|
|
41
|
+
* @param params
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
static mintKey(namespace: string, keyType: KeyType, params: KeyStoreParams): string;
|
|
45
|
+
/**
|
|
46
|
+
* Extracts the parts of a given key string, safely handling cases where
|
|
47
|
+
* the 'id' portion may contain additional colons.
|
|
48
|
+
* @param key - The key to parse.
|
|
49
|
+
* @returns An object with the parsed key parts.
|
|
50
|
+
*/
|
|
51
|
+
static parseKey(key: string): Record<string, string | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Reconstructs a key string from its parts.
|
|
54
|
+
* @param parts - An object with the key parts.
|
|
55
|
+
* @returns The reconstructed key string.
|
|
56
|
+
*/
|
|
57
|
+
static reconstituteKey(parts: Record<string, string | undefined>): string;
|
|
58
|
+
/**
|
|
59
|
+
* Resolves an entity type abbreviation to a table-friendly name.
|
|
60
|
+
* @param abbreviation - The abbreviated entity type.
|
|
61
|
+
* @returns The long-form entity name.
|
|
62
|
+
*/
|
|
63
|
+
static resolveEntityType(abbreviation: string, id?: string): string;
|
|
64
|
+
static resolveAbbreviation(entity: string): string;
|
|
65
|
+
}
|
|
66
|
+
export { KeyService, KeyType, KeyStoreParams, HMNS, KEYSEP, TYPSEP, WEBSEP, VALSEP, };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VALSEP = exports.WEBSEP = exports.TYPSEP = exports.KEYSEP = exports.HMNS = exports.KeyType = exports.KeyService = void 0;
|
|
4
|
+
const hotmesh_1 = require("../types/hotmesh");
|
|
5
|
+
Object.defineProperty(exports, "KeyType", { enumerable: true, get: function () { return hotmesh_1.KeyType; } });
|
|
6
|
+
/**
|
|
7
|
+
* Keys
|
|
8
|
+
*
|
|
9
|
+
* hmsh -> {hash} hotmesh config {version: "0.0.1", namespace: "hmsh"}
|
|
10
|
+
* hmsh:a:<appid> -> {hash} app profile { "id": "appid", "version": "2", "versions/1": "GMT", "versions/2": "GMT"}
|
|
11
|
+
* hmsh:<appid>:r: -> {hash} throttle rates {':': '23', 'topic.thing': '555'} => {':i': 'all', 'topic.thing': '555seconds'}
|
|
12
|
+
* hmsh:<appid>:w: -> {zset} work items/tasks an engine must do like garbage collect or hook a set of matching records (hookAll)
|
|
13
|
+
* hmsh:<appid>:t: -> {zset} an ordered set of list (work lists) ids
|
|
14
|
+
* hmsh:<appid>:t:<timeValue?> -> {list} a worklist of `jobId+activityId` items that should be awakened
|
|
15
|
+
* hmsh:<appid>:q: -> {hash} quorum-wide messages
|
|
16
|
+
* hmsh:<appid>:q:<ngnid> -> {hash} engine-targeted messages (targeted quorum-oriented message)
|
|
17
|
+
* hmsh:<appid>:j:<jobid> -> {hash} job data
|
|
18
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime> -> {hash} job stats (general)
|
|
19
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime>:mdn:<field/path>:<fieldvalue> -> {zset} job stats (median)
|
|
20
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime>:index:<field/path>:<fieldvalue> -> {list} job stats (index of jobid[])
|
|
21
|
+
* hmsh:<appid>:v:<version>:activities -> {hash} schemas [cache]
|
|
22
|
+
* hmsh:<appid>:v:<version>:transitions -> {hash} transitions [cache]
|
|
23
|
+
* hmsh:<appid>:v:<version>:subscriptions -> {hash} subscriptions [cache]
|
|
24
|
+
* hmsh:<appid>:x: -> {xstream} when an engine is sent or reads a buffered task (engines read from their custom topic)
|
|
25
|
+
* hmsh:<appid>:x:<topic> -> {xstream} when a worker is sent or reads a buffered task (workers read from their custom topic)
|
|
26
|
+
* hmsh:<appid>:hooks -> {hash} hook patterns/rules; set at compile time
|
|
27
|
+
* hmsh:<appid>:signals -> {string} dynamic hook signals (hget/hdel); expirable
|
|
28
|
+
* hmsh:<appid>:sym:keys: -> {hash} list of symbol ranges and :cursor assigned at version deploy time for job keys
|
|
29
|
+
* hmsh:<appid>:sym:keys:<activityid|$subscribes> -> {hash} list of symbols based upon schema enums (initially) and adaptively optimized (later) during runtime; if '$subscribes' is used as the activityid, it is a top-level `job` symbol set (for job keys)
|
|
30
|
+
* hmsh:<appid>:sym:vals: -> {hash} list of symbols for job values across all app versions
|
|
31
|
+
*/
|
|
32
|
+
const HMNS = 'hmsh';
|
|
33
|
+
exports.HMNS = HMNS;
|
|
34
|
+
const KEYSEP = ':'; // default delimiter for keys
|
|
35
|
+
exports.KEYSEP = KEYSEP;
|
|
36
|
+
const VALSEP = '::'; // default delimiter for vals
|
|
37
|
+
exports.VALSEP = VALSEP;
|
|
38
|
+
const WEBSEP = '::'; // default delimiter for webhook vals
|
|
39
|
+
exports.WEBSEP = WEBSEP;
|
|
40
|
+
const TYPSEP = '::'; // delimiter for ZSET task typing (how should a list be used?)
|
|
41
|
+
exports.TYPSEP = TYPSEP;
|
|
42
|
+
class KeyService {
|
|
43
|
+
/**
|
|
44
|
+
* Returns a key that can be used to access a value in the key/value store
|
|
45
|
+
* appropriate for the given key type; the keys have an implicit hierarchy
|
|
46
|
+
* and are used to organize data in the store in a tree-like structure
|
|
47
|
+
* via the use of colons as separators.
|
|
48
|
+
* @param namespace
|
|
49
|
+
* @param keyType
|
|
50
|
+
* @param params
|
|
51
|
+
* @returns {string}
|
|
52
|
+
*/
|
|
53
|
+
static mintKey(namespace, keyType, params) {
|
|
54
|
+
switch (keyType) {
|
|
55
|
+
case hotmesh_1.KeyType.HOTMESH:
|
|
56
|
+
return namespace;
|
|
57
|
+
case hotmesh_1.KeyType.THROTTLE_RATE:
|
|
58
|
+
return `${namespace}:${params.appId}:r:`;
|
|
59
|
+
case hotmesh_1.KeyType.WORK_ITEMS:
|
|
60
|
+
return `${namespace}:${params.appId}:w:${params.scoutType || ''}`;
|
|
61
|
+
case hotmesh_1.KeyType.TIME_RANGE:
|
|
62
|
+
return `${namespace}:${params.appId}:t:${params.timeValue || ''}`;
|
|
63
|
+
case hotmesh_1.KeyType.APP:
|
|
64
|
+
return `${namespace}:a:${params.appId || ''}`;
|
|
65
|
+
case hotmesh_1.KeyType.QUORUM:
|
|
66
|
+
return `${namespace}:${params.appId}:q:${params.engineId || ''}`;
|
|
67
|
+
case hotmesh_1.KeyType.JOB_STATE:
|
|
68
|
+
return `${namespace}:${params.appId}:j:${params.jobId}`;
|
|
69
|
+
case hotmesh_1.KeyType.JOB_DEPENDENTS:
|
|
70
|
+
return `${namespace}:${params.appId}:d:${params.jobId}`;
|
|
71
|
+
case hotmesh_1.KeyType.JOB_STATS_GENERAL:
|
|
72
|
+
return `${namespace}:${params.appId}:s:${params.jobKey}:${params.dateTime}`;
|
|
73
|
+
case hotmesh_1.KeyType.JOB_STATS_MEDIAN:
|
|
74
|
+
return `${namespace}:${params.appId}:s:${params.jobKey}:${params.dateTime}:${params.facet}`;
|
|
75
|
+
case hotmesh_1.KeyType.JOB_STATS_INDEX:
|
|
76
|
+
return `${namespace}:${params.appId}:s:${params.jobKey}:${params.dateTime}:${params.facet}`;
|
|
77
|
+
case hotmesh_1.KeyType.SCHEMAS:
|
|
78
|
+
return `${namespace}:${params.appId}:v:${params.appVersion}:schemas`;
|
|
79
|
+
case hotmesh_1.KeyType.SUBSCRIPTIONS:
|
|
80
|
+
return `${namespace}:${params.appId}:v:${params.appVersion}:subscriptions`;
|
|
81
|
+
case hotmesh_1.KeyType.SUBSCRIPTION_PATTERNS:
|
|
82
|
+
return `${namespace}:${params.appId}:v:${params.appVersion}:transitions`;
|
|
83
|
+
case hotmesh_1.KeyType.HOOKS:
|
|
84
|
+
return `${namespace}:${params.appId}:hooks`;
|
|
85
|
+
case hotmesh_1.KeyType.SIGNALS:
|
|
86
|
+
return `${namespace}:${params.appId}:signals`;
|
|
87
|
+
case hotmesh_1.KeyType.SYMKEYS:
|
|
88
|
+
return `${namespace}:${params.appId}:sym:keys:${params.activityId || ''}`;
|
|
89
|
+
case hotmesh_1.KeyType.SYMVALS:
|
|
90
|
+
return `${namespace}:${params.appId}:sym:vals:`;
|
|
91
|
+
case hotmesh_1.KeyType.STREAMS:
|
|
92
|
+
return `${namespace}:${params.appId || ''}:x:${params.topic || ''}`;
|
|
93
|
+
default:
|
|
94
|
+
throw new Error('Invalid key type.');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Extracts the parts of a given key string, safely handling cases where
|
|
99
|
+
* the 'id' portion may contain additional colons.
|
|
100
|
+
* @param key - The key to parse.
|
|
101
|
+
* @returns An object with the parsed key parts.
|
|
102
|
+
*/
|
|
103
|
+
static parseKey(key) {
|
|
104
|
+
const [namespace, appId, entity, ...rest] = key.split(KEYSEP);
|
|
105
|
+
const id = rest.join(KEYSEP) || ''; // Join remaining parts to reconstruct the id
|
|
106
|
+
return {
|
|
107
|
+
namespace,
|
|
108
|
+
app: entity === 'a' ? appId : undefined,
|
|
109
|
+
entity,
|
|
110
|
+
id,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Reconstructs a key string from its parts.
|
|
115
|
+
* @param parts - An object with the key parts.
|
|
116
|
+
* @returns The reconstructed key string.
|
|
117
|
+
*/
|
|
118
|
+
static reconstituteKey(parts) {
|
|
119
|
+
const { namespace, app, entity, id } = parts;
|
|
120
|
+
return `${namespace}${KEYSEP}${app}${KEYSEP}${entity}${KEYSEP}${id || ''}`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Resolves an entity type abbreviation to a table-friendly name.
|
|
124
|
+
* @param abbreviation - The abbreviated entity type.
|
|
125
|
+
* @returns The long-form entity name.
|
|
126
|
+
*/
|
|
127
|
+
static resolveEntityType(abbreviation, id = '') {
|
|
128
|
+
switch (abbreviation) {
|
|
129
|
+
case 'a':
|
|
130
|
+
return 'applications';
|
|
131
|
+
case 'r':
|
|
132
|
+
return 'throttles';
|
|
133
|
+
case 'w':
|
|
134
|
+
return id === '' ? 'task_priorities' : 'roles';
|
|
135
|
+
case 't':
|
|
136
|
+
return id === '' ? 'task_schedules' : 'task_lists';
|
|
137
|
+
case 'q':
|
|
138
|
+
return 'events';
|
|
139
|
+
case 'j':
|
|
140
|
+
return 'jobs';
|
|
141
|
+
case 's':
|
|
142
|
+
return 'stats';
|
|
143
|
+
case 'v':
|
|
144
|
+
return 'versions';
|
|
145
|
+
case 'x':
|
|
146
|
+
return id === '' ? 'streams' : 'stream_topics';
|
|
147
|
+
case 'hooks':
|
|
148
|
+
return 'signal_patterns';
|
|
149
|
+
case 'signals':
|
|
150
|
+
return 'signal_registry';
|
|
151
|
+
case 'sym':
|
|
152
|
+
return 'symbols';
|
|
153
|
+
default:
|
|
154
|
+
return 'unknown_entity';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
static resolveAbbreviation(entity) {
|
|
158
|
+
switch (entity) {
|
|
159
|
+
case 'applications':
|
|
160
|
+
return 'a';
|
|
161
|
+
case 'throttles':
|
|
162
|
+
return 'r';
|
|
163
|
+
case 'roles':
|
|
164
|
+
return 'w';
|
|
165
|
+
case 'task_schedules':
|
|
166
|
+
return 't';
|
|
167
|
+
case 'task_lists':
|
|
168
|
+
return 't';
|
|
169
|
+
case 'events':
|
|
170
|
+
return 'q';
|
|
171
|
+
case 'jobs':
|
|
172
|
+
return 'j';
|
|
173
|
+
case 'stats':
|
|
174
|
+
return 's';
|
|
175
|
+
case 'versions':
|
|
176
|
+
return 'v';
|
|
177
|
+
case 'streams':
|
|
178
|
+
return 'x';
|
|
179
|
+
case 'signal_patterns':
|
|
180
|
+
return 'hooks';
|
|
181
|
+
case 'signal_registry':
|
|
182
|
+
return 'signals';
|
|
183
|
+
case 'symbols':
|
|
184
|
+
return 'sym';
|
|
185
|
+
default:
|
|
186
|
+
return 'unknown_entity';
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.KeyService = KeyService;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { StoreService } from '../services/store';
|
|
3
|
+
import { AppSubscriptions, AppTransitions, AppVID } from '../types/app';
|
|
4
|
+
import { ProviderClient, ProviderConfig, ProviderTransaction, Providers, ProvidersConfig } from '../types/provider';
|
|
5
|
+
import { StringAnyType } from '../types/serializer';
|
|
6
|
+
import { StreamCode, StreamData, StreamStatus } from '../types/stream';
|
|
7
|
+
import { SystemHealth } from '../types/quorum';
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export declare const hashOptions: (options: any) => string;
|
|
12
|
+
export declare function getSystemHealth(): Promise<SystemHealth>;
|
|
13
|
+
export declare function deepCopy<T>(obj: T): T;
|
|
14
|
+
export declare function deterministicRandom(seed: number): number;
|
|
15
|
+
export declare function guid(size?: number): string;
|
|
16
|
+
export declare function sleepFor(ms: number): Promise<void>;
|
|
17
|
+
export declare function sleepImmediate(): Promise<void>;
|
|
18
|
+
export declare function XSleepFor(ms: number): {
|
|
19
|
+
promise: Promise<unknown>;
|
|
20
|
+
timerId: NodeJS.Timeout;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Identies the provider type based on the provider object. Customers may
|
|
24
|
+
* explicitly set the provider type in the configuration. But this is a
|
|
25
|
+
* convenience method to automatically identify the provider type.
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
export declare function identifyProvider(provider: any): Providers | null;
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
export declare const polyfill: {
|
|
33
|
+
/**
|
|
34
|
+
* `redis` is deprecated; `connection` is the generic replacement
|
|
35
|
+
*/
|
|
36
|
+
providerConfig(obj: any): any;
|
|
37
|
+
/**
|
|
38
|
+
* NOTE: `redisClass and redisOptions` input parameters are deprecated; use `connection` for all configuration inputs
|
|
39
|
+
*/
|
|
40
|
+
meshDataConfig(obj: {
|
|
41
|
+
connection?: Partial<ProviderConfig | ProvidersConfig>;
|
|
42
|
+
redisClass?: any;
|
|
43
|
+
redisOptions?: StringAnyType;
|
|
44
|
+
}): Partial<ProviderConfig> | Partial<ProvidersConfig>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
export declare function matchesStatusCode(code: StreamCode, pattern: string | RegExp): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
export declare function matchesStatus(status: StreamStatus, targetStatus: StreamStatus): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
export declare function findTopKey(obj: AppTransitions, input: string): string | null;
|
|
58
|
+
/**
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
export declare function findSubscriptionForTrigger(obj: AppSubscriptions, value: string): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Get the subscription topic for the flow to which activityId belongs.
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
export declare function getSubscriptionTopic(activityId: string, store: StoreService<ProviderClient, ProviderTransaction>, appVID: AppVID): Promise<string | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* returns the 12-digit format of the iso timestamp (e.g, 202101010000); returns
|
|
69
|
+
* an empty string if overridden by the user to not segment by time (infinity).
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
export declare function getTimeSeries(granularity: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
export declare function formatISODate(input: Date | string): string;
|
|
77
|
+
/**
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
export declare function getSymKey(number: number): string;
|
|
81
|
+
/**
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
export declare function getSymVal(number: number): string;
|
|
85
|
+
/**
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
88
|
+
export declare function getIndexedHash<T>(hash: T, target: string): [number, T];
|
|
89
|
+
/**
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
export declare function getValueByPath(obj: {
|
|
93
|
+
[key: string]: any;
|
|
94
|
+
}, path: string): any;
|
|
95
|
+
/**
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
export declare function restoreHierarchy(obj: StringAnyType): StringAnyType;
|
|
99
|
+
/**
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
export declare function isValidCron(cronExpression: string): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the number of seconds for a string using the milliseconds format
|
|
105
|
+
* used by the `ms` npm package as the input.
|
|
106
|
+
*/
|
|
107
|
+
export declare const s: (input: string) => number;
|
|
108
|
+
/**
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
export declare const parseStreamMessage: (message: string) => StreamData;
|
|
112
|
+
/**
|
|
113
|
+
* @private
|
|
114
|
+
*/
|
|
115
|
+
export declare const isStreamMessage: (result: any) => boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Transforms an array of arrays to an array of objects.
|
|
118
|
+
*/
|
|
119
|
+
export declare const arrayToHash: (response: [number, ...Array<string | string[]>]) => Record<string, string>[];
|