@hotmeshio/hotmesh 0.0.44 → 0.0.45

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 CHANGED
@@ -19,7 +19,7 @@ HotMesh inverts the relationship to Redis: those functions that once used Redis
19
19
 
20
20
  HotMesh creates an *ad hoc*, Redis-backed network of functions and organizes them into a unified service mesh. *Any service with access to Redis can join in the network, bypassing the legacy clutter.*
21
21
 
22
- <img src="./docs/img/hotmesh_emergent_properties.png" alt="HotMesh elevates Redis to a Service Mesh, Message Router, Integration Bus, and Business Process Engine." style="max-width:100%;width:600px;">
22
+ <img src="https://github.com/hotmeshio/sdk-typescript/tree/main/docs/img/hotmesh_emergent_properties.png" alt="HotMesh elevates Redis to a Service Mesh, Message Router, Integration Bus, and Business Process Engine." style="max-width:100%;width:600px;">
23
23
 
24
24
 
25
25
  ## Design
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -12,11 +12,10 @@ const utils_1 = require("../../modules/utils");
12
12
  class ClientService {
13
13
  constructor(config) {
14
14
  this.getHotMeshClient = async (workflowTopic, namespace) => {
15
- //use the cached instance
16
- const instanceId = 'SINGLETON';
17
- if (ClientService.instances.has(instanceId)) {
18
- const hotMeshClient = await ClientService.instances.get(instanceId);
19
- await this.verifyWorkflowActive(hotMeshClient, namespace ?? factory_1.APP_ID);
15
+ const targetNS = namespace ?? factory_1.APP_ID;
16
+ if (ClientService.instances.has(targetNS)) {
17
+ const hotMeshClient = await ClientService.instances.get(targetNS);
18
+ await this.verifyWorkflowActive(hotMeshClient, targetNS);
20
19
  if (!ClientService.topics.includes(workflowTopic)) {
21
20
  ClientService.topics.push(workflowTopic);
22
21
  await this.createStream(hotMeshClient, workflowTopic, namespace);
@@ -25,7 +24,7 @@ class ClientService {
25
24
  }
26
25
  //create and cache an instance
27
26
  const hotMeshClient = hotmesh_1.HotMeshService.init({
28
- appId: namespace ?? factory_1.APP_ID,
27
+ appId: targetNS,
29
28
  logLevel: enums_1.HMSH_LOGLEVEL,
30
29
  engine: {
31
30
  redis: {
@@ -34,9 +33,9 @@ class ClientService {
34
33
  }
35
34
  }
36
35
  });
37
- ClientService.instances.set(instanceId, hotMeshClient);
36
+ ClientService.instances.set(targetNS, hotMeshClient);
38
37
  await this.createStream(await hotMeshClient, workflowTopic, namespace);
39
- await this.activateWorkflow(await hotMeshClient, namespace ?? factory_1.APP_ID);
38
+ await this.activateWorkflow(await hotMeshClient, targetNS);
40
39
  return hotMeshClient;
41
40
  };
42
41
  /**
@@ -99,12 +99,14 @@ class QuorumService {
99
99
  async sayPong(appId, guid, originator, details = false) {
100
100
  let profile;
101
101
  if (details) {
102
+ const stream = this.engine.stream.mintKey(hotmesh_1.KeyType.STREAMS, { appId: this.appId });
102
103
  profile = {
103
104
  engine_id: this.guid,
104
105
  namespace: this.namespace,
105
106
  app_id: this.appId,
106
- stream: this.engine.stream.mintKey(hotmesh_1.KeyType.STREAMS, { appId: this.appId }),
107
+ stream,
107
108
  counts: this.engine.router.counts,
109
+ timestamp: (0, utils_1.formatISODate)(new Date()),
108
110
  };
109
111
  }
110
112
  this.store.publish(hotmesh_1.KeyType.QUORUM, {
@@ -31,6 +31,8 @@ class Router {
31
31
  }
32
32
  }
33
33
  async publishMessage(topic, streamData, multi) {
34
+ const code = streamData?.code || '200';
35
+ this.counts[code] = (this.counts[code] || 0) + 1;
34
36
  const stream = this.store.mintKey(key_1.KeyType.STREAMS, { appId: this.store.appId, topic });
35
37
  return await this.store.xadd(stream, '*', 'message', JSON.stringify(streamData), multi);
36
38
  }
@@ -147,8 +149,6 @@ class Router {
147
149
  else {
148
150
  output.metadata.guid = (0, utils_1.guid)();
149
151
  }
150
- const code = output.code || 200;
151
- this.counts[code] = (this.counts[code] || 0) + 1;
152
152
  output.type = stream_1.StreamDataType.RESPONSE;
153
153
  return await this.publishMessage(null, output);
154
154
  }
@@ -115,6 +115,7 @@ class WorkerService {
115
115
  worker_topic: this.topic,
116
116
  stream: this.stream.mintKey(key_1.KeyType.STREAMS, params),
117
117
  counts: this.router.counts,
118
+ timestamp: (0, utils_1.formatISODate)(new Date()),
118
119
  };
119
120
  }
120
121
  this.store.publish(key_1.KeyType.QUORUM, {
@@ -7,6 +7,7 @@ export interface QuorumProfile {
7
7
  stream?: string;
8
8
  stream_depth?: number;
9
9
  counts?: Record<string, number>;
10
+ timestamp?: string;
10
11
  }
11
12
  export interface PingMessage {
12
13
  type: 'ping';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -26,11 +26,10 @@ export class ClientService {
26
26
  }
27
27
 
28
28
  getHotMeshClient = async (workflowTopic: string, namespace?: string) => {
29
- //use the cached instance
30
- const instanceId = 'SINGLETON';
31
- if (ClientService.instances.has(instanceId)) {
32
- const hotMeshClient = await ClientService.instances.get(instanceId);
33
- await this.verifyWorkflowActive(hotMeshClient, namespace ?? APP_ID);
29
+ const targetNS = namespace ?? APP_ID;
30
+ if (ClientService.instances.has(targetNS)) {
31
+ const hotMeshClient = await ClientService.instances.get(targetNS);
32
+ await this.verifyWorkflowActive(hotMeshClient, targetNS);
34
33
  if (!ClientService.topics.includes(workflowTopic)) {
35
34
  ClientService.topics.push(workflowTopic);
36
35
  await this.createStream(hotMeshClient, workflowTopic, namespace);
@@ -40,7 +39,7 @@ export class ClientService {
40
39
 
41
40
  //create and cache an instance
42
41
  const hotMeshClient = HotMesh.init({
43
- appId: namespace ?? APP_ID,
42
+ appId: targetNS,
44
43
  logLevel: HMSH_LOGLEVEL,
45
44
  engine: {
46
45
  redis: {
@@ -49,9 +48,9 @@ export class ClientService {
49
48
  }
50
49
  }
51
50
  });
52
- ClientService.instances.set(instanceId, hotMeshClient);
51
+ ClientService.instances.set(targetNS, hotMeshClient);
53
52
  await this.createStream(await hotMeshClient, workflowTopic, namespace);
54
- await this.activateWorkflow(await hotMeshClient, namespace ?? APP_ID);
53
+ await this.activateWorkflow(await hotMeshClient, targetNS);
55
54
  return hotMeshClient;
56
55
  }
57
56
 
@@ -1,5 +1,5 @@
1
1
  import { HMSH_ACTIVATION_MAX_RETRY, HMSH_QUORUM_DELAY_MS } from '../../modules/enums';
2
- import { identifyRedisType, sleepFor } from '../../modules/utils';
2
+ import { formatISODate, identifyRedisType, sleepFor } from '../../modules/utils';
3
3
  import { CompilerService } from '../compiler';
4
4
  import { EngineService } from '../engine';
5
5
  import { ILogger } from '../logger';
@@ -141,12 +141,17 @@ class QuorumService {
141
141
  async sayPong(appId: string, guid: string, originator: string, details = false) {
142
142
  let profile: QuorumProfile;
143
143
  if (details) {
144
+ const stream = this.engine.stream.mintKey(
145
+ KeyType.STREAMS,
146
+ { appId: this.appId }
147
+ );
144
148
  profile = {
145
149
  engine_id: this.guid,
146
150
  namespace: this.namespace,
147
151
  app_id: this.appId,
148
- stream: this.engine.stream.mintKey(KeyType.STREAMS, { appId: this.appId }),
152
+ stream,
149
153
  counts: this.engine.router.counts,
154
+ timestamp: formatISODate(new Date()),
150
155
  };
151
156
  }
152
157
  this.store.publish(
@@ -65,6 +65,9 @@ class Router {
65
65
  }
66
66
 
67
67
  async publishMessage(topic: string, streamData: StreamData|StreamDataResponse, multi?: RedisMulti): Promise<string | RedisMulti> {
68
+ const code = streamData?.code || '200';
69
+ this.counts[code] = (this.counts[code] || 0) + 1;
70
+
68
71
  const stream = this.store.mintKey(KeyType.STREAMS, { appId: this.store.appId, topic });
69
72
  return await this.store.xadd(stream, '*', 'message', JSON.stringify(streamData), multi);
70
73
  }
@@ -184,8 +187,6 @@ class Router {
184
187
  } else {
185
188
  output.metadata.guid = guid();
186
189
  }
187
- const code = output.code || 200;
188
- this.counts[code] = (this.counts[code] || 0) + 1;
189
190
  output.type = StreamDataType.RESPONSE;
190
191
  return await this.publishMessage(null, output as StreamDataResponse) as string;
191
192
  }
@@ -1,5 +1,5 @@
1
1
  import { KeyType } from "../../modules/key";
2
- import { identifyRedisType } from "../../modules/utils";
2
+ import { formatISODate, identifyRedisType } from "../../modules/utils";
3
3
  import { ConnectorService } from "../connector";
4
4
  import { ILogger } from "../logger";
5
5
  import { Router } from "../router";
@@ -175,6 +175,7 @@ class WorkerService {
175
175
  worker_topic: this.topic,
176
176
  stream: this.stream.mintKey(KeyType.STREAMS, params),
177
177
  counts: this.router.counts,
178
+ timestamp: formatISODate(new Date()),
178
179
  };
179
180
  }
180
181
  this.store.publish(
package/types/quorum.ts CHANGED
@@ -10,6 +10,7 @@ export interface QuorumProfile {
10
10
  stream?: string;
11
11
  stream_depth?: number;
12
12
  counts?: Record<string, number>;
13
+ timestamp?: string;
13
14
  }
14
15
 
15
16
  export interface PingMessage {