@hotmeshio/hotmesh 0.3.31 → 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 -108
- package/build/modules/enums.js +0 -132
- 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,90 +0,0 @@
|
|
|
1
|
-
import { HotMesh } from '../hotmesh';
|
|
2
|
-
import { MeshFlowJobExport, ExportOptions } from '../../types/exporter';
|
|
3
|
-
import { JobInterruptOptions } from '../../types/job';
|
|
4
|
-
import { StreamError } from '../../types/stream';
|
|
5
|
-
import { ExporterService } from './exporter';
|
|
6
|
-
/**
|
|
7
|
-
* The WorkflowHandleService provides methods to interact with a running
|
|
8
|
-
* workflow. This includes exporting the workflow, sending signals, and
|
|
9
|
-
* querying the state of the workflow. It is instanced/accessed via the
|
|
10
|
-
* MeshFlow.Client class.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { Client } from '@hotmeshio/hotmesh';
|
|
15
|
-
* import { Client as Postgres } from 'pg';
|
|
16
|
-
*
|
|
17
|
-
* const client = new Client({ connection: {
|
|
18
|
-
* class: Postgres,
|
|
19
|
-
* options: { connectionString: 'postgres://user:pass@localhost:5432/db' }
|
|
20
|
-
* }});
|
|
21
|
-
*
|
|
22
|
-
* const handle = await client.workflow.start({
|
|
23
|
-
* args: ['HotMesh'],
|
|
24
|
-
* taskQueue: 'hello-world',
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* //perform actions like send a signal
|
|
28
|
-
* await handle.signal('my-signal', { data: 'Hello' });
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare class WorkflowHandleService {
|
|
32
|
-
/**
|
|
33
|
-
* @private
|
|
34
|
-
*/
|
|
35
|
-
exporter: ExporterService;
|
|
36
|
-
hotMesh: HotMesh;
|
|
37
|
-
workflowTopic: string;
|
|
38
|
-
workflowId: string;
|
|
39
|
-
/**
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
42
|
-
constructor(hotMesh: HotMesh, workflowTopic: string, workflowId: string);
|
|
43
|
-
/**
|
|
44
|
-
* Exports the workflow state to a JSON object.
|
|
45
|
-
*/
|
|
46
|
-
export(options?: ExportOptions): Promise<MeshFlowJobExport>;
|
|
47
|
-
/**
|
|
48
|
-
* Sends a signal to the workflow. This is a way to send
|
|
49
|
-
* a message to a workflow that is paused due to having
|
|
50
|
-
* executed `MeshFlow.workflow.waitFor`. The workflow
|
|
51
|
-
* will awaken if no other signals are pending.
|
|
52
|
-
*/
|
|
53
|
-
signal(signalId: string, data: Record<any, any>): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Returns the job state of the workflow. If the workflow has completed
|
|
56
|
-
* this is also the job output. If the workflow is still running, this
|
|
57
|
-
* is the current state of the job, but it may change depending upon
|
|
58
|
-
* the activities that remain.
|
|
59
|
-
*/
|
|
60
|
-
state(metadata?: boolean): Promise<Record<string, any>>;
|
|
61
|
-
/**
|
|
62
|
-
* Returns the current search state of the workflow. This is
|
|
63
|
-
* different than the job state or individual activity state.
|
|
64
|
-
* Search state represents name/value pairs that were added
|
|
65
|
-
* to the workflow.
|
|
66
|
-
*/
|
|
67
|
-
queryState(fields: string[]): Promise<Record<string, any>>;
|
|
68
|
-
/**
|
|
69
|
-
* Returns the current status of the workflow. This is a semaphore
|
|
70
|
-
* value that represents the current state of the workflow, where
|
|
71
|
-
* 0 is complete and a negative value represents that the flow was
|
|
72
|
-
* interrupted.
|
|
73
|
-
*/
|
|
74
|
-
status(): Promise<number>;
|
|
75
|
-
/**
|
|
76
|
-
* Interrupts a running workflow. Standard Job Completion tasks will
|
|
77
|
-
* run. Subscribers will be notified and the job hash will be expired.
|
|
78
|
-
*/
|
|
79
|
-
interrupt(options?: JobInterruptOptions): Promise<string>;
|
|
80
|
-
/**
|
|
81
|
-
* Waits for the workflow to complete and returns the result. If
|
|
82
|
-
* the workflow response includes an error, this method will rethrow
|
|
83
|
-
* the error, including the stack trace if available.
|
|
84
|
-
* Wrap calls in a try/catch as necessary to avoid unhandled exceptions.
|
|
85
|
-
*/
|
|
86
|
-
result<T>(config?: {
|
|
87
|
-
state?: boolean;
|
|
88
|
-
throwOnError?: boolean;
|
|
89
|
-
}): Promise<T | StreamError>;
|
|
90
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WorkflowHandleService = void 0;
|
|
4
|
-
const exporter_1 = require("./exporter");
|
|
5
|
-
/**
|
|
6
|
-
* The WorkflowHandleService provides methods to interact with a running
|
|
7
|
-
* workflow. This includes exporting the workflow, sending signals, and
|
|
8
|
-
* querying the state of the workflow. It is instanced/accessed via the
|
|
9
|
-
* MeshFlow.Client class.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { Client } from '@hotmeshio/hotmesh';
|
|
14
|
-
* import { Client as Postgres } from 'pg';
|
|
15
|
-
*
|
|
16
|
-
* const client = new Client({ connection: {
|
|
17
|
-
* class: Postgres,
|
|
18
|
-
* options: { connectionString: 'postgres://user:pass@localhost:5432/db' }
|
|
19
|
-
* }});
|
|
20
|
-
*
|
|
21
|
-
* const handle = await client.workflow.start({
|
|
22
|
-
* args: ['HotMesh'],
|
|
23
|
-
* taskQueue: 'hello-world',
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* //perform actions like send a signal
|
|
27
|
-
* await handle.signal('my-signal', { data: 'Hello' });
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
class WorkflowHandleService {
|
|
31
|
-
/**
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
constructor(hotMesh, workflowTopic, workflowId) {
|
|
35
|
-
this.workflowTopic = workflowTopic;
|
|
36
|
-
this.workflowId = workflowId;
|
|
37
|
-
this.hotMesh = hotMesh;
|
|
38
|
-
this.exporter = new exporter_1.ExporterService(this.hotMesh.appId, this.hotMesh.engine.store, this.hotMesh.engine.logger);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Exports the workflow state to a JSON object.
|
|
42
|
-
*/
|
|
43
|
-
async export(options) {
|
|
44
|
-
return this.exporter.export(this.workflowId, options);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Sends a signal to the workflow. This is a way to send
|
|
48
|
-
* a message to a workflow that is paused due to having
|
|
49
|
-
* executed `MeshFlow.workflow.waitFor`. The workflow
|
|
50
|
-
* will awaken if no other signals are pending.
|
|
51
|
-
*/
|
|
52
|
-
async signal(signalId, data) {
|
|
53
|
-
await this.hotMesh.hook(`${this.hotMesh.appId}.wfs.signal`, {
|
|
54
|
-
id: signalId,
|
|
55
|
-
data,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Returns the job state of the workflow. If the workflow has completed
|
|
60
|
-
* this is also the job output. If the workflow is still running, this
|
|
61
|
-
* is the current state of the job, but it may change depending upon
|
|
62
|
-
* the activities that remain.
|
|
63
|
-
*/
|
|
64
|
-
async state(metadata = false) {
|
|
65
|
-
const state = await this.hotMesh.getState(`${this.hotMesh.appId}.execute`, this.workflowId);
|
|
66
|
-
if (!state.data && state.metadata.err) {
|
|
67
|
-
throw new Error(JSON.parse(state.metadata.err));
|
|
68
|
-
}
|
|
69
|
-
return metadata ? state : state.data;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Returns the current search state of the workflow. This is
|
|
73
|
-
* different than the job state or individual activity state.
|
|
74
|
-
* Search state represents name/value pairs that were added
|
|
75
|
-
* to the workflow.
|
|
76
|
-
*/
|
|
77
|
-
async queryState(fields) {
|
|
78
|
-
return await this.hotMesh.getQueryState(this.workflowId, fields);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Returns the current status of the workflow. This is a semaphore
|
|
82
|
-
* value that represents the current state of the workflow, where
|
|
83
|
-
* 0 is complete and a negative value represents that the flow was
|
|
84
|
-
* interrupted.
|
|
85
|
-
*/
|
|
86
|
-
async status() {
|
|
87
|
-
return await this.hotMesh.getStatus(this.workflowId);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Interrupts a running workflow. Standard Job Completion tasks will
|
|
91
|
-
* run. Subscribers will be notified and the job hash will be expired.
|
|
92
|
-
*/
|
|
93
|
-
async interrupt(options) {
|
|
94
|
-
return await this.hotMesh.interrupt(`${this.hotMesh.appId}.execute`, this.workflowId, options);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Waits for the workflow to complete and returns the result. If
|
|
98
|
-
* the workflow response includes an error, this method will rethrow
|
|
99
|
-
* the error, including the stack trace if available.
|
|
100
|
-
* Wrap calls in a try/catch as necessary to avoid unhandled exceptions.
|
|
101
|
-
*/
|
|
102
|
-
async result(config) {
|
|
103
|
-
const topic = `${this.hotMesh.appId}.executed.${this.workflowId}`;
|
|
104
|
-
let isResolved = false;
|
|
105
|
-
return new Promise(async (resolve, reject) => {
|
|
106
|
-
/**
|
|
107
|
-
* rejects/resolves the promise based on the `throwOnError`
|
|
108
|
-
* default behavior is to throw if error
|
|
109
|
-
*/
|
|
110
|
-
const safeReject = (err) => {
|
|
111
|
-
if (config?.throwOnError === false) {
|
|
112
|
-
return resolve(err);
|
|
113
|
-
}
|
|
114
|
-
reject(err);
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Common completion function that unsubscribes from the topic/returns
|
|
118
|
-
*/
|
|
119
|
-
const complete = async (response, err) => {
|
|
120
|
-
if (isResolved)
|
|
121
|
-
return;
|
|
122
|
-
isResolved = true;
|
|
123
|
-
if (err) {
|
|
124
|
-
return safeReject(err);
|
|
125
|
-
}
|
|
126
|
-
else if (!response) {
|
|
127
|
-
const state = await this.hotMesh.getState(`${this.hotMesh.appId}.execute`, this.workflowId);
|
|
128
|
-
if (state.data?.done && !state.data?.$error) {
|
|
129
|
-
return resolve(state.data.response);
|
|
130
|
-
}
|
|
131
|
-
else if (state.data?.$error) {
|
|
132
|
-
return safeReject(state.data.$error);
|
|
133
|
-
}
|
|
134
|
-
else if (state.metadata.err) {
|
|
135
|
-
return safeReject(JSON.parse(state.metadata.err));
|
|
136
|
-
}
|
|
137
|
-
response = state.data?.response;
|
|
138
|
-
}
|
|
139
|
-
resolve(response);
|
|
140
|
-
};
|
|
141
|
-
//more expensive; fetches the entire job, not just the `status`
|
|
142
|
-
if (config?.state) {
|
|
143
|
-
const state = await this.hotMesh.getState(`${this.hotMesh.appId}.execute`, this.workflowId);
|
|
144
|
-
if (state?.data?.done && !state.data?.$error) {
|
|
145
|
-
return complete(state.data.response);
|
|
146
|
-
}
|
|
147
|
-
else if (state.data?.$error) {
|
|
148
|
-
return complete(null, state.data.$error);
|
|
149
|
-
}
|
|
150
|
-
else if (state.metadata.err) {
|
|
151
|
-
return complete(null, JSON.parse(state.metadata.err));
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
//subscribe to 'done' topic
|
|
155
|
-
this.hotMesh.sub(topic, async (_topic, state) => {
|
|
156
|
-
this.hotMesh.unsub(topic);
|
|
157
|
-
if (state.data.done && !state.data?.$error) {
|
|
158
|
-
await complete(state.data?.response);
|
|
159
|
-
}
|
|
160
|
-
else if (state.data?.$error) {
|
|
161
|
-
return complete(null, state.data.$error);
|
|
162
|
-
}
|
|
163
|
-
else if (state.metadata.err) {
|
|
164
|
-
const error = JSON.parse(state.metadata.err);
|
|
165
|
-
return await complete(null, error);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
//check state in case completed during wiring
|
|
169
|
-
const status = await this.hotMesh.getStatus(this.workflowId);
|
|
170
|
-
if (status <= 0) {
|
|
171
|
-
await complete();
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.WorkflowHandleService = WorkflowHandleService;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { ContextType } from '../../types/meshflow';
|
|
2
|
-
import { ClientService } from './client';
|
|
3
|
-
import { ConnectionService } from './connection';
|
|
4
|
-
import { Search } from './search';
|
|
5
|
-
import { WorkerService } from './worker';
|
|
6
|
-
import { WorkflowService } from './workflow';
|
|
7
|
-
import { WorkflowHandleService } from './handle';
|
|
8
|
-
/**
|
|
9
|
-
* The MeshFlow service is a collection of services that
|
|
10
|
-
* emulate Temporal's capabilities, but instead are
|
|
11
|
-
* backed by Postgres or Redis/ValKey. The following lifecycle example
|
|
12
|
-
* demonstrates how to start a new workflow, subscribe
|
|
13
|
-
* to the result, and shutdown the system.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { Client, Worker, MeshFlow, HotMesh } from '@hotmeshio/hotmesh';
|
|
18
|
-
* import { Client as Postgres} from 'pg';
|
|
19
|
-
* import * as workflows from './workflows';
|
|
20
|
-
*
|
|
21
|
-
* //1) Initialize the worker
|
|
22
|
-
* await Worker.create({
|
|
23
|
-
* connection: {
|
|
24
|
-
* class: Postgres,
|
|
25
|
-
* options: {
|
|
26
|
-
* connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* taskQueue: 'default',
|
|
30
|
-
* namespace: 'meshflow',
|
|
31
|
-
* workflow: workflows.example,
|
|
32
|
-
* options: {
|
|
33
|
-
* backoffCoefficient: 2,
|
|
34
|
-
* maximumAttempts: 1_000,
|
|
35
|
-
* maximumInterval: '5 seconds'
|
|
36
|
-
* }
|
|
37
|
-
* });
|
|
38
|
-
*
|
|
39
|
-
* //2) initialize the client
|
|
40
|
-
* const client = new Client({
|
|
41
|
-
* connection: {
|
|
42
|
-
* class: Postgres,
|
|
43
|
-
* options: {
|
|
44
|
-
* connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
45
|
-
* }
|
|
46
|
-
* }
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
49
|
-
* //3) start a new workflow
|
|
50
|
-
* const handle = await client.workflow.start({
|
|
51
|
-
* args: ['HotMesh', 'es'],
|
|
52
|
-
* taskQueue: 'default',
|
|
53
|
-
* workflowName: 'example',
|
|
54
|
-
* workflowId: HotMesh.guid(),
|
|
55
|
-
* namespace: 'meshflow',
|
|
56
|
-
* });
|
|
57
|
-
*
|
|
58
|
-
* //4) subscribe to the eventual result
|
|
59
|
-
* console.log('\nRESPONSE', await handle.result(), '\n');
|
|
60
|
-
* //logs '¡Hola, HotMesh!'
|
|
61
|
-
*
|
|
62
|
-
* //5) Shutdown (typically on sigint)
|
|
63
|
-
* await MeshFlow.shutdown();
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
declare class MeshFlowClass {
|
|
67
|
-
/**
|
|
68
|
-
* @private
|
|
69
|
-
*/
|
|
70
|
-
constructor();
|
|
71
|
-
/**
|
|
72
|
-
* The MeshFlow `Client` service is functionally
|
|
73
|
-
* equivalent to the Temporal `Client` service.
|
|
74
|
-
*/
|
|
75
|
-
static Client: typeof ClientService;
|
|
76
|
-
/**
|
|
77
|
-
* The MeshFlow `Connection` service is functionally
|
|
78
|
-
* equivalent to the Temporal `Connection` service.
|
|
79
|
-
*/
|
|
80
|
-
static Connection: typeof ConnectionService;
|
|
81
|
-
/**
|
|
82
|
-
* @private
|
|
83
|
-
*/
|
|
84
|
-
static Search: typeof Search;
|
|
85
|
-
/**
|
|
86
|
-
* The Handle provides methods to interact with a running
|
|
87
|
-
* workflow. This includes exporting the workflow, sending signals, and
|
|
88
|
-
* querying the state of the workflow. An instance of the Handle service
|
|
89
|
-
* is typically accessed via the MeshFlow.Client class (workflow.getHandle).
|
|
90
|
-
*/
|
|
91
|
-
static Handle: typeof WorkflowHandleService;
|
|
92
|
-
/**
|
|
93
|
-
* The MeshFlow `Worker` service is functionally
|
|
94
|
-
* equivalent to the Temporal `Worker` service.
|
|
95
|
-
*/
|
|
96
|
-
static Worker: typeof WorkerService;
|
|
97
|
-
/**
|
|
98
|
-
* The MeshFlow `workflow` service is functionally
|
|
99
|
-
* equivalent to the Temporal `Workflow` service
|
|
100
|
-
* with additional methods for managing workflows,
|
|
101
|
-
* including: `execChild`, `waitFor`, `sleep`, etc
|
|
102
|
-
*/
|
|
103
|
-
static workflow: typeof WorkflowService;
|
|
104
|
-
/**
|
|
105
|
-
* Shutdown everything. All connections, workers, and clients will be closed.
|
|
106
|
-
* Include in your signal handlers to ensure a clean shutdown.
|
|
107
|
-
*/
|
|
108
|
-
static shutdown(): Promise<void>;
|
|
109
|
-
}
|
|
110
|
-
export { MeshFlowClass as MeshFlow };
|
|
111
|
-
export type { ContextType };
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MeshFlow = void 0;
|
|
4
|
-
const hotmesh_1 = require("../hotmesh");
|
|
5
|
-
const client_1 = require("./client");
|
|
6
|
-
const connection_1 = require("./connection");
|
|
7
|
-
const search_1 = require("./search");
|
|
8
|
-
const worker_1 = require("./worker");
|
|
9
|
-
const workflow_1 = require("./workflow");
|
|
10
|
-
const handle_1 = require("./handle");
|
|
11
|
-
/**
|
|
12
|
-
* The MeshFlow service is a collection of services that
|
|
13
|
-
* emulate Temporal's capabilities, but instead are
|
|
14
|
-
* backed by Postgres or Redis/ValKey. The following lifecycle example
|
|
15
|
-
* demonstrates how to start a new workflow, subscribe
|
|
16
|
-
* to the result, and shutdown the system.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* import { Client, Worker, MeshFlow, HotMesh } from '@hotmeshio/hotmesh';
|
|
21
|
-
* import { Client as Postgres} from 'pg';
|
|
22
|
-
* import * as workflows from './workflows';
|
|
23
|
-
*
|
|
24
|
-
* //1) Initialize the worker
|
|
25
|
-
* await Worker.create({
|
|
26
|
-
* connection: {
|
|
27
|
-
* class: Postgres,
|
|
28
|
-
* options: {
|
|
29
|
-
* connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* taskQueue: 'default',
|
|
33
|
-
* namespace: 'meshflow',
|
|
34
|
-
* workflow: workflows.example,
|
|
35
|
-
* options: {
|
|
36
|
-
* backoffCoefficient: 2,
|
|
37
|
-
* maximumAttempts: 1_000,
|
|
38
|
-
* maximumInterval: '5 seconds'
|
|
39
|
-
* }
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* //2) initialize the client
|
|
43
|
-
* const client = new Client({
|
|
44
|
-
* connection: {
|
|
45
|
-
* class: Postgres,
|
|
46
|
-
* options: {
|
|
47
|
-
* connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
48
|
-
* }
|
|
49
|
-
* }
|
|
50
|
-
* });
|
|
51
|
-
*
|
|
52
|
-
* //3) start a new workflow
|
|
53
|
-
* const handle = await client.workflow.start({
|
|
54
|
-
* args: ['HotMesh', 'es'],
|
|
55
|
-
* taskQueue: 'default',
|
|
56
|
-
* workflowName: 'example',
|
|
57
|
-
* workflowId: HotMesh.guid(),
|
|
58
|
-
* namespace: 'meshflow',
|
|
59
|
-
* });
|
|
60
|
-
*
|
|
61
|
-
* //4) subscribe to the eventual result
|
|
62
|
-
* console.log('\nRESPONSE', await handle.result(), '\n');
|
|
63
|
-
* //logs '¡Hola, HotMesh!'
|
|
64
|
-
*
|
|
65
|
-
* //5) Shutdown (typically on sigint)
|
|
66
|
-
* await MeshFlow.shutdown();
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
class MeshFlowClass {
|
|
70
|
-
/**
|
|
71
|
-
* @private
|
|
72
|
-
*/
|
|
73
|
-
constructor() { }
|
|
74
|
-
/**
|
|
75
|
-
* Shutdown everything. All connections, workers, and clients will be closed.
|
|
76
|
-
* Include in your signal handlers to ensure a clean shutdown.
|
|
77
|
-
*/
|
|
78
|
-
static async shutdown() {
|
|
79
|
-
await MeshFlowClass.Client.shutdown();
|
|
80
|
-
await MeshFlowClass.Worker.shutdown();
|
|
81
|
-
await hotmesh_1.HotMesh.stop();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.MeshFlow = MeshFlowClass;
|
|
85
|
-
/**
|
|
86
|
-
* The MeshFlow `Client` service is functionally
|
|
87
|
-
* equivalent to the Temporal `Client` service.
|
|
88
|
-
*/
|
|
89
|
-
MeshFlowClass.Client = client_1.ClientService;
|
|
90
|
-
/**
|
|
91
|
-
* The MeshFlow `Connection` service is functionally
|
|
92
|
-
* equivalent to the Temporal `Connection` service.
|
|
93
|
-
*/
|
|
94
|
-
MeshFlowClass.Connection = connection_1.ConnectionService;
|
|
95
|
-
/**
|
|
96
|
-
* @private
|
|
97
|
-
*/
|
|
98
|
-
MeshFlowClass.Search = search_1.Search;
|
|
99
|
-
/**
|
|
100
|
-
* The Handle provides methods to interact with a running
|
|
101
|
-
* workflow. This includes exporting the workflow, sending signals, and
|
|
102
|
-
* querying the state of the workflow. An instance of the Handle service
|
|
103
|
-
* is typically accessed via the MeshFlow.Client class (workflow.getHandle).
|
|
104
|
-
*/
|
|
105
|
-
MeshFlowClass.Handle = handle_1.WorkflowHandleService;
|
|
106
|
-
/**
|
|
107
|
-
* The MeshFlow `Worker` service is functionally
|
|
108
|
-
* equivalent to the Temporal `Worker` service.
|
|
109
|
-
*/
|
|
110
|
-
MeshFlowClass.Worker = worker_1.WorkerService;
|
|
111
|
-
/**
|
|
112
|
-
* The MeshFlow `workflow` service is functionally
|
|
113
|
-
* equivalent to the Temporal `Workflow` service
|
|
114
|
-
* with additional methods for managing workflows,
|
|
115
|
-
* including: `execChild`, `waitFor`, `sleep`, etc
|
|
116
|
-
*/
|
|
117
|
-
MeshFlowClass.workflow = workflow_1.WorkflowService;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*********** HOTMESH 'MESHFLOW' MODULE APPLICATION GRAPH **********
|
|
3
|
-
*
|
|
4
|
-
* This HotMesh application spec uses 50 activities and 25 transitions
|
|
5
|
-
* to model and emulate the Temporal Application & Query servers using
|
|
6
|
-
* a pluggable backend.
|
|
7
|
-
*
|
|
8
|
-
* This YAML file can also serve as a useful starting point for building
|
|
9
|
-
* Integration/BPM/Workflow servers in general (MuleSoft, etc) without the need
|
|
10
|
-
* for a physical application server.
|
|
11
|
-
*
|
|
12
|
-
* Possible use cases include:
|
|
13
|
-
* * Orchestration servers
|
|
14
|
-
* * Integration servers
|
|
15
|
-
* * BPMN engines
|
|
16
|
-
* * Reentrant process servers
|
|
17
|
-
* * Service Meshes
|
|
18
|
-
* * Master Data Management systems
|
|
19
|
-
*/
|
|
20
|
-
declare const APP_VERSION = "4";
|
|
21
|
-
declare const APP_ID = "meshflow";
|
|
22
|
-
/**
|
|
23
|
-
* returns a new meshflow workflow schema
|
|
24
|
-
* @param {string} app - app name (e.g., 'meshflow')
|
|
25
|
-
* @param {string} version - number as string (e.g., '1')
|
|
26
|
-
* @returns {string} HotMesh App YAML
|
|
27
|
-
*/
|
|
28
|
-
declare const getWorkflowYAML: (app: string, version: string) => string;
|
|
29
|
-
export { getWorkflowYAML, APP_VERSION, APP_ID };
|