@hotmeshio/hotmesh 0.0.37 → 0.0.39
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 +14 -8
- package/build/modules/enums.d.ts +29 -23
- package/build/modules/enums.js +38 -29
- package/build/modules/errors.d.ts +1 -1
- package/build/modules/errors.js +9 -7
- package/build/modules/key.d.ts +1 -34
- package/build/modules/key.js +24 -47
- package/build/package.json +1 -1
- package/build/services/activities/activity.js +1 -1
- package/build/services/activities/hook.js +4 -9
- package/build/services/activities/trigger.d.ts +3 -2
- package/build/services/activities/trigger.js +10 -6
- package/build/services/durable/client.d.ts +9 -1
- package/build/services/durable/client.js +30 -14
- package/build/services/durable/handle.js +2 -2
- package/build/services/durable/worker.js +4 -3
- package/build/services/engine/index.d.ts +2 -1
- package/build/services/engine/index.js +6 -6
- package/build/services/hotmesh/index.d.ts +2 -2
- package/build/services/hotmesh/index.js +3 -4
- package/build/services/quorum/index.d.ts +6 -6
- package/build/services/quorum/index.js +47 -11
- package/build/services/router/index.js +16 -14
- package/build/services/store/clients/ioredis.d.ts +1 -0
- package/build/services/store/clients/ioredis.js +9 -0
- package/build/services/store/clients/redis.d.ts +1 -0
- package/build/services/store/clients/redis.js +16 -0
- package/build/services/store/index.d.ts +15 -9
- package/build/services/store/index.js +46 -23
- package/build/services/stream/clients/ioredis.d.ts +1 -0
- package/build/services/stream/clients/ioredis.js +33 -24
- package/build/services/stream/clients/redis.d.ts +1 -0
- package/build/services/stream/clients/redis.js +15 -0
- package/build/services/stream/index.d.ts +1 -0
- package/build/services/task/index.d.ts +10 -3
- package/build/services/task/index.js +35 -17
- package/build/services/worker/index.d.ts +1 -0
- package/build/services/worker/index.js +24 -0
- package/build/types/durable.d.ts +3 -2
- package/build/types/hotmesh.d.ts +43 -2
- package/build/types/hotmesh.js +28 -0
- package/build/types/index.d.ts +3 -2
- package/build/types/index.js +3 -1
- package/build/types/logger.d.ts +1 -0
- package/build/types/logger.js +1 -0
- package/build/types/quorum.d.ts +11 -1
- package/build/types/redisclient.d.ts +1 -0
- package/build/types/task.d.ts +1 -0
- package/build/types/task.js +2 -0
- package/modules/enums.ts +49 -35
- package/modules/errors.ts +17 -8
- package/modules/key.ts +3 -40
- package/package.json +1 -1
- package/services/activities/activity.ts +2 -2
- package/services/activities/hook.ts +18 -9
- package/services/activities/trigger.ts +10 -6
- package/services/durable/client.ts +31 -15
- package/services/durable/handle.ts +3 -3
- package/services/durable/worker.ts +4 -3
- package/services/engine/index.ts +13 -12
- package/services/hotmesh/index.ts +4 -5
- package/services/quorum/index.ts +48 -12
- package/services/router/index.ts +26 -24
- package/services/store/clients/ioredis.ts +9 -0
- package/services/store/clients/redis.ts +16 -0
- package/services/store/index.ts +63 -25
- package/services/stream/clients/ioredis.ts +33 -24
- package/services/stream/clients/redis.ts +14 -0
- package/services/stream/index.ts +1 -0
- package/services/task/index.ts +66 -24
- package/services/worker/index.ts +30 -0
- package/types/durable.ts +6 -5
- package/types/hotmesh.ts +47 -2
- package/types/index.ts +8 -1
- package/types/logger.ts +3 -1
- package/types/quorum.ts +15 -4
- package/types/redisclient.ts +1 -0
- package/types/task.ts +1 -0
package/services/worker/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { RedisClientType as IORedisClientType } from '../../types/ioredisclient'
|
|
|
14
14
|
import { HotMeshConfig, HotMeshWorker } from "../../types/hotmesh";
|
|
15
15
|
import {
|
|
16
16
|
QuorumMessage,
|
|
17
|
+
QuorumProfile,
|
|
17
18
|
SubscriptionCallback } from "../../types/quorum";
|
|
18
19
|
import { RedisClient, RedisMulti } from "../../types/redis";
|
|
19
20
|
import { RedisClientType } from '../../types/redisclient';
|
|
@@ -153,10 +154,39 @@ class WorkerService {
|
|
|
153
154
|
self.logger.debug('worker-event-received', { topic, type: message.type });
|
|
154
155
|
if (message.type === 'throttle') {
|
|
155
156
|
self.throttle(message.throttle);
|
|
157
|
+
} else if(message.type === 'ping') {
|
|
158
|
+
self.sayPong(self.appId, self.guid, message.originator, message.details);
|
|
156
159
|
}
|
|
157
160
|
};
|
|
158
161
|
}
|
|
159
162
|
|
|
163
|
+
async sayPong(appId: string, guid: string, originator: string, details = false) {
|
|
164
|
+
let profile: QuorumProfile;
|
|
165
|
+
if (details) {
|
|
166
|
+
const params = {
|
|
167
|
+
appId: this.appId,
|
|
168
|
+
topic: this.topic,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
profile = {
|
|
172
|
+
engine_id: this.guid,
|
|
173
|
+
namespace: this.namespace,
|
|
174
|
+
app_id: this.appId,
|
|
175
|
+
worker_topic: this.topic,
|
|
176
|
+
stream: this.stream.mintKey(KeyType.STREAMS, params),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
this.store.publish(
|
|
180
|
+
KeyType.QUORUM,
|
|
181
|
+
{
|
|
182
|
+
type: 'pong',
|
|
183
|
+
guid, originator,
|
|
184
|
+
profile,
|
|
185
|
+
},
|
|
186
|
+
appId,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
160
190
|
async throttle(delayInMillis: number) {
|
|
161
191
|
this.router.setThrottle(delayInMillis);
|
|
162
192
|
}
|
package/types/durable.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LogLevel } from './logger';
|
|
1
2
|
import { RedisClass, RedisOptions } from './redis';
|
|
2
3
|
|
|
3
4
|
type WorkflowConfig = {
|
|
@@ -173,16 +174,16 @@ type MeshOSActivityOptions = {
|
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
type MeshOSWorkerOptions = {
|
|
176
|
-
taskQueue?: string;
|
|
177
|
+
taskQueue?: string; //change the default task queue
|
|
177
178
|
allowList?: Array<MeshOSOptions | string>; //limit which `hook` and `workflow` workers start
|
|
178
|
-
logLevel?:
|
|
179
|
-
maxSystemRetries?: number;
|
|
179
|
+
logLevel?: LogLevel; //debug, info, warn, error
|
|
180
|
+
maxSystemRetries?: number; //1-3 (10ms, 100ms, 1_000ms)
|
|
180
181
|
backoffCoefficient?: number; //2-10ish
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
type WorkerOptions = {
|
|
184
|
-
logLevel?:
|
|
185
|
-
maxSystemRetries?: number;
|
|
185
|
+
logLevel?: LogLevel; //debug, info, warn, error
|
|
186
|
+
maxSystemRetries?: number; //1-3 (10ms, 100ms, 1_000ms)
|
|
186
187
|
backoffCoefficient?: number; //2-10ish
|
|
187
188
|
}
|
|
188
189
|
|
package/types/hotmesh.ts
CHANGED
|
@@ -3,6 +3,49 @@ import { HotMeshService } from '../services/hotmesh';
|
|
|
3
3
|
import { HookRules } from './hook';
|
|
4
4
|
import { RedisClass, RedisClient, RedisOptions } from './redis';
|
|
5
5
|
import { StreamData, StreamDataResponse } from './stream';
|
|
6
|
+
import { LogLevel } from './logger';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* the full set of entity types that are stored in the key/value store
|
|
10
|
+
*/
|
|
11
|
+
enum KeyType {
|
|
12
|
+
APP = 'APP',
|
|
13
|
+
ENGINE_ID = 'ENGINE',
|
|
14
|
+
HOOKS = 'HOOKS',
|
|
15
|
+
JOB_DEPENDENTS = 'JOB_DEPENDENTS',
|
|
16
|
+
JOB_STATE = 'JOB_STATE',
|
|
17
|
+
JOB_STATS_GENERAL = 'JOB_STATS_GENERAL',
|
|
18
|
+
JOB_STATS_MEDIAN = 'JOB_STATS_MEDIAN',
|
|
19
|
+
JOB_STATS_INDEX = 'JOB_STATS_INDEX',
|
|
20
|
+
HOTMESH = 'HOTMESH',
|
|
21
|
+
QUORUM = 'QUORUM',
|
|
22
|
+
SCHEMAS = 'SCHEMAS',
|
|
23
|
+
SIGNALS = 'SIGNALS',
|
|
24
|
+
STREAMS = 'STREAMS',
|
|
25
|
+
SUBSCRIPTIONS = 'SUBSCRIPTIONS',
|
|
26
|
+
SUBSCRIPTION_PATTERNS = 'SUBSCRIPTION_PATTERNS',
|
|
27
|
+
SYMKEYS = 'SYMKEYS',
|
|
28
|
+
SYMVALS = 'SYMVALS',
|
|
29
|
+
TIME_RANGE = 'TIME_RANGE',
|
|
30
|
+
WORK_ITEMS = 'WORK_ITEMS',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* minting keys, requires one or more of the following parameters
|
|
35
|
+
*/
|
|
36
|
+
type KeyStoreParams = {
|
|
37
|
+
appId?: string; //app id is a uuid for a hotmesh app
|
|
38
|
+
engineId?: string; //unique auto-generated guid for an ephemeral engine instance
|
|
39
|
+
appVersion?: string; //(e.g. "1.0.0", "1", "1.0")
|
|
40
|
+
jobId?: string; //a customer-defined id for job; must be unique for the entire app
|
|
41
|
+
activityId?: string; //activity id is a uuid for a given hotmesh app
|
|
42
|
+
jobKey?: string; //a customer-defined label for a job that serves to categorize events
|
|
43
|
+
dateTime?: string; //UTC date time: YYYY-MM-DDTHH:MM (20203-04-12T00:00); serves as a time-series bucket for the job_key
|
|
44
|
+
facet?: string; //data path starting at root with values separated by colons (e.g. "object/type:bar")
|
|
45
|
+
topic?: string; //topic name (e.g., "foo" or "" for top-level)
|
|
46
|
+
timeValue?: number; //time value (rounded to minute) (for delete range)
|
|
47
|
+
scoutType?: 'signal' | 'time'; //a single member of the quorum serves as the 'scout' for the group, triaging tasks for the collective
|
|
48
|
+
};
|
|
6
49
|
|
|
7
50
|
type HotMesh = typeof HotMeshService;
|
|
8
51
|
|
|
@@ -39,7 +82,7 @@ type HotMeshConfig = {
|
|
|
39
82
|
namespace?: string;
|
|
40
83
|
name?: string;
|
|
41
84
|
logger?: ILogger;
|
|
42
|
-
logLevel?:
|
|
85
|
+
logLevel?: LogLevel;
|
|
43
86
|
engine?: HotMeshEngine;
|
|
44
87
|
workers?: HotMeshWorker[];
|
|
45
88
|
}
|
|
@@ -98,5 +141,7 @@ export {
|
|
|
98
141
|
HotMeshApps, //object array of all apps in the db
|
|
99
142
|
HotMeshConfig, //customer config
|
|
100
143
|
HotMeshManifest,
|
|
101
|
-
HotMeshGraph
|
|
144
|
+
HotMeshGraph,
|
|
145
|
+
KeyType,
|
|
146
|
+
KeyStoreParams,
|
|
102
147
|
};
|
package/types/index.ts
CHANGED
|
@@ -90,7 +90,9 @@ export {
|
|
|
90
90
|
HotMeshGraph,
|
|
91
91
|
HotMeshManifest,
|
|
92
92
|
HotMeshSettings,
|
|
93
|
-
HotMeshWorker
|
|
93
|
+
HotMeshWorker,
|
|
94
|
+
KeyStoreParams,
|
|
95
|
+
KeyType } from './hotmesh';
|
|
94
96
|
export {
|
|
95
97
|
ActivateMessage,
|
|
96
98
|
JobMessage,
|
|
@@ -98,6 +100,8 @@ export {
|
|
|
98
100
|
PingMessage,
|
|
99
101
|
PongMessage,
|
|
100
102
|
QuorumMessage,
|
|
103
|
+
QuorumMessageCallback,
|
|
104
|
+
QuorumProfile,
|
|
101
105
|
SubscriptionCallback,
|
|
102
106
|
ThrottleMessage,
|
|
103
107
|
WorkMessage } from './quorum';
|
|
@@ -161,7 +165,10 @@ export {
|
|
|
161
165
|
trace,
|
|
162
166
|
Tracer,
|
|
163
167
|
ValueType } from './telemetry';
|
|
168
|
+
export {
|
|
169
|
+
WorkListTaskType } from './task'
|
|
164
170
|
export {
|
|
165
171
|
TransitionMatch,
|
|
166
172
|
TransitionRule,
|
|
167
173
|
Transitions } from './transition';
|
|
174
|
+
|
package/types/logger.ts
CHANGED
package/types/quorum.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { JobOutput } from "./job";
|
|
2
2
|
|
|
3
|
-
//used for coordination like version activation
|
|
3
|
+
//used for coordination (like version activation)
|
|
4
|
+
|
|
5
|
+
export interface QuorumProfile {
|
|
6
|
+
namespace: string;
|
|
7
|
+
app_id: string;
|
|
8
|
+
engine_id: string;
|
|
9
|
+
worker_topic?: string;
|
|
10
|
+
stream?: string;
|
|
11
|
+
stream_depth?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
4
14
|
export interface PingMessage {
|
|
5
15
|
type: 'ping';
|
|
6
16
|
originator: string; //guid
|
|
17
|
+
details?: boolean; //if true, all endpoints will include their profile
|
|
7
18
|
}
|
|
8
19
|
|
|
9
20
|
export interface WorkMessage {
|
|
@@ -16,11 +27,11 @@ export interface CronMessage {
|
|
|
16
27
|
originator: string; //guid
|
|
17
28
|
}
|
|
18
29
|
|
|
19
|
-
//used for coordination like version activation
|
|
20
30
|
export interface PongMessage {
|
|
21
31
|
type: 'pong';
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
guid: string; //call initiator
|
|
33
|
+
originator: string; //clone of originator guid passed in ping
|
|
34
|
+
profile?: QuorumProfile; //contains details about the engine/worker
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
export interface ActivateMessage {
|
package/types/redisclient.ts
CHANGED
|
@@ -6,6 +6,7 @@ interface RedisMultiType {
|
|
|
6
6
|
XADD(key: string, id: string, fields: any): this;
|
|
7
7
|
XACK(key: string, group: string, id: string): this;
|
|
8
8
|
XDEL(key: string, id: string): this;
|
|
9
|
+
XLEN(key: string): this;
|
|
9
10
|
HDEL(key: string, itemId: string): this;
|
|
10
11
|
HGET(key: string, itemId: string): this;
|
|
11
12
|
HGETALL(key: string): this;
|
package/types/task.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type WorkListTaskType = 'sleep' | 'expire' | 'interrupt' | 'delist';
|