@hotmeshio/hotmesh 0.1.16 → 0.1.17

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
@@ -12,8 +12,8 @@ You have a Redis instance? Good. You're ready to go.
12
12
  ## SDK Docs
13
13
  [Read the Docs](https://hotmeshio.github.io/sdk-typescript/)
14
14
 
15
- ## MeshCall
16
- The **MeshCall** module connects and exposes your functions as idempotent endpoints.
15
+ ## MeshCall | Connect Everything
16
+ The **MeshCall** module connects any function with a connection to Redis. Function responses are cacheable and functions can even run as cyclical cron jobs. Make blazing fast interservice calls that return in milliseconds without the overhead of HTTP.
17
17
 
18
18
  <details style="padding: .5em">
19
19
  <summary style="font-size:1.25em;">Run an idempotent cron job</summary>
@@ -21,7 +21,7 @@ The **MeshCall** module connects and exposes your functions as idempotent endpoi
21
21
  ### Run a Cron
22
22
  This example demonstrates an *idempotent* cron that runs every day. The `id` makes each cron job unique and ensures that only one instance runs, despite repeated invocations. *The `cron` method fails silently if a workflow is already running with the same `id`.*
23
23
 
24
- Optionally set `maxCycles` or `maxDuration` to limit the number of cycles.
24
+ Optionally set a `delay` and/or set `maxCycles` to limit the number of cycles.
25
25
 
26
26
  1. Define the cron function.
27
27
  ```typescript
@@ -39,7 +39,7 @@ The **MeshCall** module connects and exposes your functions as idempotent endpoi
39
39
  callback: async () => {
40
40
  //your code here...
41
41
  },
42
- options: { id, interval }
42
+ options: { id, interval, maxCycles: 24 }
43
43
  });
44
44
  };
45
45
  ```
@@ -78,7 +78,7 @@ The **MeshCall** module connects and exposes your functions as idempotent endpoi
78
78
  <summary style="font-size:1.25em;">Call any function in any service</summary>
79
79
 
80
80
  ### Call a Function
81
- Make blazing fast interservice calls that return in milliseconds without the overhead of HTTP.
81
+ Make blazing fast interservice calls that behave like HTTP but without the setup and performance overhead. This example demonstrates how to connect a function to the mesh and call it from anywhere on the network.
82
82
 
83
83
  1. Call `MeshCall.connect` and provide a `topic` to uniquely identify the function.
84
84
 
@@ -167,7 +167,7 @@ The **MeshCall** module connects and exposes your functions as idempotent endpoi
167
167
  ```
168
168
  </details>
169
169
 
170
- ## MeshFlow
170
+ ## MeshFlow | Transactional Workflow
171
171
  The **MeshFlow** module is a drop-in replacement for [Temporal.io](https://temporal.io). If you need to orchestrate your functions as durable workflows, MeshFlow combines the popular Temporal SDK with Redis' *in-memory execution speed*.
172
172
 
173
173
  <details style="padding: .5em">
@@ -502,17 +502,17 @@ This example calls an activity and then sleeps for a week. It runs indefinitely
502
502
  ```
503
503
  </details>
504
504
 
505
- ## MeshData
505
+ ## MeshData | Transactional Analytics
506
506
  The **MeshData** service extends the **MeshFlow** service, combining data record concepts and transactional workflow principles into a single *Operational Data Layer*.
507
507
 
508
508
  Deployments with the Redis `FT.SEARCH` module enabled can use the **MeshData** module to merge [OLTP](https://en.wikipedia.org/wiki/Online_transaction_processing) and [OLAP](https://en.wikipedia.org/wiki/Online_analytical_processing) operations into a hybrid transactional/analytics ([HTAP](https://en.wikipedia.org/wiki/Hybrid_transactional/analytical_processing)) system.
509
509
 
510
- >For those Redis deployments without the `FT.SEARCH` module, it's still useful to define a workflow schema. The MeshData class provides convenience methods for reading and writing hash field data to a workflow record (e.g., `get`, `del`, and `incr`).*
510
+ *For those Redis deployments without the `FT.SEARCH` module, it's still useful to define a workflow schema. The MeshData class provides convenience methods for reading and writing hash field data to a workflow record (e.g., `get`, `del`, and `incr`).*
511
511
 
512
512
  <details style="padding: .5em">
513
513
  <summary style="font-size:1.25em;">Create a search index</summary>
514
514
 
515
- ### Schemas and Indexes
515
+ ### Workflow Data Indexes
516
516
 
517
517
  This example demonstrates how to define a schema and deploy an index for a 'user' entity type.
518
518
 
@@ -552,7 +552,7 @@ This example demonstrates how to define a schema and deploy an index for a 'user
552
552
  <details style="padding: .5em">
553
553
  <summary style="font-size:1.25em;">Create an indexed, searchable record</summary>
554
554
 
555
- ### Searchable Workflow
555
+ ### Workflow Record Data
556
556
  This example demonstrates how to create a 'user' workflow backed by the searchable schema from the prior example.
557
557
 
558
558
  1. Call MeshData `connect` to initialize a 'user' entity *worker*. It references a target worker function which will run the workflow. Data fields that are documented in the schema (like `active`) will be automatically indexed when set on the workflow record.
@@ -632,7 +632,7 @@ This example demonstrates how to create a 'user' workflow backed by the searchab
632
632
  <details style="padding: .5em">
633
633
  <summary style="font-size:1.25em;">Fetch record data</summary>
634
634
 
635
- ### Workflow Record Fields
635
+ ### Read Record Data
636
636
  This example demonstrates how to read data fields directly from a workflow.
637
637
 
638
638
  1. Read data fields directly from the *jimbo123* 'user' record.
@@ -663,7 +663,7 @@ This example demonstrates how to read data fields directly from a workflow.
663
663
  <details style="padding: .5em">
664
664
  <summary style="font-size:1.25em;">Search record data</summary>
665
665
 
666
- ### Searchable Workflow
666
+ ### Query Record Data
667
667
  This example demonstrates how to search for those workflows where a given condition exists in the data. This one searches for active users. *NOTE: The native Redis FT.SEARCH syntax is supported. The JSON abstraction shown here is a convenience method for straight-forward, one-dimensional queries.*
668
668
 
669
669
  1. Search for active users (where the value of the `active` field is `yes`).
package/index.ts CHANGED
@@ -1,19 +1,9 @@
1
1
  import { MeshCall } from './services/meshcall';
2
2
  import { MeshData } from './services/meshdata';
3
+ import { MeshFlow } from './services/meshflow';
3
4
  import { HotMesh } from './services/hotmesh';
4
- import { ClientService } from './services/meshflow/client';
5
- import { WorkerService } from './services/meshflow/worker';
6
- import { WorkflowService } from './services/meshflow/workflow';
7
- import { ConnectionService } from './services/meshflow/connection';
8
5
  import { HotMeshConfig } from './types/hotmesh';
9
6
 
10
- const MeshFlow = {
11
- Client: ClientService,
12
- Worker: WorkerService,
13
- workflow: WorkflowService,
14
- Connection: ConnectionService,
15
- };
16
-
17
7
  export {
18
8
  HotMesh,
19
9
  MeshCall,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
package/types/meshcall.ts CHANGED
@@ -16,29 +16,84 @@ interface MeshCallExecOptions {
16
16
  flush?: boolean;
17
17
  }
18
18
  interface MeshCallConnectParams {
19
+ /**
20
+ * Log level for the worker
21
+ */
19
22
  logLevel?: LogLevel;
20
- guid?: string; // Assign a custom engine id
23
+ /**
24
+ * Idempotent GUID for the worker and engine
25
+ */
26
+ guid?: string;
27
+ /**
28
+ * Namespace for grouping common functions
29
+ */
21
30
  namespace?: string;
31
+ /**
32
+ * Unique topic for the worker function
33
+ */
22
34
  topic: string;
35
+ /**
36
+ * Redis configuration for the worker
37
+ */
23
38
  redis: RedisConfig;
24
- callback: <T extends any[], U>(...args: T) => Promise<U>;
39
+ /**
40
+ * The linked worker function that will be called
41
+ */
42
+ callback: (...args: any[]) => any;
25
43
  }
26
44
 
27
45
  interface MeshCallExecParams {
46
+ /**
47
+ * namespace for grouping common functions
48
+ */
28
49
  namespace?: string;
50
+ /**
51
+ * topic assigned to the worker when it was connected
52
+ */
29
53
  topic: string;
54
+ /**
55
+ * Arguments to pass to the worker function
56
+ */
30
57
  args: any[];
58
+ /**
59
+ * Redis configuration
60
+ */
31
61
  redis: RedisConfig;
62
+ /**
63
+ * Execution options like caching ttl
64
+ */
32
65
  options?: MeshCallExecOptions;
33
66
  }
34
67
 
68
+ interface MeshCallFlushOptions {
69
+ /**
70
+ * Cache id when caching/flushing/retrieving function results.
71
+ */
72
+ id: string;
73
+ }
74
+
35
75
  interface MeshCallFlushParams {
76
+ /**
77
+ * namespace for grouping common functions
78
+ */
36
79
  namespace?: string;
37
- id: string;
80
+ /**
81
+ * id for cached response to flush
82
+ */
83
+ id?: string;
84
+ /**
85
+ * topic assigned to the worker when it was connected
86
+ */
38
87
  topic: string;
88
+ /**
89
+ * Redis configuration
90
+ */
39
91
  redis: RedisConfig;
92
+ /**
93
+ * Options for the flush
94
+ */
95
+ options?: MeshCallFlushOptions;
40
96
  }
41
-
42
97
  interface MeshCallCronOptions {
43
98
  /**
44
99
  * Idempotent GUID for the function
@@ -50,14 +105,15 @@ interface MeshCallCronOptions {
50
105
  */
51
106
  interval: string;
52
107
  /**
53
- * Maximum number of cycles to run before stopping.
108
+ * Maximum number of cycles to run before exiting the cron.
54
109
  */
55
110
  maxCycles?: number;
56
111
  /**
57
- * Maximum duration to run before stopping the cron.
58
- * Refer to the syntax for the `ms` NPM package.
112
+ * Time in seconds to sleep before invoking the first cycle.
113
+ * For example, `1 day`, `1 hour`. Fidelity is generally
114
+ * within 5 seconds. Refer to the syntax for the `ms` NPM package.
59
115
  */
60
- maxDuration?: string;
116
+ delay?: string;
61
117
  }
62
118
 
63
119
  interface MeshCallInterruptOptions {
@@ -95,9 +151,9 @@ interface MeshCallCronParams {
95
151
  */
96
152
  args: any[];
97
153
  /**
98
- * Callback function to invoke each time the cron job runs; `args` will be passed
154
+ * linked worker function to run
99
155
  */
100
- callback: <T extends any[], U>(...args: T) => Promise<U>;
156
+ callback: (...args: any[]) => any;
101
157
  /**
102
158
  * Options for the cron job
103
159
  */
@@ -105,9 +161,21 @@ interface MeshCallCronParams {
105
161
  }
106
162
 
107
163
  interface MeshCallInterruptParams {
164
+ /**
165
+ * namespace for grouping common functions
166
+ */
108
167
  namespace?: string;
168
+ /**
169
+ * topic assigned to the cron worker when it was connected
170
+ */
109
171
  topic: string;
172
+ /**
173
+ * Redis configuration
174
+ */
110
175
  redis: RedisConfig;
176
+ /**
177
+ * Options for interrupting the cron
178
+ */
111
179
  options: MeshCallInterruptOptions;
112
180
  }
113
181
 
@@ -119,5 +187,6 @@ export {
119
187
  MeshCallCronOptions,
120
188
  MeshCallInterruptOptions,
121
189
  MeshCallInterruptParams,
190
+ MeshCallFlushOptions,
122
191
  MeshCallFlushParams,
123
192
  };