@hotmeshio/hotmesh 0.0.11 → 0.0.12

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
@@ -47,13 +47,13 @@ The HotMesh SDK is designed to keep your code front-and-center. Write functions
47
47
  }
48
48
  ```
49
49
 
50
- 3. Although you could call your workflow directly (it's just a vanilla function), it's only durable when invoked and orchestrated via HotMesh. By using a HotMesh **client** to send the request, the function is guaranteed to return a result.
50
+ 3. Although you could call your workflow directly (it's just a vanilla function), it's only durable when invoked and orchestrated via HotMesh. By using a HotMesh **client** to trigger the function, it's guaranteed to return a result.
51
51
  ```javascript
52
52
  //client.ts
53
53
 
54
54
  import { Durable } from '@hotmeshio/hotmesh';
55
55
  import Redis from 'ioredis'; //OR `import * as Redis from 'redis';`
56
- import { v4 as uuidv4 } from 'uuid';
56
+ import { nanoid } from 'nanoid';
57
57
 
58
58
  async function run(): Promise<string> {
59
59
  const client = new Durable.Client({
@@ -67,7 +67,7 @@ The HotMesh SDK is designed to keep your code front-and-center. Write functions
67
67
  args: ['HotMesh', 'es'],
68
68
  taskQueue: 'hello-world',
69
69
  workflowName: 'example',
70
- workflowId: uuidv4()
70
+ workflowId: nanoid()
71
71
  });
72
72
 
73
73
  return await handle.result();
@@ -75,7 +75,7 @@ The HotMesh SDK is designed to keep your code front-and-center. Write functions
75
75
  }
76
76
  ```
77
77
 
78
- 4. The last step is to create a **worker** and link it to your workflow function. Workers listen for tasks on their assigned channel, executing the linked workflow function until it succeeds.
78
+ 4. The last step is to create a **worker** and link it to your workflow function. Workers listen for tasks on their assigned channel, executing the targeted workflow function until it succeeds.
79
79
  ```javascript
80
80
  //worker.ts
81
81
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Durable Workflows",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -55,7 +55,7 @@
55
55
  "@opentelemetry/api": "^1.4.1",
56
56
  "js-yaml": "^4.1.0",
57
57
  "ms": "^2.1.3",
58
- "uuid": "^9.0.1",
58
+ "nanoid": "^3.3.6",
59
59
  "winston": "^3.8.2"
60
60
  },
61
61
  "devDependencies": {
@@ -73,6 +73,8 @@ class Cycle extends activity_1.Activity {
73
73
  dad: collator_1.CollatorService.resolveReentryDimension(this),
74
74
  jid: this.context.metadata.jid,
75
75
  aid: this.config.ancestor,
76
+ spn: this.context['$self'].output.metadata?.l1s,
77
+ trc: this.context.metadata.trc,
76
78
  },
77
79
  data: this.context.data
78
80
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Trigger = void 0;
4
- const uuid_1 = require("uuid");
4
+ const nanoid_1 = require("nanoid");
5
5
  const errors_1 = require("../../modules/errors");
6
6
  const utils_1 = require("../../modules/utils");
7
7
  const activity_1 = require("./activity");
@@ -136,7 +136,7 @@ class Trigger extends activity_1.Activity {
136
136
  }
137
137
  resolveJobId(context) {
138
138
  const jobId = this.config.stats?.id;
139
- return jobId ? pipe_1.Pipe.resolve(jobId, context) : (0, uuid_1.v4)();
139
+ return jobId ? pipe_1.Pipe.resolve(jobId, context) : (0, nanoid_1.nanoid)();
140
140
  }
141
141
  resolveJobKey(context) {
142
142
  const jobKey = this.config.stats?.key;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConnectorService = void 0;
4
- const uuid_1 = require("uuid");
4
+ const nanoid_1 = require("nanoid");
5
5
  const utils_1 = require("../../modules/utils");
6
6
  const ioredis_1 = require("../connector/clients/ioredis");
7
7
  const redis_1 = require("../connector/clients/redis");
@@ -13,12 +13,12 @@ class ConnectorService {
13
13
  const instances = [];
14
14
  if ((0, utils_1.identifyRedisTypeFromClass)(Redis) === 'redis') {
15
15
  for (let i = 1; i <= 3; i++) {
16
- instances.push(redis_1.RedisConnection.connect((0, uuid_1.v4)(), Redis, options));
16
+ instances.push(redis_1.RedisConnection.connect((0, nanoid_1.nanoid)(), Redis, options));
17
17
  }
18
18
  }
19
19
  else {
20
20
  for (let i = 1; i <= 3; i++) {
21
- instances.push(ioredis_1.RedisConnection.connect((0, uuid_1.v4)(), Redis, options));
21
+ instances.push(ioredis_1.RedisConnection.connect((0, nanoid_1.nanoid)(), Redis, options));
22
22
  }
23
23
  }
24
24
  const [store, stream, sub] = await Promise.all(instances);
@@ -12,7 +12,7 @@ Here is an example of how the methods in this file are used:
12
12
  import { Durable } from '@hotmeshio/hotmesh';
13
13
  import Redis from 'ioredis';
14
14
  import { example } from './workflows';
15
- import { v4 as uuidv4 } from 'uuid';
15
+ import { nanoid } from 'nanoid';
16
16
 
17
17
  async function run() {
18
18
  const connection = await Durable.Connection.connect({
@@ -31,7 +31,7 @@ async function run() {
31
31
  args: ['HotMesh'],
32
32
  taskQueue: 'hello-world',
33
33
  workflowName: 'example',
34
- workflowId: 'workflow-' + uuidv4(),
34
+ workflowId: 'workflow-' + nanoid(),
35
35
  });
36
36
 
37
37
  console.log(`Started workflow ${handle.workflowId}`);
@@ -8,7 +8,7 @@ Here is an example of how the methods in this file are used:
8
8
 
9
9
  import { Durable } from '@hotmeshio/hotmesh';
10
10
  import Redis from 'ioredis';
11
- import { v4 as uuidv4 } from 'uuid';
11
+ import { nanoid } from 'nanoid';
12
12
 
13
13
  async function run() {
14
14
  const connection = await Durable.Connection.connect({
@@ -27,7 +27,7 @@ async function run() {
27
27
  taskQueue: 'hello-world',
28
28
  args: ['HotMesh'],
29
29
  workflowName: 'example',
30
- workflowId: uuidv4(),
30
+ workflowId: nanoid(),
31
31
  });
32
32
 
33
33
  console.log(`Started workflow ${handle.workflowId}`);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HotMeshService = void 0;
4
- const uuid_1 = require("uuid");
4
+ const nanoid_1 = require("nanoid");
5
5
  const key_1 = require("../../modules/key");
6
6
  const engine_1 = require("../engine");
7
7
  const logger_1 = require("../logger");
@@ -39,7 +39,7 @@ class HotMeshService {
39
39
  }
40
40
  static async init(config) {
41
41
  const instance = new HotMeshService();
42
- instance.guid = (0, uuid_1.v4)();
42
+ instance.guid = (0, nanoid_1.nanoid)();
43
43
  instance.verifyAndSetNamespace(config.namespace);
44
44
  instance.verifyAndSetAppId(config.appId);
45
45
  instance.logger = new logger_1.LoggerService(config.appId, instance.guid, config.name || '', config.logLevel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Durable Workflows",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -55,7 +55,7 @@
55
55
  "@opentelemetry/api": "^1.4.1",
56
56
  "js-yaml": "^4.1.0",
57
57
  "ms": "^2.1.3",
58
- "uuid": "^9.0.1",
58
+ "nanoid": "^3.3.6",
59
59
  "winston": "^3.8.2"
60
60
  },
61
61
  "devDependencies": {
@@ -91,6 +91,8 @@ class Cycle extends Activity {
91
91
  dad: CollatorService.resolveReentryDimension(this),
92
92
  jid: this.context.metadata.jid,
93
93
  aid: this.config.ancestor,
94
+ spn: this.context['$self'].output.metadata?.l1s,
95
+ trc: this.context.metadata.trc,
94
96
  },
95
97
  data: this.context.data
96
98
  };
@@ -1,4 +1,4 @@
1
- import { v4 as uuidv4 } from 'uuid';
1
+ import { nanoid } from 'nanoid';
2
2
  import { DuplicateJobError } from '../../modules/errors';
3
3
  import { formatISODate, getTimeSeries } from '../../modules/utils';
4
4
  import { Activity } from './activity';
@@ -160,7 +160,7 @@ class Trigger extends Activity {
160
160
 
161
161
  resolveJobId(context: Partial<JobState>): string {
162
162
  const jobId = this.config.stats?.id;
163
- return jobId ? Pipe.resolve(jobId, context) : uuidv4();
163
+ return jobId ? Pipe.resolve(jobId, context) : nanoid();
164
164
  }
165
165
 
166
166
  resolveJobKey(context: Partial<JobState>): string {
@@ -1,4 +1,4 @@
1
- import { v4 as uuidv4 } from 'uuid';
1
+ import { nanoid } from 'nanoid';
2
2
 
3
3
  import { identifyRedisTypeFromClass } from '../../modules/utils';
4
4
  import { RedisConnection as IORedisConnection } from '../connector/clients/ioredis';
@@ -23,14 +23,14 @@ export class ConnectorService {
23
23
  if (identifyRedisTypeFromClass(Redis) === 'redis') {
24
24
  for (let i = 1; i <= 3; i++) {
25
25
  instances.push(RedisConnection.connect(
26
- uuidv4(),
26
+ nanoid(),
27
27
  Redis as RedisClassType,
28
28
  options as RedisClientOptions));
29
29
  }
30
30
  } else {
31
31
  for (let i = 1; i <= 3; i++) {
32
32
  instances.push(IORedisConnection.connect(
33
- uuidv4(),
33
+ nanoid(),
34
34
  Redis as IORedisClassType,
35
35
  options as IORedisClientOptions));
36
36
  }
@@ -12,7 +12,7 @@ Here is an example of how the methods in this file are used:
12
12
  import { Durable } from '@hotmeshio/hotmesh';
13
13
  import Redis from 'ioredis';
14
14
  import { example } from './workflows';
15
- import { v4 as uuidv4 } from 'uuid';
15
+ import { nanoid } from 'nanoid';
16
16
 
17
17
  async function run() {
18
18
  const connection = await Durable.Connection.connect({
@@ -31,7 +31,7 @@ async function run() {
31
31
  args: ['HotMesh'],
32
32
  taskQueue: 'hello-world',
33
33
  workflowName: 'example',
34
- workflowId: 'workflow-' + uuidv4(),
34
+ workflowId: 'workflow-' + nanoid(),
35
35
  });
36
36
 
37
37
  console.log(`Started workflow ${handle.workflowId}`);
@@ -7,7 +7,7 @@ Here is an example of how the methods in this file are used:
7
7
 
8
8
  import { Durable } from '@hotmeshio/hotmesh';
9
9
  import Redis from 'ioredis';
10
- import { v4 as uuidv4 } from 'uuid';
10
+ import { nanoid } from 'nanoid';
11
11
 
12
12
  async function run() {
13
13
  const connection = await Durable.Connection.connect({
@@ -26,7 +26,7 @@ async function run() {
26
26
  taskQueue: 'hello-world',
27
27
  args: ['HotMesh'],
28
28
  workflowName: 'example',
29
- workflowId: uuidv4(),
29
+ workflowId: nanoid(),
30
30
  });
31
31
 
32
32
  console.log(`Started workflow ${handle.workflowId}`);
@@ -1,4 +1,4 @@
1
- import { v4 as uuidv4 } from 'uuid';
1
+ import { nanoid } from 'nanoid';
2
2
  import { HMNS } from '../../modules/key';
3
3
  import { EngineService } from '../engine';
4
4
  import { LoggerService, ILogger } from '../logger';
@@ -53,7 +53,7 @@ class HotMeshService {
53
53
 
54
54
  static async init(config: HotMeshConfig) {
55
55
  const instance = new HotMeshService();
56
- instance.guid = uuidv4();
56
+ instance.guid = nanoid();
57
57
  instance.verifyAndSetNamespace(config.namespace);
58
58
  instance.verifyAndSetAppId(config.appId);
59
59
  instance.logger = new LoggerService(config.appId, instance.guid, config.name || '', config.logLevel);