@hotmeshio/hotmesh 0.3.18 → 0.3.20
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 +194 -68
- package/build/index.d.ts +5 -1
- package/build/index.js +9 -1
- package/build/modules/key.js +1 -1
- package/build/modules/utils.d.ts +0 -1
- package/build/modules/utils.js +1 -1
- package/build/package.json +10 -7
- package/build/services/activities/activity.js +1 -1
- package/build/services/activities/await.js +1 -1
- package/build/services/activities/cycle.js +1 -1
- package/build/services/activities/hook.js +1 -1
- package/build/services/activities/index.js +1 -1
- package/build/services/activities/interrupt.js +1 -1
- package/build/services/activities/signal.js +1 -1
- package/build/services/activities/trigger.js +1 -1
- package/build/services/activities/worker.js +1 -1
- package/build/services/collator/index.js +1 -1
- package/build/services/compiler/deployer.js +1 -1
- package/build/services/compiler/index.js +1 -1
- package/build/services/compiler/validator.js +1 -1
- package/build/services/connector/factory.d.ts +1 -0
- package/build/services/connector/factory.js +22 -21
- package/build/services/connector/index.d.ts +4 -2
- package/build/services/connector/index.js +10 -5
- package/build/services/connector/providers/postgres.d.ts +13 -2
- package/build/services/connector/providers/postgres.js +54 -9
- package/build/services/engine/index.d.ts +1 -1
- package/build/services/engine/index.js +1 -1
- package/build/services/exporter/index.js +1 -1
- package/build/services/hotmesh/index.js +1 -6
- package/build/services/mapper/index.js +1 -1
- package/build/services/meshflow/connection.js +1 -0
- package/build/services/meshflow/exporter.js +1 -1
- package/build/services/pipe/functions/array.js +1 -1
- package/build/services/pipe/functions/bitwise.js +1 -1
- package/build/services/pipe/functions/conditional.js +1 -1
- package/build/services/pipe/functions/cron.js +1 -1
- package/build/services/pipe/functions/date.js +1 -1
- package/build/services/pipe/functions/index.js +1 -1
- package/build/services/pipe/functions/json.js +1 -1
- package/build/services/pipe/functions/logical.js +1 -1
- package/build/services/pipe/functions/math.js +1 -1
- package/build/services/pipe/functions/number.js +1 -1
- package/build/services/pipe/functions/object.js +1 -1
- package/build/services/pipe/functions/string.js +1 -1
- package/build/services/pipe/functions/symbol.js +1 -1
- package/build/services/pipe/functions/unary.js +1 -1
- package/build/services/pipe/index.js +1 -1
- package/build/services/quorum/index.d.ts +1 -1
- package/build/services/quorum/index.js +1 -1
- package/build/services/reporter/index.js +1 -1
- package/build/services/router/index.js +1 -1
- package/build/services/search/providers/postgres/postgres.js +1 -1
- package/build/services/search/providers/redis/ioredis.js +1 -1
- package/build/services/search/providers/redis/redis.js +1 -1
- package/build/services/serializer/index.js +1 -1
- package/build/services/store/providers/postgres/kvsql.js +1 -1
- package/build/services/store/providers/postgres/kvtables.d.ts +3 -2
- package/build/services/store/providers/postgres/kvtables.js +1 -1
- package/build/services/store/providers/postgres/kvtransaction.js +1 -1
- package/build/services/store/providers/postgres/kvtypes/hash.d.ts +1 -0
- package/build/services/store/providers/postgres/kvtypes/hash.js +1 -1
- package/build/services/store/providers/postgres/kvtypes/list.js +1 -1
- package/build/services/store/providers/postgres/kvtypes/string.js +1 -1
- package/build/services/store/providers/postgres/kvtypes/zset.js +1 -1
- package/build/services/store/providers/postgres/postgres.js +1 -1
- package/build/services/store/providers/redis/_base.js +1 -1
- package/build/services/store/providers/redis/ioredis.js +1 -1
- package/build/services/store/providers/redis/redis.js +1 -1
- package/build/services/store/providers/store-initializable.js +1 -1
- package/build/services/stream/providers/nats/nats.js +1 -1
- package/build/services/stream/providers/postgres/postgres.d.ts +1 -0
- package/build/services/stream/providers/postgres/postgres.js +1 -1
- package/build/services/stream/providers/redis/ioredis.js +1 -1
- package/build/services/stream/providers/redis/redis.js +1 -1
- package/build/services/stream/providers/stream-initializable.js +1 -1
- package/build/services/sub/factory.d.ts +3 -3
- package/build/services/sub/factory.js +14 -5
- package/build/services/sub/index.d.ts +3 -2
- package/build/services/sub/providers/nats/nats.d.ts +19 -0
- package/build/services/sub/providers/nats/nats.js +1 -0
- package/build/services/sub/providers/postgres/postgres.d.ts +19 -0
- package/build/services/sub/providers/postgres/postgres.js +1 -0
- package/build/services/sub/providers/redis/ioredis.d.ts +1 -1
- package/build/services/sub/providers/redis/ioredis.js +1 -1
- package/build/services/sub/providers/redis/redis.d.ts +1 -1
- package/build/services/sub/providers/redis/redis.js +1 -1
- package/build/services/task/index.js +1 -1
- package/build/services/telemetry/index.js +1 -1
- package/build/services/worker/index.d.ts +1 -1
- package/build/services/worker/index.js +1 -1
- package/build/types/nats.d.ts +8 -0
- package/build/types/postgres.d.ts +10 -1
- package/build/types/provider.d.ts +1 -0
- package/build/types/redis.d.ts +8 -8
- package/index.ts +20 -5
- package/package.json +10 -7
- package/types/nats.ts +34 -0
- package/types/postgres.ts +13 -2
- package/types/provider.ts +4 -0
- package/types/redis.ts +8 -8
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- **Serverless Orchestration**: Orchestrate
|
|
11
|
+
- **Serverless Orchestration**: Orchestrate without adding infrastructure
|
|
12
12
|
- **No Vendor Lock-in**: Use your preferred database: *Postgres*, *Redis*, ...
|
|
13
|
-
- **Linear Scalability**: Scale your database to scale your application
|
|
14
|
-
- **Process Analytics**: Gain process insights with optional analytics
|
|
13
|
+
- **Linear Scalability**: Scale your database to scale your application
|
|
14
|
+
- **Process Analytics**: Gain process insights with optional analytics
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
<br/>
|
|
@@ -25,10 +25,9 @@ npm install @hotmeshio/hotmesh
|
|
|
25
25
|
## Learn
|
|
26
26
|
[🏠 Home](https://hotmesh.io/) | [📄 SDK Docs](https://hotmeshio.github.io/sdk-typescript/) | [💼 General Examples](https://github.com/hotmeshio/samples-typescript) | [💼 Temporal Examples](https://github.com/hotmeshio/temporal-patterns-typescript)
|
|
27
27
|
|
|
28
|
-
|
|
29
28
|
<br/>
|
|
30
29
|
|
|
31
|
-
## MeshCall |
|
|
30
|
+
## MeshCall | Inter-Service Function Calls
|
|
32
31
|
[MeshCall](https://hotmeshio.github.io/sdk-typescript/classes/services_meshcall.MeshCall.html) connects any function to the mesh.
|
|
33
32
|
|
|
34
33
|
<details style="padding: .5em">
|
|
@@ -43,14 +42,16 @@ npm install @hotmeshio/hotmesh
|
|
|
43
42
|
```typescript
|
|
44
43
|
//cron.ts
|
|
45
44
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
46
|
-
import
|
|
45
|
+
import { Client as Postgres } from 'pg';
|
|
47
46
|
|
|
48
47
|
export const runMyCron = async (id: string, interval = '0 0 * * *'): Promise<boolean> => {
|
|
49
48
|
return await MeshCall.cron({
|
|
50
49
|
topic: 'my.cron.function',
|
|
51
50
|
connection: {
|
|
52
|
-
class:
|
|
53
|
-
options: {
|
|
51
|
+
class: Postgres,
|
|
52
|
+
options: {
|
|
53
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
54
|
+
}
|
|
54
55
|
},
|
|
55
56
|
callback: async () => {
|
|
56
57
|
//your code here...
|
|
@@ -78,13 +79,15 @@ npm install @hotmeshio/hotmesh
|
|
|
78
79
|
1. Use the same `id` and `topic` that were used to create the cron to cancel it.
|
|
79
80
|
```typescript
|
|
80
81
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
81
|
-
import
|
|
82
|
+
import { Client as Postgres } from 'pg';
|
|
82
83
|
|
|
83
84
|
MeshCall.interrupt({
|
|
84
85
|
topic: 'my.cron.function',
|
|
85
86
|
connection: {
|
|
86
|
-
class:
|
|
87
|
-
options: {
|
|
87
|
+
class: Postgres,
|
|
88
|
+
options: {
|
|
89
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
90
|
+
}
|
|
88
91
|
},
|
|
89
92
|
options: { id: 'myNightlyCron123' }
|
|
90
93
|
});
|
|
@@ -95,21 +98,23 @@ npm install @hotmeshio/hotmesh
|
|
|
95
98
|
<summary style="font-size:1.25em;">Call any function in any service <small>[more]</small></summary>
|
|
96
99
|
|
|
97
100
|
### Call a Function
|
|
98
|
-
Make
|
|
101
|
+
Make interservice calls that behave like HTTP but without the setup and performance overhead. This example demonstrates how to connect and call a function.
|
|
99
102
|
|
|
100
103
|
1. Call `MeshCall.connect` and provide a `topic` to uniquely identify the function.
|
|
101
104
|
|
|
102
105
|
```typescript
|
|
103
106
|
//myFunctionWrapper.ts
|
|
104
107
|
import { MeshCall, Types } from '@hotmeshio/hotmesh';
|
|
105
|
-
import
|
|
108
|
+
import { Client as Postgres } from 'pg';
|
|
106
109
|
|
|
107
110
|
export const connectMyFunction = async () => {
|
|
108
111
|
return await MeshCall.connect({
|
|
109
112
|
topic: 'my.demo.function',
|
|
110
113
|
connection: {
|
|
111
|
-
class:
|
|
112
|
-
options: {
|
|
114
|
+
class: Postgres,
|
|
115
|
+
options: {
|
|
116
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
117
|
+
}
|
|
113
118
|
},
|
|
114
119
|
callback: async (input: string) => {
|
|
115
120
|
//your code goes here; response must be JSON serializable
|
|
@@ -131,14 +136,16 @@ npm install @hotmeshio/hotmesh
|
|
|
131
136
|
|
|
132
137
|
```typescript
|
|
133
138
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
134
|
-
import
|
|
139
|
+
import { Client as Postgres } from 'pg';
|
|
135
140
|
|
|
136
141
|
const result = await MeshCall.exec({
|
|
137
142
|
topic: 'my.demo.function',
|
|
138
143
|
args: ['something'],
|
|
139
144
|
connection: {
|
|
140
|
-
class:
|
|
141
|
-
options: {
|
|
145
|
+
class: Postgres,
|
|
146
|
+
options: {
|
|
147
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
148
|
+
}
|
|
142
149
|
},
|
|
143
150
|
}); //returns `{ hello: 'something'}`
|
|
144
151
|
```
|
|
@@ -154,14 +161,16 @@ npm install @hotmeshio/hotmesh
|
|
|
154
161
|
|
|
155
162
|
```typescript
|
|
156
163
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
157
|
-
import
|
|
164
|
+
import { Client as Postgres } from 'pg';
|
|
158
165
|
|
|
159
166
|
const result = await MeshCall.exec({
|
|
160
167
|
topic: 'my.demo.function',
|
|
161
168
|
args: ['anything'],
|
|
162
169
|
connection: {
|
|
163
|
-
class:
|
|
164
|
-
options: {
|
|
170
|
+
class: Postgres,
|
|
171
|
+
options: {
|
|
172
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
173
|
+
}
|
|
165
174
|
},
|
|
166
175
|
options: { id: 'myid123', ttl: '15 minutes' },
|
|
167
176
|
}); //returns `{ hello: 'anything'}`
|
|
@@ -171,13 +180,15 @@ npm install @hotmeshio/hotmesh
|
|
|
171
180
|
|
|
172
181
|
```typescript
|
|
173
182
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
174
|
-
import
|
|
183
|
+
import { Client as Postgres } from 'pg';
|
|
175
184
|
|
|
176
185
|
await MeshCall.flush({
|
|
177
186
|
topic: 'my.demo.function',
|
|
178
187
|
connection: {
|
|
179
|
-
class:
|
|
180
|
-
options: {
|
|
188
|
+
class: Postgres,
|
|
189
|
+
options: {
|
|
190
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
191
|
+
}
|
|
181
192
|
},
|
|
182
193
|
options: { id: 'myid123' },
|
|
183
194
|
});
|
|
@@ -236,13 +247,15 @@ When an endpoint is unpredictable, use `proxyActivities`. HotMesh will retry as
|
|
|
236
247
|
```typescript
|
|
237
248
|
//client.ts
|
|
238
249
|
import { Client, HotMesh } from '@hotmeshio/hotmesh';
|
|
239
|
-
import
|
|
250
|
+
import { Client as Postgres } from 'pg';
|
|
240
251
|
|
|
241
252
|
async function run(): Promise<string> {
|
|
242
253
|
const client = new Client({
|
|
243
254
|
connection: {
|
|
244
|
-
class:
|
|
245
|
-
options: {
|
|
255
|
+
class: Postgres,
|
|
256
|
+
options: {
|
|
257
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
258
|
+
}
|
|
246
259
|
}
|
|
247
260
|
});
|
|
248
261
|
|
|
@@ -263,14 +276,16 @@ When an endpoint is unpredictable, use `proxyActivities`. HotMesh will retry as
|
|
|
263
276
|
```typescript
|
|
264
277
|
//worker.ts
|
|
265
278
|
import { worker } from '@hotmeshio/hotmesh';
|
|
266
|
-
import
|
|
279
|
+
import { Client as Postgres } from 'pg';
|
|
267
280
|
import * as workflows from './workflows';
|
|
268
281
|
|
|
269
282
|
async function run() {
|
|
270
283
|
const worker = await Worker.create({
|
|
271
284
|
connection: {
|
|
272
|
-
class:
|
|
273
|
-
options: {
|
|
285
|
+
class: Postgres,
|
|
286
|
+
options: {
|
|
287
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
288
|
+
}
|
|
274
289
|
},
|
|
275
290
|
taskQueue: 'default',
|
|
276
291
|
workflow: workflows.example,
|
|
@@ -304,13 +319,15 @@ Pause a function and only awaken when a matching signal is received from the out
|
|
|
304
319
|
```typescript
|
|
305
320
|
//client.ts
|
|
306
321
|
import { Client, HotMesh } from '@hotmeshio/hotmesh';
|
|
307
|
-
import
|
|
322
|
+
import { Client as Postgres } from 'pg';
|
|
308
323
|
|
|
309
324
|
async function run(): Promise<string> {
|
|
310
325
|
const client = new Client({
|
|
311
326
|
connection: {
|
|
312
|
-
class:
|
|
313
|
-
options: {
|
|
327
|
+
class: Postgres,
|
|
328
|
+
options: {
|
|
329
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
330
|
+
}
|
|
314
331
|
}
|
|
315
332
|
});
|
|
316
333
|
|
|
@@ -330,14 +347,16 @@ Pause a function and only awaken when a matching signal is received from the out
|
|
|
330
347
|
```typescript
|
|
331
348
|
//worker.ts
|
|
332
349
|
import { Worker } from '@hotmeshio/hotmesh';
|
|
333
|
-
import
|
|
350
|
+
import { Client as Postgres } from 'pg';
|
|
334
351
|
import * as workflows from './waitForWorkflow';
|
|
335
352
|
|
|
336
353
|
async function run() {
|
|
337
354
|
const worker = await Worker.create({
|
|
338
355
|
connection: {
|
|
339
|
-
class:
|
|
340
|
-
options: {
|
|
356
|
+
class: Postgres,
|
|
357
|
+
options: {
|
|
358
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
359
|
+
}
|
|
341
360
|
},
|
|
342
361
|
taskQueue: 'default',
|
|
343
362
|
workflow: workflows.waitForExample,
|
|
@@ -351,12 +370,14 @@ Pause a function and only awaken when a matching signal is received from the out
|
|
|
351
370
|
|
|
352
371
|
```typescript
|
|
353
372
|
import { Client } from '@hotmeshio/hotmesh';
|
|
354
|
-
import
|
|
373
|
+
import { Client as Postgres } from 'pg';
|
|
355
374
|
|
|
356
375
|
const client = new Client({
|
|
357
376
|
connection: {
|
|
358
|
-
class:
|
|
359
|
-
options: {
|
|
377
|
+
class: Postgres,
|
|
378
|
+
options: {
|
|
379
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
380
|
+
}
|
|
360
381
|
}
|
|
361
382
|
});
|
|
362
383
|
|
|
@@ -400,12 +421,14 @@ Use a standard `Promise` to collate and cache multiple signals. HotMesh will onl
|
|
|
400
421
|
|
|
401
422
|
```typescript
|
|
402
423
|
import { Client } from '@hotmeshio/hotmesh';
|
|
403
|
-
import
|
|
424
|
+
import { Client as Postgres } from 'pg';
|
|
404
425
|
|
|
405
426
|
const client = new Client({
|
|
406
427
|
connection: {
|
|
407
|
-
class:
|
|
408
|
-
options: {
|
|
428
|
+
class: Postgres,
|
|
429
|
+
options: {
|
|
430
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
431
|
+
}
|
|
409
432
|
}
|
|
410
433
|
});
|
|
411
434
|
|
|
@@ -456,13 +479,15 @@ This example calls an activity and then sleeps for a week. It runs indefinitely
|
|
|
456
479
|
```typescript
|
|
457
480
|
//client.ts
|
|
458
481
|
import { Client, HotMesh } from '@hotmeshio/hotmesh';
|
|
459
|
-
import
|
|
482
|
+
import { Client as Postgres } from 'pg';
|
|
460
483
|
|
|
461
484
|
async function run(): Promise<string> {
|
|
462
485
|
const client = new Client({
|
|
463
486
|
connection: {
|
|
464
|
-
class:
|
|
465
|
-
options: {
|
|
487
|
+
class: Postgres,
|
|
488
|
+
options: {
|
|
489
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
490
|
+
}
|
|
466
491
|
}
|
|
467
492
|
});
|
|
468
493
|
|
|
@@ -482,14 +507,16 @@ This example calls an activity and then sleeps for a week. It runs indefinitely
|
|
|
482
507
|
```typescript
|
|
483
508
|
//worker.ts
|
|
484
509
|
import { Worker } from '@hotmeshio/hotmesh';
|
|
485
|
-
import
|
|
510
|
+
import { Client as Postgres } from 'pg';
|
|
486
511
|
import * as workflows from './recurringWorkflow';
|
|
487
512
|
|
|
488
513
|
async function run() {
|
|
489
514
|
const worker = await Worker.create({
|
|
490
515
|
connection: {
|
|
491
|
-
class:
|
|
492
|
-
options: {
|
|
516
|
+
class: Postgres,
|
|
517
|
+
options: {
|
|
518
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
519
|
+
}
|
|
493
520
|
},
|
|
494
521
|
taskQueue: 'default',
|
|
495
522
|
workflow: workflows.recurringExample,
|
|
@@ -503,12 +530,14 @@ This example calls an activity and then sleeps for a week. It runs indefinitely
|
|
|
503
530
|
|
|
504
531
|
```typescript
|
|
505
532
|
import { Client } from '@hotmeshio/hotmesh';
|
|
506
|
-
import
|
|
533
|
+
import { Client as Postgres } from 'pg';
|
|
507
534
|
|
|
508
535
|
const client = new Client({
|
|
509
536
|
connection: {
|
|
510
|
-
class:
|
|
511
|
-
options: {
|
|
537
|
+
class: Postgres,
|
|
538
|
+
options: {
|
|
539
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
540
|
+
}
|
|
512
541
|
}
|
|
513
542
|
});
|
|
514
543
|
|
|
@@ -525,7 +554,7 @@ This example calls an activity and then sleeps for a week. It runs indefinitely
|
|
|
525
554
|
<br/>
|
|
526
555
|
|
|
527
556
|
## MeshData | Transactional Analytics
|
|
528
|
-
[MeshData](https://hotmeshio.github.io/sdk-typescript/classes/services_meshdata.MeshData.html) adds analytics to
|
|
557
|
+
[MeshData](https://hotmeshio.github.io/sdk-typescript/classes/services_meshdata.MeshData.html) adds analytics to transactional workflows.
|
|
529
558
|
|
|
530
559
|
<details style="padding: .5em">
|
|
531
560
|
<summary style="font-size:1.25em;">Create a search index <small>[more]</small></summary>
|
|
@@ -555,12 +584,14 @@ This example demonstrates how to define a schema and deploy an index for a 'user
|
|
|
555
584
|
```typescript
|
|
556
585
|
//server.ts
|
|
557
586
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
558
|
-
import
|
|
587
|
+
import { Client as Postgres } from 'pg';
|
|
559
588
|
import { schema } from './schema';
|
|
560
589
|
|
|
561
590
|
const meshData = new MeshData(
|
|
562
|
-
|
|
563
|
-
|
|
591
|
+
Postgres,
|
|
592
|
+
options: {
|
|
593
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
594
|
+
},
|
|
564
595
|
schema,
|
|
565
596
|
);
|
|
566
597
|
await meshData.createSearchIndex('user', { namespace: 'meshdata' });
|
|
@@ -578,13 +609,15 @@ This example demonstrates how to create a 'user' workflow backed by the searchab
|
|
|
578
609
|
```typescript
|
|
579
610
|
//connect.ts
|
|
580
611
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
581
|
-
import
|
|
612
|
+
import { Client as Postgres } from 'pg';
|
|
582
613
|
import { schema } from './schema';
|
|
583
614
|
|
|
584
615
|
export const connectUserWorker = async (): Promise<void> => {
|
|
585
616
|
const meshData = new MeshData(
|
|
586
|
-
|
|
587
|
-
|
|
617
|
+
Postgres,
|
|
618
|
+
options: {
|
|
619
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
620
|
+
},
|
|
588
621
|
schema,
|
|
589
622
|
);
|
|
590
623
|
|
|
@@ -614,11 +647,13 @@ This example demonstrates how to create a 'user' workflow backed by the searchab
|
|
|
614
647
|
```typescript
|
|
615
648
|
//exec.ts
|
|
616
649
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
617
|
-
import
|
|
650
|
+
import { Client as Postgres } from 'pg';
|
|
618
651
|
|
|
619
652
|
const meshData = new MeshData(
|
|
620
|
-
|
|
621
|
-
|
|
653
|
+
Postgres,
|
|
654
|
+
options: {
|
|
655
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
656
|
+
},
|
|
622
657
|
schema,
|
|
623
658
|
);
|
|
624
659
|
|
|
@@ -658,12 +693,14 @@ This example demonstrates how to read data fields directly from a workflow.
|
|
|
658
693
|
```typescript
|
|
659
694
|
//read.ts
|
|
660
695
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
661
|
-
import
|
|
696
|
+
import { Client as Postgres } from 'pg';
|
|
662
697
|
import { schema } from './schema';
|
|
663
698
|
|
|
664
699
|
const meshData = new MeshData(
|
|
665
|
-
|
|
666
|
-
|
|
700
|
+
Postgres,
|
|
701
|
+
options: {
|
|
702
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
703
|
+
},
|
|
667
704
|
schema,
|
|
668
705
|
);
|
|
669
706
|
|
|
@@ -689,12 +726,14 @@ This example demonstrates how to search for those workflows where a given condit
|
|
|
689
726
|
```typescript
|
|
690
727
|
//read.ts
|
|
691
728
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
692
|
-
import
|
|
729
|
+
import { Client as Postgres } from 'pg';
|
|
693
730
|
import { schema } from './schema';
|
|
694
731
|
|
|
695
732
|
const meshData = new MeshData(
|
|
696
|
-
|
|
697
|
-
|
|
733
|
+
Postgres,
|
|
734
|
+
options: {
|
|
735
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
736
|
+
},
|
|
698
737
|
schema,
|
|
699
738
|
);
|
|
700
739
|
|
|
@@ -708,8 +747,95 @@ This example demonstrates how to search for those workflows where a given condit
|
|
|
708
747
|
|
|
709
748
|
<br/>
|
|
710
749
|
|
|
750
|
+
## Connect
|
|
751
|
+
HotMesh is pluggable and ships with support for Postgres (pg) and Redis (ioredis/redis). NATS is also supported for PubSub for extended patterns.
|
|
752
|
+
|
|
753
|
+
<details style="padding: .5em">
|
|
754
|
+
<summary style="font-size:1.25em;">Postgres <small>[more]</small></summary>
|
|
755
|
+
|
|
756
|
+
### Connect Postgres Client
|
|
757
|
+
```typescript
|
|
758
|
+
import { Client as PostgresClient } from 'pg';
|
|
759
|
+
|
|
760
|
+
//provide these credentials to HotMesh
|
|
761
|
+
const connection = {
|
|
762
|
+
class: PostgresClient,
|
|
763
|
+
options: {
|
|
764
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
```
|
|
769
|
+
### Connect Postgres Pool
|
|
770
|
+
Pool connections are recommended for high-throughput applications. The pool will manage connections and automatically handle connection pooling.
|
|
771
|
+
```typescript
|
|
772
|
+
import { Pool as PostgresPool } from 'pg';
|
|
773
|
+
|
|
774
|
+
const PostgresPoolClient = new PostgresPool({
|
|
775
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
//provide these credentials to HotMesh
|
|
779
|
+
const connection = {
|
|
780
|
+
class: PostgresPoolClient,
|
|
781
|
+
options: {}
|
|
782
|
+
};
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
</details>
|
|
786
|
+
|
|
787
|
+
<details style="padding: .5em">
|
|
788
|
+
<summary style="font-size:1.25em;">Redis <small>[more]</small></summary>
|
|
789
|
+
|
|
790
|
+
### Redis/IORedis
|
|
791
|
+
```typescript
|
|
792
|
+
import * as Redis from 'redis';
|
|
793
|
+
//OR `import Redis from 'ioredis';`
|
|
794
|
+
|
|
795
|
+
const connection = {
|
|
796
|
+
class: Redis,
|
|
797
|
+
options: {
|
|
798
|
+
url: 'redis://:your_password@localhost:6379',
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
```
|
|
802
|
+
</details>
|
|
803
|
+
|
|
804
|
+
<details style="padding: .5em">
|
|
805
|
+
<summary style="font-size:1.25em;">NATS <small>[more]</small></summary>
|
|
806
|
+
|
|
807
|
+
### NATS PubSub
|
|
808
|
+
Add NATS for improved PubSub support, including patterned subscriptions. Note the explicit channel subscription in the example below. *The NATS provider supports version 2.0 of the NATS client (the latest version). See ./package.json for details.*
|
|
809
|
+
|
|
810
|
+
```typescript
|
|
811
|
+
import { Client as Postgres } from 'pg';
|
|
812
|
+
import { connect as NATS } from 'nats';
|
|
813
|
+
|
|
814
|
+
const connection = {
|
|
815
|
+
store: {
|
|
816
|
+
class: Postgres,
|
|
817
|
+
options: {
|
|
818
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
stream: {
|
|
822
|
+
class: Postgres,
|
|
823
|
+
options: {
|
|
824
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
sub: {
|
|
828
|
+
class: NATS,
|
|
829
|
+
options: { servers: ['nats:4222'] }
|
|
830
|
+
},
|
|
831
|
+
};
|
|
832
|
+
```
|
|
833
|
+
</details>
|
|
834
|
+
|
|
835
|
+
<br/>
|
|
836
|
+
|
|
711
837
|
## Metrics and Monitoring
|
|
712
|
-
HotMesh's **OpenTelemetry** output provides
|
|
838
|
+
HotMesh's **OpenTelemetry** output provides insight into long-running, cross-service transactions. Add an OpenTelemetry sink to any service where HotMesh is deployed and HotMesh will emit the full **OpenTelemetry** execution tree organized as a single, unified DAG.
|
|
713
839
|
|
|
714
840
|
The **HotMesh Dashboard** provides a detailed overview of all running workflows. It includes an LLM to simplify querying and analyzing workflow data. An example Web server with REST APIs and the Dashboard (a WebApp) is included in the [samples-typescript](https://github.com/hotmeshio/samples-typescript) Git repo.
|
|
715
841
|
|
package/build/index.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ import { MeshOS } from './services/meshos';
|
|
|
8
8
|
import * as Errors from './modules/errors';
|
|
9
9
|
import * as Utils from './modules/utils';
|
|
10
10
|
import { ConnectorService as Connector } from './services/connector/factory';
|
|
11
|
+
import { PostgresConnection as ConnectorPostgres } from './services/connector/providers/postgres';
|
|
12
|
+
import { RedisConnection as ConnectorIORedis } from './services/connector/providers/ioredis';
|
|
13
|
+
import { RedisConnection as ConnectorRedis } from './services/connector/providers/redis';
|
|
14
|
+
import { NatsConnection as ConnectorNATS } from './services/connector/providers/nats';
|
|
11
15
|
declare const Client: typeof import("./services/meshflow/client").ClientService, Connection: typeof import("./services/meshflow/connection").ConnectionService, Search: typeof import("./services/meshflow/search").Search, Worker: typeof import("./services/meshflow/worker").WorkerService, workflow: typeof import("./services/meshflow/workflow").WorkflowService;
|
|
12
|
-
export {
|
|
16
|
+
export { Connector, ConnectorIORedis, ConnectorNATS, ConnectorPostgres, ConnectorRedis, HotMesh, HotMeshConfig, MeshCall, MeshData, MeshFlow, MeshOS, Client, Connection, Search, Worker, workflow, WorkflowHandle, Errors, Utils, };
|
|
13
17
|
export * as Types from './types';
|
package/build/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Types = exports.WorkflowHandle = exports.workflow = exports.Worker = exports.
|
|
26
|
+
exports.Types = exports.Utils = exports.Errors = exports.WorkflowHandle = exports.workflow = exports.Worker = exports.Search = exports.Connection = exports.Client = exports.MeshOS = exports.MeshFlow = exports.MeshData = exports.MeshCall = exports.HotMesh = exports.ConnectorRedis = exports.ConnectorPostgres = exports.ConnectorNATS = exports.ConnectorIORedis = exports.Connector = void 0;
|
|
27
27
|
const hotmesh_1 = require("./services/hotmesh");
|
|
28
28
|
Object.defineProperty(exports, "HotMesh", { enumerable: true, get: function () { return hotmesh_1.HotMesh; } });
|
|
29
29
|
const meshcall_1 = require("./services/meshcall");
|
|
@@ -42,6 +42,14 @@ const Utils = __importStar(require("./modules/utils"));
|
|
|
42
42
|
exports.Utils = Utils;
|
|
43
43
|
const factory_1 = require("./services/connector/factory");
|
|
44
44
|
Object.defineProperty(exports, "Connector", { enumerable: true, get: function () { return factory_1.ConnectorService; } });
|
|
45
|
+
const postgres_1 = require("./services/connector/providers/postgres");
|
|
46
|
+
Object.defineProperty(exports, "ConnectorPostgres", { enumerable: true, get: function () { return postgres_1.PostgresConnection; } });
|
|
47
|
+
const ioredis_1 = require("./services/connector/providers/ioredis");
|
|
48
|
+
Object.defineProperty(exports, "ConnectorIORedis", { enumerable: true, get: function () { return ioredis_1.RedisConnection; } });
|
|
49
|
+
const redis_1 = require("./services/connector/providers/redis");
|
|
50
|
+
Object.defineProperty(exports, "ConnectorRedis", { enumerable: true, get: function () { return redis_1.RedisConnection; } });
|
|
51
|
+
const nats_1 = require("./services/connector/providers/nats");
|
|
52
|
+
Object.defineProperty(exports, "ConnectorNATS", { enumerable: true, get: function () { return nats_1.NatsConnection; } });
|
|
45
53
|
const { Client, Connection, Search, Worker, workflow } = meshflow_1.MeshFlow;
|
|
46
54
|
exports.Client = Client;
|
|
47
55
|
exports.Connection = Connection;
|
package/build/modules/key.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';(function(
|
|
1
|
+
'use strict';(function(_0x4971ea,_0x1d4d46){const _0xd9e3cb=_0x59a9,_0x5d7ec7=_0x4971ea();while(!![]){try{const _0x61199e=parseInt(_0xd9e3cb(0x6b))/0x1+parseInt(_0xd9e3cb(0x66))/0x2*(-parseInt(_0xd9e3cb(0x6a))/0x3)+-parseInt(_0xd9e3cb(0x6c))/0x4+-parseInt(_0xd9e3cb(0x69))/0x5*(parseInt(_0xd9e3cb(0x67))/0x6)+parseInt(_0xd9e3cb(0x6d))/0x7*(-parseInt(_0xd9e3cb(0x65))/0x8)+-parseInt(_0xd9e3cb(0x68))/0x9+parseInt(_0xd9e3cb(0x64))/0xa*(parseInt(_0xd9e3cb(0x6e))/0xb);if(_0x61199e===_0x1d4d46)break;else _0x5d7ec7['push'](_0x5d7ec7['shift']());}catch(_0x238bc1){_0x5d7ec7['push'](_0x5d7ec7['shift']());}}}(_0x5903,0x55dd9));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['VALSEP']=exports['WEBSEP']=exports['TYPSEP']=exports['KEYSEP']=exports['HMNS']=exports['KeyType']=exports['KeyService']=void 0x0;const hotmesh_1=require('../types/hotmesh');Object['defineProperty'](exports,'KeyType',{'enumerable':!![],'get':function(){return hotmesh_1['KeyType'];}});const HMNS='hmsh';exports['HMNS']=HMNS;const KEYSEP=':';exports['KEYSEP']=KEYSEP;const VALSEP='::';exports['VALSEP']=VALSEP;const WEBSEP='::';function _0x59a9(_0x2648a5,_0x1dd24f){const _0x590375=_0x5903();return _0x59a9=function(_0x59a990,_0x47f0ca){_0x59a990=_0x59a990-0x64;let _0x143d2e=_0x590375[_0x59a990];return _0x143d2e;},_0x59a9(_0x2648a5,_0x1dd24f);}exports['WEBSEP']=WEBSEP;const TYPSEP='::';exports['TYPSEP']=TYPSEP;class KeyService{static['mintKey'](_0xf2202b,_0x1046c4,_0x2322ac){switch(_0x1046c4){case hotmesh_1['KeyType']['HOTMESH']:return _0xf2202b;case hotmesh_1['KeyType']['THROTTLE_RATE']:return _0xf2202b+':'+_0x2322ac['appId']+':r:';case hotmesh_1['KeyType']['WORK_ITEMS']:return _0xf2202b+':'+_0x2322ac['appId']+':w:'+(_0x2322ac['scoutType']||'');case hotmesh_1['KeyType']['TIME_RANGE']:return _0xf2202b+':'+_0x2322ac['appId']+':t:'+(_0x2322ac['timeValue']||'');case hotmesh_1['KeyType']['APP']:return _0xf2202b+':a:'+(_0x2322ac['appId']||'');case hotmesh_1['KeyType']['QUORUM']:return _0xf2202b+':'+_0x2322ac['appId']+':q:'+(_0x2322ac['engineId']||'');case hotmesh_1['KeyType']['JOB_STATE']:return _0xf2202b+':'+_0x2322ac['appId']+':j:'+_0x2322ac['jobId'];case hotmesh_1['KeyType']['JOB_DEPENDENTS']:return _0xf2202b+':'+_0x2322ac['appId']+':d:'+_0x2322ac['jobId'];case hotmesh_1['KeyType']['JOB_STATS_GENERAL']:return _0xf2202b+':'+_0x2322ac['appId']+':s:'+_0x2322ac['jobKey']+':'+_0x2322ac['dateTime'];case hotmesh_1['KeyType']['JOB_STATS_MEDIAN']:return _0xf2202b+':'+_0x2322ac['appId']+':s:'+_0x2322ac['jobKey']+':'+_0x2322ac['dateTime']+':'+_0x2322ac['facet'];case hotmesh_1['KeyType']['JOB_STATS_INDEX']:return _0xf2202b+':'+_0x2322ac['appId']+':s:'+_0x2322ac['jobKey']+':'+_0x2322ac['dateTime']+':'+_0x2322ac['facet'];case hotmesh_1['KeyType']['SCHEMAS']:return _0xf2202b+':'+_0x2322ac['appId']+':v:'+_0x2322ac['appVersion']+':schemas';case hotmesh_1['KeyType']['SUBSCRIPTIONS']:return _0xf2202b+':'+_0x2322ac['appId']+':v:'+_0x2322ac['appVersion']+':subscriptions';case hotmesh_1['KeyType']['SUBSCRIPTION_PATTERNS']:return _0xf2202b+':'+_0x2322ac['appId']+':v:'+_0x2322ac['appVersion']+':transitions';case hotmesh_1['KeyType']['HOOKS']:return _0xf2202b+':'+_0x2322ac['appId']+':hooks';case hotmesh_1['KeyType']['SIGNALS']:return _0xf2202b+':'+_0x2322ac['appId']+':signals';case hotmesh_1['KeyType']['SYMKEYS']:return _0xf2202b+':'+_0x2322ac['appId']+':sym:keys:'+(_0x2322ac['activityId']||'');case hotmesh_1['KeyType']['SYMVALS']:return _0xf2202b+':'+_0x2322ac['appId']+':sym:vals:';case hotmesh_1['KeyType']['STREAMS']:return _0xf2202b+':'+(_0x2322ac['appId']||'')+':x:'+(_0x2322ac['topic']||'');default:throw new Error('Invalid\x20key\x20type.');}}static['parseKey'](_0x4afb5c){const [_0x5691ba,_0x2cdef1,_0x4924ea,..._0x4c6890]=_0x4afb5c['split'](KEYSEP),_0x54c12f=_0x4c6890['join'](KEYSEP)||'';return{'namespace':_0x5691ba,'app':_0x4924ea==='a'?_0x2cdef1:undefined,'entity':_0x4924ea,'id':_0x54c12f};}static['reconstituteKey'](_0x4f4f36){const {namespace:_0x40cf9e,app:_0x3eb379,entity:_0x92eead,id:_0x43ab3a}=_0x4f4f36;return''+_0x40cf9e+KEYSEP+_0x3eb379+KEYSEP+_0x92eead+KEYSEP+(_0x43ab3a||'');}static['resolveEntityType'](_0x48d108,_0x19dfe5=''){switch(_0x48d108){case'a':return'applications';case'r':return'throttles';case'w':return _0x19dfe5===''?'task_priorities':'roles';case't':return _0x19dfe5===''?'task_schedules':'task_lists';case'q':return'events';case'j':return'jobs';case's':return'stats';case'v':return'versions';case'x':return _0x19dfe5===''?'streams':'stream_topics';case'hooks':return'signal_patterns';case'signals':return'signal_registry';case'sym':return'symbols';default:return'unknown_entity';}}static['resolveAbbreviation'](_0x3b6949){switch(_0x3b6949){case'applications':return'a';case'throttles':return'r';case'roles':return'w';case'task_schedules':return't';case'task_lists':return't';case'events':return'q';case'jobs':return'j';case'stats':return's';case'versions':return'v';case'streams':return'x';case'signal_patterns':return'hooks';case'signal_registry':return'signals';case'symbols':return'sym';default:return'unknown_entity';}}}function _0x5903(){const _0x41d15b=['632973asyGkq','410YnnQtm','5550088VjCAMz','2ilcWCw','6yBAhkm','1081017rqDaBL','3190885mbCrYY','871323TkKZNQ','384802BhpKXT','2599472jVZbrW','7PGgrHg'];_0x5903=function(){return _0x41d15b;};return _0x5903();}exports['KeyService']=KeyService;
|
package/build/modules/utils.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ export declare const polyfill: {
|
|
|
27
27
|
redisOptions?: StringAnyType;
|
|
28
28
|
}): Partial<ProviderConfig> | Partial<ProvidersConfig>;
|
|
29
29
|
};
|
|
30
|
-
export declare function identifyRedisTypeFromClass(redisClass: any): 'redis' | 'ioredis' | null;
|
|
31
30
|
export declare function matchesStatusCode(code: StreamCode, pattern: string | RegExp): boolean;
|
|
32
31
|
export declare function matchesStatus(status: StreamStatus, targetStatus: StreamStatus): boolean;
|
|
33
32
|
export declare function findTopKey(obj: AppTransitions, input: string): string | null;
|