@hotmeshio/hotmesh 0.3.1 → 0.3.3
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 +1 -1
- package/build/package.json +1 -1
- package/build/services/activities/trigger.js +1 -0
- package/build/services/meshcall/index.js +2 -2
- package/build/services/meshdata/index.js +7 -7
- package/build/services/meshflow/client.js +3 -3
- package/build/services/meshflow/schemas/factory.d.ts +1 -1
- package/build/services/meshflow/schemas/factory.js +1 -1
- package/build/services/meshflow/search.js +4 -4
- package/build/services/meshflow/worker.js +4 -4
- package/package.json +1 -1
- package/types/meshdata.ts +8 -6
- package/types/meshflow.ts +12 -6
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ npm install @hotmeshio/hotmesh
|
|
|
10
10
|
You have a Redis instance? Good. You're ready to go.
|
|
11
11
|
|
|
12
12
|
## Learn
|
|
13
|
-
[📄 Docs](https://hotmeshio.github.io/sdk-typescript/) | [💼 Projects](https://github.com/hotmeshio/samples-typescript) | [🎥
|
|
13
|
+
[📄 Docs](https://hotmeshio.github.io/sdk-typescript/) | [💼 Sample Projects](https://github.com/hotmeshio/samples-typescript) | [🎥 Intro (3m)](https://www.loom.com/share/211bd4b4038d42f0ba34374ef5b6f961?sid=7b889a56-f60f-4ccc-84e7-8c2697e548a9) | [🎥 Transactional Workflow (9m)](https://www.loom.com/share/54ffd5266baf4ac6b287578abfd1d821?sid=0db2cef8-ef0d-4e02-a0b7-a1ee14f476ce)
|
|
14
14
|
|
|
15
15
|
## MeshCall | Connect Everything
|
|
16
16
|
[MeshCall](https://hotmeshio.github.io/sdk-typescript/classes/services_meshcall.MeshCall.html) connects your services as a singular mesh, exposing functions as idempotent endpoints. Function responses are cacheable and functions can even run as idempotent cron jobs. Make blazing fast interservice calls that return in milliseconds without the overhead of HTTP.
|
package/build/package.json
CHANGED
|
@@ -54,6 +54,7 @@ class Trigger extends activity_1.Activity {
|
|
|
54
54
|
catch (error) {
|
|
55
55
|
telemetry?.setActivityError(error.message);
|
|
56
56
|
if (error instanceof errors_1.DuplicateJobError) {
|
|
57
|
+
await (0, utils_1.sleepFor)(1000);
|
|
57
58
|
const isOverage = await collator_1.CollatorService.isInceptionOverage(this, this.context.metadata.guid);
|
|
58
59
|
if (isOverage) {
|
|
59
60
|
this.logger.info('trigger-collation-overage', {
|
|
@@ -43,7 +43,7 @@ class MeshCall {
|
|
|
43
43
|
await hotMesh.activate(version);
|
|
44
44
|
}
|
|
45
45
|
catch (error) {
|
|
46
|
-
hotMesh.engine.logger.error('
|
|
46
|
+
hotMesh.engine.logger.error('meshcall-client-activate-err', { error });
|
|
47
47
|
throw error;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -53,7 +53,7 @@ class MeshCall {
|
|
|
53
53
|
await hotMesh.activate(version);
|
|
54
54
|
}
|
|
55
55
|
catch (error) {
|
|
56
|
-
hotMesh.engine.logger.error('
|
|
56
|
+
hotMesh.engine.logger.error('meshcall-client-deploy-activate-err', {
|
|
57
57
|
...error,
|
|
58
58
|
});
|
|
59
59
|
throw error;
|
|
@@ -13,7 +13,7 @@ class MeshData {
|
|
|
13
13
|
this.instances = new Map();
|
|
14
14
|
this.mesh = {
|
|
15
15
|
sub: async (callback, options = {}) => {
|
|
16
|
-
const hotMesh = await this.getHotMesh(options.namespace || '
|
|
16
|
+
const hotMesh = await this.getHotMesh(options.namespace || 'meshflow');
|
|
17
17
|
const callbackWrapper = (topic, message) => {
|
|
18
18
|
if (message.type === 'pong' && !message.originator) {
|
|
19
19
|
if (message.profile?.worker_topic) {
|
|
@@ -37,11 +37,11 @@ class MeshData {
|
|
|
37
37
|
await hotMesh.quorum?.sub(callbackWrapper);
|
|
38
38
|
},
|
|
39
39
|
pub: async (message, options = {}) => {
|
|
40
|
-
const hotMesh = await this.getHotMesh(options.namespace || '
|
|
40
|
+
const hotMesh = await this.getHotMesh(options.namespace || 'meshflow');
|
|
41
41
|
await hotMesh.quorum?.pub(message);
|
|
42
42
|
},
|
|
43
43
|
unsub: async (callback, options = {}) => {
|
|
44
|
-
const hotMesh = await this.getHotMesh(options.namespace || '
|
|
44
|
+
const hotMesh = await this.getHotMesh(options.namespace || 'meshflow');
|
|
45
45
|
await hotMesh.quorum?.unsub(callback);
|
|
46
46
|
},
|
|
47
47
|
};
|
|
@@ -132,7 +132,7 @@ class MeshData {
|
|
|
132
132
|
}
|
|
133
133
|
return `${entity}${id}`;
|
|
134
134
|
}
|
|
135
|
-
async getHotMesh(namespace = '
|
|
135
|
+
async getHotMesh(namespace = 'meshflow') {
|
|
136
136
|
let hotMesh = await this.instances.get(namespace);
|
|
137
137
|
if (!hotMesh) {
|
|
138
138
|
hotMesh = hotmesh_1.HotMesh.init({
|
|
@@ -257,10 +257,10 @@ class MeshData {
|
|
|
257
257
|
return await this.getClient().workflow.signal(guid, payload, namespace);
|
|
258
258
|
}
|
|
259
259
|
async rollCall(options = {}) {
|
|
260
|
-
return (await this.getHotMesh(options.namespace || '
|
|
260
|
+
return (await this.getHotMesh(options.namespace || 'meshflow')).rollCall(options.delay || 1000);
|
|
261
261
|
}
|
|
262
262
|
async throttle(options) {
|
|
263
|
-
return (await this.getHotMesh(options.namespace || '
|
|
263
|
+
return (await this.getHotMesh(options.namespace || 'meshflow')).throttle(options);
|
|
264
264
|
}
|
|
265
265
|
async hook({ entity, id, hookEntity, hookArgs, options = {}, }) {
|
|
266
266
|
const workflowId = MeshData.mintGuid(entity, id);
|
|
@@ -428,7 +428,7 @@ class MeshData {
|
|
|
428
428
|
return (await hotMesh.engine?.store?.findJobs(options.match, options.limit, options.batch, options.cursor));
|
|
429
429
|
}
|
|
430
430
|
async find(entity, options, ...args) {
|
|
431
|
-
return await this.getClient().workflow.search(options.taskQueue ?? entity, options.workflowName ?? entity, options.namespace || '
|
|
431
|
+
return await this.getClient().workflow.search(options.taskQueue ?? entity, options.workflowName ?? entity, options.namespace || 'meshflow', options.index ?? options.search?.index ?? this.search.index ?? '', ...args);
|
|
432
432
|
}
|
|
433
433
|
async findWhere(entity, options) {
|
|
434
434
|
const targetSearch = options.options?.search ?? this.search;
|
|
@@ -117,7 +117,7 @@ class ClientService {
|
|
|
117
117
|
return await this.search(hotMeshClient, index, query);
|
|
118
118
|
}
|
|
119
119
|
catch (error) {
|
|
120
|
-
hotMeshClient.engine.logger.error('
|
|
120
|
+
hotMeshClient.engine.logger.error('meshflow-client-search-err', {
|
|
121
121
|
...error,
|
|
122
122
|
});
|
|
123
123
|
throw error;
|
|
@@ -153,7 +153,7 @@ class ClientService {
|
|
|
153
153
|
await hotMesh.activate(version);
|
|
154
154
|
}
|
|
155
155
|
catch (error) {
|
|
156
|
-
hotMesh.engine.logger.error('
|
|
156
|
+
hotMesh.engine.logger.error('meshflow-client-activate-err', { error });
|
|
157
157
|
throw error;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -163,7 +163,7 @@ class ClientService {
|
|
|
163
163
|
await hotMesh.activate(version);
|
|
164
164
|
}
|
|
165
165
|
catch (error) {
|
|
166
|
-
hotMesh.engine.logger.error('
|
|
166
|
+
hotMesh.engine.logger.error('meshflow-client-deploy-activate-err', {
|
|
167
167
|
...error,
|
|
168
168
|
});
|
|
169
169
|
throw error;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.APP_ID = exports.APP_VERSION = exports.getWorkflowYAML = void 0;
|
|
4
4
|
const APP_VERSION = '4';
|
|
5
5
|
exports.APP_VERSION = APP_VERSION;
|
|
6
|
-
const APP_ID = '
|
|
6
|
+
const APP_ID = 'meshflow';
|
|
7
7
|
exports.APP_ID = APP_ID;
|
|
8
8
|
const getWorkflowYAML = (app, version) => {
|
|
9
9
|
return `app:
|
|
@@ -53,7 +53,7 @@ class Search {
|
|
|
53
53
|
await store.exec('FT.CREATE', `${search.index}`, 'ON', 'HASH', 'PREFIX', prefixes.length.toString(), ...prefixes, 'SCHEMA', ...schema);
|
|
54
54
|
}
|
|
55
55
|
catch (error) {
|
|
56
|
-
hotMeshClient.engine.logger.info('
|
|
56
|
+
hotMeshClient.engine.logger.info('meshflow-client-search-err', {
|
|
57
57
|
...error,
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -66,7 +66,7 @@ class Search {
|
|
|
66
66
|
return searchIndexes;
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
|
-
hotMeshClient.engine.logger.info('
|
|
69
|
+
hotMeshClient.engine.logger.info('meshflow-client-search-list-err', {
|
|
70
70
|
...error,
|
|
71
71
|
});
|
|
72
72
|
return [];
|
|
@@ -104,7 +104,7 @@ class Search {
|
|
|
104
104
|
return value;
|
|
105
105
|
}
|
|
106
106
|
catch (error) {
|
|
107
|
-
this.hotMeshClient.logger.error('
|
|
107
|
+
this.hotMeshClient.logger.error('meshflow-search-get-error', { ...error });
|
|
108
108
|
return '';
|
|
109
109
|
}
|
|
110
110
|
}
|
|
@@ -134,7 +134,7 @@ class Search {
|
|
|
134
134
|
return returnValues;
|
|
135
135
|
}
|
|
136
136
|
catch (error) {
|
|
137
|
-
this.hotMeshClient.logger.error('
|
|
137
|
+
this.hotMeshClient.logger.error('meshflow-search-mget-error', {
|
|
138
138
|
...error,
|
|
139
139
|
});
|
|
140
140
|
return [];
|
|
@@ -21,7 +21,7 @@ class WorkerService {
|
|
|
21
21
|
await hotMesh.activate(factory_1.APP_VERSION);
|
|
22
22
|
}
|
|
23
23
|
catch (err) {
|
|
24
|
-
hotMesh.engine.logger.error('
|
|
24
|
+
hotMesh.engine.logger.error('meshflow-worker-deploy-activate-err', err);
|
|
25
25
|
throw err;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -30,7 +30,7 @@ class WorkerService {
|
|
|
30
30
|
await hotMesh.activate(factory_1.APP_VERSION);
|
|
31
31
|
}
|
|
32
32
|
catch (err) {
|
|
33
|
-
hotMesh.engine.logger.error('
|
|
33
|
+
hotMesh.engine.logger.error('meshflow-worker-activate-err', err);
|
|
34
34
|
throw err;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -81,7 +81,7 @@ class WorkerService {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
async run() {
|
|
84
|
-
this.workflowRunner.engine.logger.info('
|
|
84
|
+
this.workflowRunner.engine.logger.info('meshflow-worker-running');
|
|
85
85
|
}
|
|
86
86
|
async initActivityWorker(config, activityTopic) {
|
|
87
87
|
const redisConfig = {
|
|
@@ -121,7 +121,7 @@ class WorkerService {
|
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
catch (err) {
|
|
124
|
-
this.activityRunner.engine.logger.error('
|
|
124
|
+
this.activityRunner.engine.logger.error('meshflow-worker-activity-err', {
|
|
125
125
|
name: err.name,
|
|
126
126
|
message: err.message,
|
|
127
127
|
stack: err.stack,
|
package/package.json
CHANGED
package/types/meshdata.ts
CHANGED
|
@@ -36,9 +36,10 @@ export type CallOptions = {
|
|
|
36
36
|
*/
|
|
37
37
|
fields?: string[];
|
|
38
38
|
/**
|
|
39
|
-
* namespace for the the execution client
|
|
39
|
+
* namespace for the the execution client
|
|
40
|
+
* @default 'meshflow'
|
|
40
41
|
*/
|
|
41
|
-
namespace?: string;
|
|
42
|
+
namespace?: string;
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* Custom marker data field used for adding a searchable marker to the job.
|
|
@@ -72,9 +73,10 @@ export type ConnectOptions = {
|
|
|
72
73
|
*/
|
|
73
74
|
prefix?: string;
|
|
74
75
|
/**
|
|
75
|
-
* optional namespace for the the worker
|
|
76
|
+
* optional namespace for the the worker
|
|
77
|
+
* @default 'meshflow'
|
|
76
78
|
*/
|
|
77
|
-
namespace?: string;
|
|
79
|
+
namespace?: string;
|
|
78
80
|
/**
|
|
79
81
|
* extended worker options
|
|
80
82
|
*/
|
|
@@ -175,7 +177,7 @@ export type HookInput = {
|
|
|
175
177
|
|
|
176
178
|
export type MeshDataWorkflowOptions = {
|
|
177
179
|
/**
|
|
178
|
-
* The app deployment namespace; how it appears in redis (e.g., '
|
|
180
|
+
* The app deployment namespace; how it appears in redis (e.g., 'meshflow')
|
|
179
181
|
*/
|
|
180
182
|
namespace?: string;
|
|
181
183
|
|
|
@@ -225,7 +227,7 @@ export type MeshDataWorkflowOptions = {
|
|
|
225
227
|
config?: WorkflowConfig;
|
|
226
228
|
|
|
227
229
|
/**
|
|
228
|
-
* Set to 'infinity'
|
|
230
|
+
* Set to 'infinity', '1 minute', '1 hour', etc
|
|
229
231
|
*/
|
|
230
232
|
ttl?: string;
|
|
231
233
|
|
package/types/meshflow.ts
CHANGED
|
@@ -65,7 +65,8 @@ type WorkflowContext = {
|
|
|
65
65
|
replay: StringStringType;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* the HotMesh App namespace
|
|
68
|
+
* the HotMesh App namespace
|
|
69
|
+
* @default meshflow
|
|
69
70
|
*/
|
|
70
71
|
namespace: string;
|
|
71
72
|
|
|
@@ -252,7 +253,8 @@ type SearchResults = {
|
|
|
252
253
|
|
|
253
254
|
type WorkflowOptions = {
|
|
254
255
|
/**
|
|
255
|
-
* the namespace for the workflow
|
|
256
|
+
* the namespace for the workflow
|
|
257
|
+
* @default meshflow
|
|
256
258
|
*/
|
|
257
259
|
namespace?: string;
|
|
258
260
|
|
|
@@ -358,7 +360,8 @@ type WorkflowOptions = {
|
|
|
358
360
|
|
|
359
361
|
/**
|
|
360
362
|
* Options for setting up a hook.
|
|
361
|
-
* '
|
|
363
|
+
* 'meshflow' is the default namespace if not provided;
|
|
364
|
+
* similar to setting `appid` in the YAML
|
|
362
365
|
*/
|
|
363
366
|
type HookOptions = {
|
|
364
367
|
/** Optional namespace under which the hook function will be grouped */
|
|
@@ -450,8 +453,8 @@ type WorkerConfig = {
|
|
|
450
453
|
connection: Connection;
|
|
451
454
|
|
|
452
455
|
/**
|
|
453
|
-
* Namespace used in the app configuration, denoted as `appid` in the YAML
|
|
454
|
-
* @default
|
|
456
|
+
* Namespace used in the app configuration, denoted as `appid` in the YAML
|
|
457
|
+
* @default meshflow
|
|
455
458
|
*/
|
|
456
459
|
namespace?: string;
|
|
457
460
|
|
|
@@ -505,7 +508,10 @@ type FindJobsOptions = {
|
|
|
505
508
|
/** The workflow name; include an asterisk for wilcard search; refer to Redis SCAN for the allowed format */
|
|
506
509
|
match?: string;
|
|
507
510
|
|
|
508
|
-
/**
|
|
511
|
+
/**
|
|
512
|
+
* application namespace
|
|
513
|
+
* @default meshflow
|
|
514
|
+
*/
|
|
509
515
|
namespace?: string;
|
|
510
516
|
|
|
511
517
|
/** The suggested response limit. Reduce batch size to reduce the likelihood of large overages. */
|