@hotmeshio/hotmesh 0.3.32 → 0.4.0
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 +128 -823
- package/build/index.d.ts +9 -9
- package/build/index.js +10 -10
- package/build/package.json +22 -21
- package/build/types/error.d.ts +5 -5
- package/build/types/exporter.d.ts +1 -1
- package/build/types/index.d.ts +3 -3
- package/build/types/manifest.d.ts +2 -2
- package/build/types/{meshflow.d.ts → memflow.d.ts} +15 -15
- package/build/types/meshdata.d.ts +3 -3
- package/build/types/postgres.d.ts +7 -0
- package/build/types/stream.d.ts +3 -0
- package/index.ts +11 -11
- package/package.json +22 -21
- package/typedoc.json +8 -7
- package/types/error.ts +5 -5
- package/types/exporter.ts +1 -1
- package/types/index.ts +7 -7
- package/types/manifest.ts +2 -2
- package/types/{meshflow.ts → memflow.ts} +15 -15
- package/types/meshdata.ts +3 -3
- package/types/postgres.ts +9 -0
- package/types/stream.ts +4 -0
- package/build/modules/enums.d.ts +0 -110
- package/build/modules/enums.js +0 -134
- package/build/modules/errors.d.ts +0 -124
- package/build/modules/errors.js +0 -191
- package/build/modules/key.d.ts +0 -66
- package/build/modules/key.js +0 -1
- package/build/modules/storage.d.ts +0 -3
- package/build/modules/storage.js +0 -5
- package/build/modules/utils.d.ts +0 -119
- package/build/modules/utils.js +0 -1
- package/build/services/activities/activity.d.ts +0 -104
- package/build/services/activities/activity.js +0 -1
- package/build/services/activities/await.d.ts +0 -12
- package/build/services/activities/await.js +0 -1
- package/build/services/activities/cycle.d.ts +0 -19
- package/build/services/activities/cycle.js +0 -1
- package/build/services/activities/hook.d.ts +0 -27
- package/build/services/activities/hook.js +0 -1
- package/build/services/activities/index.d.ts +0 -19
- package/build/services/activities/index.js +0 -1
- package/build/services/activities/interrupt.d.ts +0 -16
- package/build/services/activities/interrupt.js +0 -1
- package/build/services/activities/signal.d.ts +0 -20
- package/build/services/activities/signal.js +0 -1
- package/build/services/activities/trigger.d.ts +0 -37
- package/build/services/activities/trigger.js +0 -1
- package/build/services/activities/worker.d.ts +0 -12
- package/build/services/activities/worker.js +0 -1
- package/build/services/collator/index.d.ts +0 -111
- package/build/services/collator/index.js +0 -1
- package/build/services/compiler/deployer.d.ts +0 -40
- package/build/services/compiler/deployer.js +0 -1
- package/build/services/compiler/index.d.ts +0 -32
- package/build/services/compiler/index.js +0 -1
- package/build/services/compiler/validator.d.ts +0 -34
- package/build/services/compiler/validator.js +0 -1
- package/build/services/connector/factory.d.ts +0 -22
- package/build/services/connector/factory.js +0 -99
- package/build/services/connector/index.d.ts +0 -30
- package/build/services/connector/index.js +0 -54
- package/build/services/connector/providers/ioredis.d.ts +0 -9
- package/build/services/connector/providers/ioredis.js +0 -26
- package/build/services/connector/providers/nats.d.ts +0 -9
- package/build/services/connector/providers/nats.js +0 -34
- package/build/services/connector/providers/postgres.d.ts +0 -20
- package/build/services/connector/providers/postgres.js +0 -102
- package/build/services/connector/providers/redis.d.ts +0 -9
- package/build/services/connector/providers/redis.js +0 -38
- package/build/services/engine/index.d.ts +0 -264
- package/build/services/engine/index.js +0 -1
- package/build/services/exporter/index.d.ts +0 -44
- package/build/services/exporter/index.js +0 -1
- package/build/services/hotmesh/index.d.ts +0 -340
- package/build/services/hotmesh/index.js +0 -479
- package/build/services/logger/index.d.ts +0 -16
- package/build/services/logger/index.js +0 -54
- package/build/services/mapper/index.d.ts +0 -28
- package/build/services/mapper/index.js +0 -1
- package/build/services/meshcall/index.d.ts +0 -194
- package/build/services/meshcall/index.js +0 -452
- package/build/services/meshcall/schemas/factory.d.ts +0 -9
- package/build/services/meshcall/schemas/factory.js +0 -189
- package/build/services/meshdata/index.d.ts +0 -795
- package/build/services/meshdata/index.js +0 -1235
- package/build/services/meshflow/client.d.ts +0 -108
- package/build/services/meshflow/client.js +0 -371
- package/build/services/meshflow/connection.d.ts +0 -23
- package/build/services/meshflow/connection.js +0 -33
- package/build/services/meshflow/exporter.d.ts +0 -51
- package/build/services/meshflow/exporter.js +0 -1
- package/build/services/meshflow/handle.d.ts +0 -90
- package/build/services/meshflow/handle.js +0 -176
- package/build/services/meshflow/index.d.ts +0 -111
- package/build/services/meshflow/index.js +0 -117
- package/build/services/meshflow/schemas/factory.d.ts +0 -29
- package/build/services/meshflow/schemas/factory.js +0 -2492
- package/build/services/meshflow/search.d.ts +0 -142
- package/build/services/meshflow/search.js +0 -320
- package/build/services/meshflow/worker.d.ts +0 -124
- package/build/services/meshflow/worker.js +0 -514
- package/build/services/meshflow/workflow/all.d.ts +0 -7
- package/build/services/meshflow/workflow/all.js +0 -15
- package/build/services/meshflow/workflow/common.d.ts +0 -18
- package/build/services/meshflow/workflow/common.js +0 -45
- package/build/services/meshflow/workflow/context.d.ts +0 -6
- package/build/services/meshflow/workflow/context.js +0 -45
- package/build/services/meshflow/workflow/didRun.d.ts +0 -7
- package/build/services/meshflow/workflow/didRun.js +0 -22
- package/build/services/meshflow/workflow/emit.d.ts +0 -11
- package/build/services/meshflow/workflow/emit.js +0 -29
- package/build/services/meshflow/workflow/enrich.d.ts +0 -9
- package/build/services/meshflow/workflow/enrich.js +0 -17
- package/build/services/meshflow/workflow/execChild.d.ts +0 -18
- package/build/services/meshflow/workflow/execChild.js +0 -102
- package/build/services/meshflow/workflow/hook.d.ts +0 -9
- package/build/services/meshflow/workflow/hook.js +0 -40
- package/build/services/meshflow/workflow/index.d.ts +0 -70
- package/build/services/meshflow/workflow/index.js +0 -83
- package/build/services/meshflow/workflow/interrupt.d.ts +0 -9
- package/build/services/meshflow/workflow/interrupt.js +0 -24
- package/build/services/meshflow/workflow/isSideEffectAllowed.d.ts +0 -10
- package/build/services/meshflow/workflow/isSideEffectAllowed.js +0 -33
- package/build/services/meshflow/workflow/proxyActivities.d.ts +0 -20
- package/build/services/meshflow/workflow/proxyActivities.js +0 -97
- package/build/services/meshflow/workflow/random.d.ts +0 -6
- package/build/services/meshflow/workflow/random.js +0 -16
- package/build/services/meshflow/workflow/searchMethods.d.ts +0 -6
- package/build/services/meshflow/workflow/searchMethods.js +0 -25
- package/build/services/meshflow/workflow/signal.d.ts +0 -7
- package/build/services/meshflow/workflow/signal.js +0 -28
- package/build/services/meshflow/workflow/sleepFor.d.ts +0 -8
- package/build/services/meshflow/workflow/sleepFor.js +0 -35
- package/build/services/meshflow/workflow/trace.d.ts +0 -14
- package/build/services/meshflow/workflow/trace.js +0 -33
- package/build/services/meshflow/workflow/waitFor.d.ts +0 -8
- package/build/services/meshflow/workflow/waitFor.js +0 -35
- package/build/services/meshos/index.d.ts +0 -293
- package/build/services/meshos/index.js +0 -547
- package/build/services/pipe/functions/array.d.ts +0 -17
- package/build/services/pipe/functions/array.js +0 -1
- package/build/services/pipe/functions/bitwise.d.ts +0 -9
- package/build/services/pipe/functions/bitwise.js +0 -1
- package/build/services/pipe/functions/conditional.d.ts +0 -13
- package/build/services/pipe/functions/conditional.js +0 -1
- package/build/services/pipe/functions/cron.d.ts +0 -12
- package/build/services/pipe/functions/cron.js +0 -1
- package/build/services/pipe/functions/date.d.ts +0 -58
- package/build/services/pipe/functions/date.js +0 -1
- package/build/services/pipe/functions/index.d.ts +0 -29
- package/build/services/pipe/functions/index.js +0 -1
- package/build/services/pipe/functions/json.d.ts +0 -5
- package/build/services/pipe/functions/json.js +0 -1
- package/build/services/pipe/functions/logical.d.ts +0 -5
- package/build/services/pipe/functions/logical.js +0 -1
- package/build/services/pipe/functions/math.d.ts +0 -42
- package/build/services/pipe/functions/math.js +0 -1
- package/build/services/pipe/functions/number.d.ts +0 -21
- package/build/services/pipe/functions/number.js +0 -1
- package/build/services/pipe/functions/object.d.ts +0 -25
- package/build/services/pipe/functions/object.js +0 -1
- package/build/services/pipe/functions/string.d.ts +0 -23
- package/build/services/pipe/functions/string.js +0 -1
- package/build/services/pipe/functions/symbol.d.ts +0 -12
- package/build/services/pipe/functions/symbol.js +0 -1
- package/build/services/pipe/functions/unary.d.ts +0 -7
- package/build/services/pipe/functions/unary.js +0 -1
- package/build/services/pipe/index.d.ts +0 -48
- package/build/services/pipe/index.js +0 -1
- package/build/services/quorum/index.d.ts +0 -90
- package/build/services/quorum/index.js +0 -1
- package/build/services/reporter/index.d.ts +0 -50
- package/build/services/reporter/index.js +0 -1
- package/build/services/router/index.d.ts +0 -60
- package/build/services/router/index.js +0 -1
- package/build/services/search/factory.d.ts +0 -7
- package/build/services/search/factory.js +0 -24
- package/build/services/search/index.d.ts +0 -22
- package/build/services/search/index.js +0 -10
- package/build/services/search/providers/postgres/postgres.d.ts +0 -24
- package/build/services/search/providers/postgres/postgres.js +0 -1
- package/build/services/search/providers/redis/ioredis.d.ts +0 -18
- package/build/services/search/providers/redis/ioredis.js +0 -1
- package/build/services/search/providers/redis/redis.d.ts +0 -18
- package/build/services/search/providers/redis/redis.js +0 -1
- package/build/services/serializer/index.d.ts +0 -42
- package/build/services/serializer/index.js +0 -1
- package/build/services/store/cache.d.ts +0 -67
- package/build/services/store/cache.js +0 -128
- package/build/services/store/factory.d.ts +0 -8
- package/build/services/store/factory.js +0 -24
- package/build/services/store/index.d.ts +0 -89
- package/build/services/store/index.js +0 -9
- package/build/services/store/providers/postgres/kvsql.d.ts +0 -168
- package/build/services/store/providers/postgres/kvsql.js +0 -1
- package/build/services/store/providers/postgres/kvtables.d.ts +0 -20
- package/build/services/store/providers/postgres/kvtables.js +0 -1
- package/build/services/store/providers/postgres/kvtransaction.d.ts +0 -36
- package/build/services/store/providers/postgres/kvtransaction.js +0 -1
- package/build/services/store/providers/postgres/kvtypes/hash.d.ts +0 -60
- package/build/services/store/providers/postgres/kvtypes/hash.js +0 -1
- package/build/services/store/providers/postgres/kvtypes/list.d.ts +0 -33
- package/build/services/store/providers/postgres/kvtypes/list.js +0 -1
- package/build/services/store/providers/postgres/kvtypes/string.d.ts +0 -20
- package/build/services/store/providers/postgres/kvtypes/string.js +0 -1
- package/build/services/store/providers/postgres/kvtypes/zset.d.ts +0 -41
- package/build/services/store/providers/postgres/kvtypes/zset.js +0 -1
- package/build/services/store/providers/postgres/postgres.d.ts +0 -145
- package/build/services/store/providers/postgres/postgres.js +0 -1
- package/build/services/store/providers/redis/_base.d.ts +0 -137
- package/build/services/store/providers/redis/_base.js +0 -1
- package/build/services/store/providers/redis/ioredis.d.ts +0 -20
- package/build/services/store/providers/redis/ioredis.js +0 -1
- package/build/services/store/providers/redis/redis.d.ts +0 -18
- package/build/services/store/providers/redis/redis.js +0 -1
- package/build/services/store/providers/store-initializable.d.ts +0 -5
- package/build/services/store/providers/store-initializable.js +0 -1
- package/build/services/stream/factory.d.ts +0 -8
- package/build/services/stream/factory.js +0 -37
- package/build/services/stream/index.d.ts +0 -64
- package/build/services/stream/index.js +0 -11
- package/build/services/stream/providers/nats/nats.d.ts +0 -59
- package/build/services/stream/providers/nats/nats.js +0 -1
- package/build/services/stream/providers/postgres/kvtables.d.ts +0 -2
- package/build/services/stream/providers/postgres/kvtables.js +0 -1
- package/build/services/stream/providers/postgres/postgres.d.ts +0 -88
- package/build/services/stream/providers/postgres/postgres.js +0 -1
- package/build/services/stream/providers/redis/ioredis.d.ts +0 -60
- package/build/services/stream/providers/redis/ioredis.js +0 -1
- package/build/services/stream/providers/redis/redis.d.ts +0 -60
- package/build/services/stream/providers/redis/redis.js +0 -1
- package/build/services/stream/providers/stream-initializable.d.ts +0 -4
- package/build/services/stream/providers/stream-initializable.js +0 -1
- package/build/services/sub/factory.d.ts +0 -7
- package/build/services/sub/factory.js +0 -29
- package/build/services/sub/index.d.ts +0 -22
- package/build/services/sub/index.js +0 -10
- package/build/services/sub/providers/nats/nats.d.ts +0 -19
- package/build/services/sub/providers/nats/nats.js +0 -1
- package/build/services/sub/providers/postgres/postgres.d.ts +0 -19
- package/build/services/sub/providers/postgres/postgres.js +0 -1
- package/build/services/sub/providers/redis/ioredis.d.ts +0 -17
- package/build/services/sub/providers/redis/ioredis.js +0 -1
- package/build/services/sub/providers/redis/redis.d.ts +0 -17
- package/build/services/sub/providers/redis/redis.js +0 -1
- package/build/services/task/index.d.ts +0 -36
- package/build/services/task/index.js +0 -1
- package/build/services/telemetry/index.d.ts +0 -52
- package/build/services/telemetry/index.js +0 -1
- package/build/services/worker/index.d.ts +0 -77
- package/build/services/worker/index.js +0 -1
- /package/build/types/{meshflow.js → memflow.js} +0 -0
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { HotMesh } from '../hotmesh';
|
|
2
|
-
import { MeshCallConnectParams, MeshCallCronParams, MeshCallExecParams, MeshCallFlushParams, MeshCallInstanceOptions, MeshCallInterruptParams } from '../../types/meshcall';
|
|
3
|
-
import { ProviderConfig, ProvidersConfig } from '../../types/provider';
|
|
4
|
-
/**
|
|
5
|
-
* MeshCall connects any function as an idempotent endpoint.
|
|
6
|
-
* Call functions from anywhere on the network connected to the
|
|
7
|
-
* target backend (Postgres, Redis/ValKey, NATS, etc). Function
|
|
8
|
-
* responses are cacheable and invocations can be scheduled to
|
|
9
|
-
* run as idempotent cron jobs (this one runs nightly at midnight
|
|
10
|
-
* and uses Postgres as the backend provider).
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { Client as Postgres } from 'pg';
|
|
15
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
16
|
-
*
|
|
17
|
-
* MeshCall.cron({
|
|
18
|
-
* topic: 'my.cron.function',
|
|
19
|
-
* connection: {
|
|
20
|
-
* class: Postgres,
|
|
21
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
22
|
-
* },
|
|
23
|
-
* callback: async () => {
|
|
24
|
-
* //your code here...anything goes
|
|
25
|
-
* },
|
|
26
|
-
* options: { id: 'myDailyCron123', interval: '0 0 * * *' }
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
declare class MeshCall {
|
|
31
|
-
/**
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
static workers: Map<string, HotMesh | Promise<HotMesh>>;
|
|
35
|
-
/**
|
|
36
|
-
* @private
|
|
37
|
-
*/
|
|
38
|
-
static engines: Map<string, HotMesh | Promise<HotMesh>>;
|
|
39
|
-
/**
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
42
|
-
static connections: Map<string, any>;
|
|
43
|
-
/**
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
constructor();
|
|
47
|
-
/**
|
|
48
|
-
* iterates cached worker/engine instances to locate the first match
|
|
49
|
-
* with the provided namespace and connection options
|
|
50
|
-
* @private
|
|
51
|
-
*/
|
|
52
|
-
static findFirstMatching(targets: Map<string, HotMesh | Promise<HotMesh>>, namespace: string, config: ProviderConfig | ProvidersConfig, options?: MeshCallInstanceOptions): Promise<HotMesh | void>;
|
|
53
|
-
/**
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
static getHotMeshClient: (namespace: string, connection: ProviderConfig | ProvidersConfig, options?: MeshCallInstanceOptions) => Promise<HotMesh>;
|
|
57
|
-
/**
|
|
58
|
-
* @private
|
|
59
|
-
*/
|
|
60
|
-
static verifyWorkflowActive(hotMesh: HotMesh, appId?: string, count?: number): Promise<boolean>;
|
|
61
|
-
/**
|
|
62
|
-
* @private
|
|
63
|
-
*/
|
|
64
|
-
static activateWorkflow(hotMesh: HotMesh, appId?: string, version?: string): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Returns a cached worker instance or creates a new one
|
|
67
|
-
* @private
|
|
68
|
-
*/
|
|
69
|
-
static getInstance(namespace: string, providerConfig: ProviderConfig | ProvidersConfig, options?: MeshCallInstanceOptions): Promise<HotMesh>;
|
|
70
|
-
/**
|
|
71
|
-
* connection re-use is important when making repeated calls, but
|
|
72
|
-
* only if the connection options are an exact match. this method
|
|
73
|
-
* hashes the connection options to ensure that the same connection
|
|
74
|
-
*/
|
|
75
|
-
static hashOptions(connection: ProviderConfig | ProvidersConfig): string;
|
|
76
|
-
/**
|
|
77
|
-
* Connects and links a worker function to the mesh
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* import { Client as Postgres } from 'pg';
|
|
81
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
82
|
-
*
|
|
83
|
-
* MeshCall.connect({
|
|
84
|
-
* topic: 'my.function',
|
|
85
|
-
* connection: {
|
|
86
|
-
* class: Postgres,
|
|
87
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
88
|
-
* },
|
|
89
|
-
* callback: async (arg1: any) => {
|
|
90
|
-
* //your code here...
|
|
91
|
-
* }
|
|
92
|
-
* });
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
static connect(params: MeshCallConnectParams): Promise<HotMesh>;
|
|
96
|
-
/**
|
|
97
|
-
* Calls a function and returns the response.
|
|
98
|
-
*
|
|
99
|
-
* @template U - the return type of the linked worker function
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```typescript
|
|
103
|
-
* const response = await MeshCall.exec({
|
|
104
|
-
* topic: 'my.function',
|
|
105
|
-
* args: [{ my: 'args' }],
|
|
106
|
-
* connection: {
|
|
107
|
-
* class: Postgres,
|
|
108
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
109
|
-
* }
|
|
110
|
-
* });
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
static exec<U>(params: MeshCallExecParams): Promise<U>;
|
|
114
|
-
/**
|
|
115
|
-
* Clears a cached function response.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* import { Client as Postgres } from 'pg';
|
|
120
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
121
|
-
*
|
|
122
|
-
* MeshCall.flush({
|
|
123
|
-
* topic: 'my.function',
|
|
124
|
-
* connection: {
|
|
125
|
-
* class: Postgres,
|
|
126
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
127
|
-
* },
|
|
128
|
-
* options: { id: 'myCachedExecFunctionId' }
|
|
129
|
-
* });
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
static flush(params: MeshCallFlushParams): Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Creates a stream where messages can be published to ensure there is a
|
|
135
|
-
* channel in place when the message arrives (a race condition for those
|
|
136
|
-
* platforms without implicit topic setup).
|
|
137
|
-
* @private
|
|
138
|
-
*/
|
|
139
|
-
static createStream: (hotMeshClient: HotMesh, workflowTopic: string, namespace?: string) => Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* Schedules a cron job to run at a specified interval
|
|
142
|
-
* with optional args. Provided arguments are passed to the
|
|
143
|
-
* callback function each time the cron job runs. The `id`
|
|
144
|
-
* option is used to uniquely identify the cron job, allowing
|
|
145
|
-
* it to be interrupted at any time.
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```typescript
|
|
149
|
-
* import { Client as Postgres } from 'pg';
|
|
150
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
151
|
-
*
|
|
152
|
-
* MeshCall.cron({
|
|
153
|
-
* topic: 'my.cron.function',
|
|
154
|
-
* args: ['arg1', 'arg2'], //optionally pass args
|
|
155
|
-
* connection: {
|
|
156
|
-
* class: Postgres,
|
|
157
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
158
|
-
* },
|
|
159
|
-
* callback: async (arg1: any, arg2: any) => {
|
|
160
|
-
* //your code here...
|
|
161
|
-
* },
|
|
162
|
-
* options: { id: 'myDailyCron123', interval: '0 0 * * *' }
|
|
163
|
-
* });
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
static cron(params: MeshCallCronParams): Promise<boolean>;
|
|
167
|
-
/**
|
|
168
|
-
* Interrupts a running cron job. Returns `true` if the job
|
|
169
|
-
* was successfully interrupted, or `false` if the job was not
|
|
170
|
-
* found.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```typescript
|
|
174
|
-
* import { Client as Postgres } from 'pg';
|
|
175
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
176
|
-
*
|
|
177
|
-
* MeshCall.interrupt({
|
|
178
|
-
* topic: 'my.cron.function',
|
|
179
|
-
* connection: {
|
|
180
|
-
* class: Postgres,
|
|
181
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
182
|
-
* },
|
|
183
|
-
* options: { id: 'myDailyCron123' }
|
|
184
|
-
* });
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
static interrupt(params: MeshCallInterruptParams): Promise<boolean>;
|
|
188
|
-
/**
|
|
189
|
-
* Shuts down all meshcall instances. Call this method
|
|
190
|
-
* from the SIGTERM handler in your application.
|
|
191
|
-
*/
|
|
192
|
-
static shutdown(): Promise<void>;
|
|
193
|
-
}
|
|
194
|
-
export { MeshCall };
|
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.MeshCall = void 0;
|
|
5
|
-
const hotmesh_1 = require("../hotmesh");
|
|
6
|
-
const enums_1 = require("../../modules/enums");
|
|
7
|
-
const utils_1 = require("../../modules/utils");
|
|
8
|
-
const key_1 = require("../../modules/key");
|
|
9
|
-
const cron_1 = require("../pipe/functions/cron");
|
|
10
|
-
const factory_1 = require("./schemas/factory");
|
|
11
|
-
/**
|
|
12
|
-
* MeshCall connects any function as an idempotent endpoint.
|
|
13
|
-
* Call functions from anywhere on the network connected to the
|
|
14
|
-
* target backend (Postgres, Redis/ValKey, NATS, etc). Function
|
|
15
|
-
* responses are cacheable and invocations can be scheduled to
|
|
16
|
-
* run as idempotent cron jobs (this one runs nightly at midnight
|
|
17
|
-
* and uses Postgres as the backend provider).
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* import { Client as Postgres } from 'pg';
|
|
22
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
23
|
-
*
|
|
24
|
-
* MeshCall.cron({
|
|
25
|
-
* topic: 'my.cron.function',
|
|
26
|
-
* connection: {
|
|
27
|
-
* class: Postgres,
|
|
28
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
29
|
-
* },
|
|
30
|
-
* callback: async () => {
|
|
31
|
-
* //your code here...anything goes
|
|
32
|
-
* },
|
|
33
|
-
* options: { id: 'myDailyCron123', interval: '0 0 * * *' }
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
class MeshCall {
|
|
38
|
-
/**
|
|
39
|
-
* @private
|
|
40
|
-
*/
|
|
41
|
-
constructor() { }
|
|
42
|
-
/**
|
|
43
|
-
* iterates cached worker/engine instances to locate the first match
|
|
44
|
-
* with the provided namespace and connection options
|
|
45
|
-
* @private
|
|
46
|
-
*/
|
|
47
|
-
static async findFirstMatching(targets, namespace = key_1.HMNS, config, options = {}) {
|
|
48
|
-
for (const [id, hotMeshInstance] of targets) {
|
|
49
|
-
const hotMesh = await hotMeshInstance;
|
|
50
|
-
const appId = hotMesh.engine.appId;
|
|
51
|
-
if (appId === namespace) {
|
|
52
|
-
if (id.startsWith(MeshCall.hashOptions(config))) {
|
|
53
|
-
if (Boolean(options.readonly) == Boolean(hotMesh.engine.router.readonly)) {
|
|
54
|
-
return hotMeshInstance;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
static async verifyWorkflowActive(hotMesh, appId = key_1.HMNS, count = 0) {
|
|
64
|
-
const app = await hotMesh.engine.store.getApp(appId);
|
|
65
|
-
const appVersion = app?.version;
|
|
66
|
-
if (isNaN(appVersion)) {
|
|
67
|
-
if (count > 10) {
|
|
68
|
-
throw new Error('Workflow failed to activate');
|
|
69
|
-
}
|
|
70
|
-
await (0, utils_1.sleepFor)(enums_1.HMSH_QUORUM_DELAY_MS * 2);
|
|
71
|
-
return await MeshCall.verifyWorkflowActive(hotMesh, appId, count + 1);
|
|
72
|
-
}
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* @private
|
|
77
|
-
*/
|
|
78
|
-
static async activateWorkflow(hotMesh, appId = key_1.HMNS, version = factory_1.VERSION) {
|
|
79
|
-
const app = await hotMesh.engine.store.getApp(appId);
|
|
80
|
-
const appVersion = app?.version;
|
|
81
|
-
if (appVersion === version && !app.active) {
|
|
82
|
-
try {
|
|
83
|
-
await hotMesh.activate(version);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
hotMesh.engine.logger.error('meshcall-client-activate-err', {
|
|
87
|
-
error,
|
|
88
|
-
});
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else if (isNaN(Number(appVersion)) || appVersion < version) {
|
|
93
|
-
try {
|
|
94
|
-
await hotMesh.deploy((0, factory_1.getWorkflowYAML)(appId));
|
|
95
|
-
await hotMesh.activate(version);
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
hotMesh.engine.logger.error('meshcall-client-deploy-activate-err', {
|
|
99
|
-
error,
|
|
100
|
-
});
|
|
101
|
-
throw error;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Returns a cached worker instance or creates a new one
|
|
107
|
-
* @private
|
|
108
|
-
*/
|
|
109
|
-
static async getInstance(namespace, providerConfig, options = {}) {
|
|
110
|
-
let hotMeshInstance;
|
|
111
|
-
if (!options.readonly) {
|
|
112
|
-
hotMeshInstance = await MeshCall.findFirstMatching(MeshCall.workers, namespace, providerConfig, options);
|
|
113
|
-
}
|
|
114
|
-
if (!hotMeshInstance) {
|
|
115
|
-
hotMeshInstance = await MeshCall.findFirstMatching(MeshCall.engines, namespace, providerConfig, options);
|
|
116
|
-
if (!hotMeshInstance) {
|
|
117
|
-
hotMeshInstance = (await MeshCall.getHotMeshClient(namespace, providerConfig, options));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return hotMeshInstance;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* connection re-use is important when making repeated calls, but
|
|
124
|
-
* only if the connection options are an exact match. this method
|
|
125
|
-
* hashes the connection options to ensure that the same connection
|
|
126
|
-
*/
|
|
127
|
-
static hashOptions(connection) {
|
|
128
|
-
if ('options' in connection) {
|
|
129
|
-
//shorthand format
|
|
130
|
-
return (0, utils_1.hashOptions)(connection.options);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
//longhand format (sub, store, stream, pub, search)
|
|
134
|
-
const response = [];
|
|
135
|
-
for (const p in connection) {
|
|
136
|
-
if (connection[p].options) {
|
|
137
|
-
response.push((0, utils_1.hashOptions)(connection[p].options));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return response.join('');
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Connects and links a worker function to the mesh
|
|
145
|
-
* @example
|
|
146
|
-
* ```typescript
|
|
147
|
-
* import { Client as Postgres } from 'pg';
|
|
148
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
149
|
-
*
|
|
150
|
-
* MeshCall.connect({
|
|
151
|
-
* topic: 'my.function',
|
|
152
|
-
* connection: {
|
|
153
|
-
* class: Postgres,
|
|
154
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
155
|
-
* },
|
|
156
|
-
* callback: async (arg1: any) => {
|
|
157
|
-
* //your code here...
|
|
158
|
-
* }
|
|
159
|
-
* });
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
static async connect(params) {
|
|
163
|
-
const targetNamespace = params.namespace ?? key_1.HMNS;
|
|
164
|
-
const optionsHash = MeshCall.hashOptions(utils_1.polyfill.providerConfig(params));
|
|
165
|
-
const targetTopic = `${optionsHash}.${targetNamespace}.${params.topic}`;
|
|
166
|
-
const connection = utils_1.polyfill.providerConfig(params);
|
|
167
|
-
const hotMeshWorker = await hotmesh_1.HotMesh.init({
|
|
168
|
-
guid: params.guid,
|
|
169
|
-
logLevel: params.logLevel ?? enums_1.HMSH_LOGLEVEL,
|
|
170
|
-
appId: params.namespace ?? key_1.HMNS,
|
|
171
|
-
engine: { connection },
|
|
172
|
-
workers: [
|
|
173
|
-
{
|
|
174
|
-
topic: params.topic,
|
|
175
|
-
connection,
|
|
176
|
-
callback: async function (input) {
|
|
177
|
-
const response = await params.callback.apply(this, input.data.args);
|
|
178
|
-
return {
|
|
179
|
-
metadata: { ...input.metadata },
|
|
180
|
-
data: { response },
|
|
181
|
-
};
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
],
|
|
185
|
-
});
|
|
186
|
-
MeshCall.workers.set(targetTopic, hotMeshWorker);
|
|
187
|
-
await MeshCall.activateWorkflow(hotMeshWorker, targetNamespace);
|
|
188
|
-
return hotMeshWorker;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Calls a function and returns the response.
|
|
192
|
-
*
|
|
193
|
-
* @template U - the return type of the linked worker function
|
|
194
|
-
*
|
|
195
|
-
* @example
|
|
196
|
-
* ```typescript
|
|
197
|
-
* const response = await MeshCall.exec({
|
|
198
|
-
* topic: 'my.function',
|
|
199
|
-
* args: [{ my: 'args' }],
|
|
200
|
-
* connection: {
|
|
201
|
-
* class: Postgres,
|
|
202
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
203
|
-
* }
|
|
204
|
-
* });
|
|
205
|
-
* ```
|
|
206
|
-
*/
|
|
207
|
-
static async exec(params) {
|
|
208
|
-
const TOPIC = `${params.namespace ?? key_1.HMNS}.call`;
|
|
209
|
-
const hotMeshInstance = await MeshCall.getInstance(params.namespace, utils_1.polyfill.providerConfig(params));
|
|
210
|
-
let id = params.options?.id;
|
|
211
|
-
if (id) {
|
|
212
|
-
if (params.options?.flush) {
|
|
213
|
-
await hotMeshInstance.scrub(id);
|
|
214
|
-
}
|
|
215
|
-
else if (params.options?.ttl) {
|
|
216
|
-
//check cache
|
|
217
|
-
try {
|
|
218
|
-
const cached = await hotMeshInstance.getState(TOPIC, id);
|
|
219
|
-
if (cached) {
|
|
220
|
-
//todo: check if present; await if not (subscribe)
|
|
221
|
-
return cached.data.response;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
catch (error) {
|
|
225
|
-
//just swallow error; it means the cache is empty (no doc by that id)
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
id = hotmesh_1.HotMesh.guid();
|
|
231
|
-
}
|
|
232
|
-
let expire = 1;
|
|
233
|
-
if (params.options?.ttl) {
|
|
234
|
-
expire = (0, utils_1.s)(params.options.ttl);
|
|
235
|
-
}
|
|
236
|
-
const jobOutput = await hotMeshInstance.pubsub(TOPIC, { id, expire, topic: params.topic, args: params.args }, null, 30000);
|
|
237
|
-
return jobOutput?.data?.response;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Clears a cached function response.
|
|
241
|
-
*
|
|
242
|
-
* @example
|
|
243
|
-
* ```typescript
|
|
244
|
-
* import { Client as Postgres } from 'pg';
|
|
245
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
246
|
-
*
|
|
247
|
-
* MeshCall.flush({
|
|
248
|
-
* topic: 'my.function',
|
|
249
|
-
* connection: {
|
|
250
|
-
* class: Postgres,
|
|
251
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
252
|
-
* },
|
|
253
|
-
* options: { id: 'myCachedExecFunctionId' }
|
|
254
|
-
* });
|
|
255
|
-
* ```
|
|
256
|
-
*/
|
|
257
|
-
static async flush(params) {
|
|
258
|
-
const hotMeshInstance = await MeshCall.getInstance(params.namespace, utils_1.polyfill.providerConfig(params));
|
|
259
|
-
await hotMeshInstance.scrub(params.id ?? params?.options?.id);
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Schedules a cron job to run at a specified interval
|
|
263
|
-
* with optional args. Provided arguments are passed to the
|
|
264
|
-
* callback function each time the cron job runs. The `id`
|
|
265
|
-
* option is used to uniquely identify the cron job, allowing
|
|
266
|
-
* it to be interrupted at any time.
|
|
267
|
-
*
|
|
268
|
-
* @example
|
|
269
|
-
* ```typescript
|
|
270
|
-
* import { Client as Postgres } from 'pg';
|
|
271
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
272
|
-
*
|
|
273
|
-
* MeshCall.cron({
|
|
274
|
-
* topic: 'my.cron.function',
|
|
275
|
-
* args: ['arg1', 'arg2'], //optionally pass args
|
|
276
|
-
* connection: {
|
|
277
|
-
* class: Postgres,
|
|
278
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
279
|
-
* },
|
|
280
|
-
* callback: async (arg1: any, arg2: any) => {
|
|
281
|
-
* //your code here...
|
|
282
|
-
* },
|
|
283
|
-
* options: { id: 'myDailyCron123', interval: '0 0 * * *' }
|
|
284
|
-
* });
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
static async cron(params) {
|
|
288
|
-
let hotMeshInstance;
|
|
289
|
-
let readonly = true;
|
|
290
|
-
if (params.callback) {
|
|
291
|
-
//always connect cron worker if provided
|
|
292
|
-
hotMeshInstance = await MeshCall.connect({
|
|
293
|
-
logLevel: params.logLevel,
|
|
294
|
-
guid: params.guid,
|
|
295
|
-
topic: params.topic,
|
|
296
|
-
connection: utils_1.polyfill.providerConfig(params),
|
|
297
|
-
callback: params.callback,
|
|
298
|
-
namespace: params.namespace,
|
|
299
|
-
});
|
|
300
|
-
readonly = false;
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
//this is a readonly cron connection which means
|
|
304
|
-
//it is only being created to connect as a readonly member
|
|
305
|
-
//of the mesh network that the cron is running on. it
|
|
306
|
-
//can start a job, but it cannot run the job itself in RO mode.
|
|
307
|
-
}
|
|
308
|
-
//configure job inputs
|
|
309
|
-
const TOPIC = `${params.namespace ?? key_1.HMNS}.cron`;
|
|
310
|
-
const maxCycles = params.options.maxCycles ?? 100000;
|
|
311
|
-
let interval = enums_1.HMSH_FIDELITY_SECONDS;
|
|
312
|
-
let delay;
|
|
313
|
-
let cron;
|
|
314
|
-
if ((0, utils_1.isValidCron)(params.options.interval)) {
|
|
315
|
-
//cron syntax
|
|
316
|
-
cron = params.options.interval;
|
|
317
|
-
const nextDelay = new cron_1.CronHandler().nextDelay(cron);
|
|
318
|
-
delay = nextDelay > 0 ? nextDelay : undefined;
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
const seconds = (0, utils_1.s)(params.options.interval);
|
|
322
|
-
interval = Math.max(seconds, enums_1.HMSH_FIDELITY_SECONDS);
|
|
323
|
-
delay = params.options.delay ? (0, utils_1.s)(params.options.delay) : undefined;
|
|
324
|
-
}
|
|
325
|
-
try {
|
|
326
|
-
if (!hotMeshInstance) {
|
|
327
|
-
//get or create a read-only engine instance to start the cron
|
|
328
|
-
hotMeshInstance = await MeshCall.getInstance(params.namespace, utils_1.polyfill.providerConfig(params), { readonly, guid: params.guid });
|
|
329
|
-
await MeshCall.createStream(hotMeshInstance, params.topic, params.namespace);
|
|
330
|
-
}
|
|
331
|
-
//spawn the job (ok if it's a duplicate)
|
|
332
|
-
await hotMeshInstance.pub(TOPIC, {
|
|
333
|
-
id: params.options.id,
|
|
334
|
-
topic: params.topic,
|
|
335
|
-
args: params.args,
|
|
336
|
-
interval,
|
|
337
|
-
cron,
|
|
338
|
-
maxCycles,
|
|
339
|
-
delay,
|
|
340
|
-
});
|
|
341
|
-
return true;
|
|
342
|
-
}
|
|
343
|
-
catch (error) {
|
|
344
|
-
if (error.message.includes(`Duplicate job: ${params.options.id}`)) {
|
|
345
|
-
return false;
|
|
346
|
-
}
|
|
347
|
-
throw error;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Interrupts a running cron job. Returns `true` if the job
|
|
352
|
-
* was successfully interrupted, or `false` if the job was not
|
|
353
|
-
* found.
|
|
354
|
-
*
|
|
355
|
-
* @example
|
|
356
|
-
* ```typescript
|
|
357
|
-
* import { Client as Postgres } from 'pg';
|
|
358
|
-
* import { MeshCall } from '@hotmesh/meshcall';
|
|
359
|
-
*
|
|
360
|
-
* MeshCall.interrupt({
|
|
361
|
-
* topic: 'my.cron.function',
|
|
362
|
-
* connection: {
|
|
363
|
-
* class: Postgres,
|
|
364
|
-
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
|
|
365
|
-
* },
|
|
366
|
-
* options: { id: 'myDailyCron123' }
|
|
367
|
-
* });
|
|
368
|
-
* ```
|
|
369
|
-
*/
|
|
370
|
-
static async interrupt(params) {
|
|
371
|
-
const hotMeshInstance = await MeshCall.getInstance(params.namespace, utils_1.polyfill.providerConfig(params));
|
|
372
|
-
try {
|
|
373
|
-
await hotMeshInstance.interrupt(`${params.namespace ?? key_1.HMNS}.cron`, params.options.id, { throw: false, expire: 1 });
|
|
374
|
-
}
|
|
375
|
-
catch (error) {
|
|
376
|
-
//job doesn't exist; is already stopped
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
return true;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Shuts down all meshcall instances. Call this method
|
|
383
|
-
* from the SIGTERM handler in your application.
|
|
384
|
-
*/
|
|
385
|
-
static async shutdown() {
|
|
386
|
-
for (const [_, hotMeshInstance] of MeshCall.workers) {
|
|
387
|
-
(await hotMeshInstance).stop();
|
|
388
|
-
}
|
|
389
|
-
for (const [_, hotMeshInstance] of MeshCall.engines) {
|
|
390
|
-
(await hotMeshInstance).stop();
|
|
391
|
-
}
|
|
392
|
-
await hotmesh_1.HotMesh.stop();
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
exports.MeshCall = MeshCall;
|
|
396
|
-
_a = MeshCall;
|
|
397
|
-
/**
|
|
398
|
-
* @private
|
|
399
|
-
*/
|
|
400
|
-
MeshCall.workers = new Map();
|
|
401
|
-
/**
|
|
402
|
-
* @private
|
|
403
|
-
*/
|
|
404
|
-
MeshCall.engines = new Map();
|
|
405
|
-
/**
|
|
406
|
-
* @private
|
|
407
|
-
*/
|
|
408
|
-
MeshCall.connections = new Map();
|
|
409
|
-
/**
|
|
410
|
-
* @private
|
|
411
|
-
*/
|
|
412
|
-
MeshCall.getHotMeshClient = async (namespace, connection, options = {}) => {
|
|
413
|
-
//namespace isolation requires the connection options to be hashed
|
|
414
|
-
//as multiple intersecting databases can be used by the same service
|
|
415
|
-
const optionsHash = MeshCall.hashOptions(connection);
|
|
416
|
-
const targetNS = namespace ?? key_1.HMNS;
|
|
417
|
-
const connectionNS = `${optionsHash}.${targetNS}`;
|
|
418
|
-
if (MeshCall.engines.has(connectionNS)) {
|
|
419
|
-
const hotMeshClient = await MeshCall.engines.get(connectionNS);
|
|
420
|
-
await _a.verifyWorkflowActive(hotMeshClient, targetNS);
|
|
421
|
-
return hotMeshClient;
|
|
422
|
-
}
|
|
423
|
-
//create and cache an instance
|
|
424
|
-
const hotMeshClient = hotmesh_1.HotMesh.init({
|
|
425
|
-
guid: options.guid,
|
|
426
|
-
appId: targetNS,
|
|
427
|
-
logLevel: enums_1.HMSH_LOGLEVEL,
|
|
428
|
-
engine: {
|
|
429
|
-
connection,
|
|
430
|
-
readonly: options.readonly,
|
|
431
|
-
},
|
|
432
|
-
});
|
|
433
|
-
MeshCall.engines.set(connectionNS, hotMeshClient);
|
|
434
|
-
await _a.activateWorkflow(await hotMeshClient, targetNS);
|
|
435
|
-
return hotMeshClient;
|
|
436
|
-
};
|
|
437
|
-
/**
|
|
438
|
-
* Creates a stream where messages can be published to ensure there is a
|
|
439
|
-
* channel in place when the message arrives (a race condition for those
|
|
440
|
-
* platforms without implicit topic setup).
|
|
441
|
-
* @private
|
|
442
|
-
*/
|
|
443
|
-
MeshCall.createStream = async (hotMeshClient, workflowTopic, namespace) => {
|
|
444
|
-
const params = { appId: namespace ?? key_1.HMNS, topic: workflowTopic };
|
|
445
|
-
const streamKey = hotMeshClient.engine.store.mintKey(key_1.KeyType.STREAMS, params);
|
|
446
|
-
try {
|
|
447
|
-
await hotMeshClient.engine.stream.createConsumerGroup(streamKey, 'WORKER');
|
|
448
|
-
}
|
|
449
|
-
catch (err) {
|
|
450
|
-
//ignore if already exists
|
|
451
|
-
}
|
|
452
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const VERSION = "2";
|
|
2
|
-
/**
|
|
3
|
-
* Provides the YAML necessary to create a workflow for the `MeshCall` service.
|
|
4
|
-
* The `appId` parameter is optional and defaults to the HMNS constant ('hmsh').
|
|
5
|
-
*
|
|
6
|
-
* The version is a string as it supports semantic versioning. It is also optional
|
|
7
|
-
* and defaults to '1'.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getWorkflowYAML: (appId?: string, version?: string) => string;
|