@hotmeshio/hotmesh 0.1.14 → 0.1.16
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 +623 -209
- package/build/index.d.ts +14 -3
- package/build/index.js +17 -4
- package/build/modules/enums.d.ts +12 -12
- package/build/modules/enums.js +15 -25
- package/build/modules/errors.d.ts +16 -16
- package/build/modules/errors.js +28 -28
- package/build/modules/key.d.ts +0 -37
- package/build/modules/key.js +4 -45
- package/build/modules/utils.d.ts +7 -15
- package/build/modules/utils.js +21 -44
- package/build/package.json +18 -15
- package/build/services/activities/activity.d.ts +0 -31
- package/build/services/activities/activity.js +1 -50
- package/build/services/activities/await.js +0 -4
- package/build/services/activities/cycle.d.ts +0 -7
- package/build/services/activities/cycle.js +1 -16
- package/build/services/activities/hook.d.ts +0 -6
- package/build/services/activities/hook.js +2 -12
- package/build/services/activities/interrupt.js +0 -8
- package/build/services/activities/signal.d.ts +0 -6
- package/build/services/activities/signal.js +0 -15
- package/build/services/activities/trigger.d.ts +4 -5
- package/build/services/activities/trigger.js +22 -16
- package/build/services/activities/worker.js +0 -4
- package/build/services/collator/index.d.ts +0 -70
- package/build/services/collator/index.js +1 -91
- package/build/services/compiler/deployer.js +6 -38
- package/build/services/compiler/index.d.ts +0 -15
- package/build/services/compiler/index.js +0 -20
- package/build/services/compiler/validator.d.ts +0 -3
- package/build/services/compiler/validator.js +0 -25
- package/build/services/connector/clients/ioredis.js +0 -2
- package/build/services/connector/clients/redis.js +0 -2
- package/build/services/connector/index.js +0 -2
- package/build/services/engine/index.d.ts +1 -10
- package/build/services/engine/index.js +1 -48
- package/build/services/exporter/index.d.ts +0 -27
- package/build/services/exporter/index.js +0 -33
- package/build/services/hotmesh/index.d.ts +8 -4
- package/build/services/hotmesh/index.js +20 -19
- package/build/services/logger/index.js +0 -2
- package/build/services/mapper/index.d.ts +0 -14
- package/build/services/mapper/index.js +0 -14
- package/build/services/meshcall/index.d.ts +21 -0
- package/build/services/meshcall/index.js +202 -0
- package/build/services/meshcall/schemas/factory.d.ts +2 -0
- package/build/services/meshcall/schemas/factory.js +179 -0
- package/build/services/meshdata/index.d.ts +75 -0
- package/build/services/meshdata/index.js +541 -0
- package/build/services/meshflow/client.d.ts +18 -0
- package/build/services/{durable → meshflow}/client.js +9 -40
- package/build/services/{durable → meshflow}/connection.d.ts +2 -1
- package/build/services/{durable → meshflow}/connection.js +1 -0
- package/build/services/meshflow/exporter.d.ts +29 -0
- package/build/services/{durable → meshflow}/exporter.js +0 -29
- package/build/services/meshflow/handle.d.ts +22 -0
- package/build/services/{durable → meshflow}/handle.js +0 -46
- package/build/services/meshflow/index.d.ts +17 -0
- package/build/services/meshflow/index.js +23 -0
- package/build/services/meshflow/schemas/factory.d.ts +4 -0
- package/build/services/{durable → meshflow}/schemas/factory.js +3 -31
- package/build/services/meshflow/search.d.ts +23 -0
- package/build/services/{durable → meshflow}/search.js +0 -99
- package/build/services/{durable → meshflow}/worker.d.ts +3 -2
- package/build/services/{durable → meshflow}/worker.js +23 -39
- package/build/services/meshflow/workflow.d.ts +27 -0
- package/build/services/{durable → meshflow}/workflow.js +27 -169
- package/build/services/pipe/functions/date.d.ts +0 -7
- package/build/services/pipe/functions/date.js +0 -7
- package/build/services/pipe/functions/math.js +0 -2
- package/build/services/pipe/index.d.ts +0 -15
- package/build/services/pipe/index.js +2 -23
- package/build/services/quorum/index.d.ts +1 -7
- package/build/services/quorum/index.js +0 -21
- package/build/services/reporter/index.d.ts +0 -5
- package/build/services/reporter/index.js +0 -9
- package/build/services/router/index.d.ts +0 -9
- package/build/services/router/index.js +2 -30
- package/build/services/serializer/index.js +6 -23
- package/build/services/store/cache.d.ts +0 -19
- package/build/services/store/cache.js +0 -19
- package/build/services/store/clients/ioredis.d.ts +0 -6
- package/build/services/store/clients/ioredis.js +0 -7
- package/build/services/store/clients/redis.d.ts +0 -6
- package/build/services/store/clients/redis.js +0 -6
- package/build/services/store/index.d.ts +0 -55
- package/build/services/store/index.js +14 -87
- package/build/services/stream/clients/ioredis.js +1 -4
- package/build/services/task/index.d.ts +0 -9
- package/build/services/task/index.js +0 -31
- package/build/services/telemetry/index.d.ts +0 -7
- package/build/services/telemetry/index.js +1 -13
- package/build/services/worker/index.d.ts +1 -4
- package/build/services/worker/index.js +0 -6
- package/build/types/activity.d.ts +0 -81
- package/build/types/error.d.ts +5 -5
- package/build/types/exporter.d.ts +1 -14
- package/build/types/hotmesh.d.ts +4 -12
- package/build/types/hotmesh.js +0 -3
- package/build/types/index.d.ts +5 -3
- package/build/types/index.js +1 -1
- package/build/types/job.d.ts +1 -95
- package/build/types/meshcall.d.ts +54 -0
- package/build/types/meshdata.d.ts +59 -0
- package/build/types/meshdata.js +2 -0
- package/build/types/meshflow.d.ts +202 -0
- package/build/types/meshflow.js +2 -0
- package/build/types/pipe.d.ts +0 -65
- package/build/types/quorum.d.ts +0 -12
- package/build/types/redis.d.ts +0 -6
- package/build/types/stream.d.ts +0 -59
- package/build/types/stream.js +0 -4
- package/index.ts +22 -3
- package/package.json +18 -15
- package/typedoc.json +38 -0
- package/types/error.ts +5 -5
- package/types/exporter.ts +1 -1
- package/types/hotmesh.ts +3 -2
- package/types/index.ts +25 -7
- package/types/job.ts +19 -1
- package/types/meshcall.ts +123 -0
- package/types/meshdata.ts +273 -0
- package/types/{durable.ts → meshflow.ts} +33 -9
- package/build/services/durable/client.d.ts +0 -49
- package/build/services/durable/exporter.d.ts +0 -51
- package/build/services/durable/handle.d.ts +0 -58
- package/build/services/durable/index.d.ts +0 -19
- package/build/services/durable/index.js +0 -25
- package/build/services/durable/schemas/factory.d.ts +0 -33
- package/build/services/durable/search.d.ts +0 -120
- package/build/services/durable/workflow.d.ts +0 -143
- package/build/types/durable.d.ts +0 -467
- /package/build/types/{durable.js → meshcall.js} +0 -0
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ILogger } from '../logger';
|
|
2
|
-
import { StoreService } from '../store';
|
|
3
|
-
import { ExportOptions, DurableJobExport, TimelineType, TransitionType, ExportFields } from '../../types/exporter';
|
|
4
|
-
import { RedisClient, RedisMulti } from '../../types/redis';
|
|
5
|
-
import { StringStringType, Symbols } from '../../types/serializer';
|
|
6
|
-
declare class ExporterService {
|
|
7
|
-
appId: string;
|
|
8
|
-
logger: ILogger;
|
|
9
|
-
store: StoreService<RedisClient, RedisMulti>;
|
|
10
|
-
symbols: Promise<Symbols> | Symbols;
|
|
11
|
-
private static symbols;
|
|
12
|
-
constructor(appId: string, store: StoreService<RedisClient, RedisMulti>, logger: ILogger);
|
|
13
|
-
/**
|
|
14
|
-
* Convert the job hash from its compiles format into a DurableJobExport object with
|
|
15
|
-
* facets that describe the workflow in terms relevant to narrative storytelling.
|
|
16
|
-
*/
|
|
17
|
-
export(jobId: string, options?: ExportOptions): Promise<DurableJobExport>;
|
|
18
|
-
/**
|
|
19
|
-
* Inflates the job data from Redis into a DurableJobExport object
|
|
20
|
-
* @param jobHash - the job data from Redis
|
|
21
|
-
* @param dependencyList - the list of dependencies for the job
|
|
22
|
-
* @returns - the inflated job data
|
|
23
|
-
*/
|
|
24
|
-
inflate(jobHash: StringStringType, options: ExportOptions): DurableJobExport;
|
|
25
|
-
resolveValue(raw: string, withValues: boolean): Record<string, any> | string | number | null;
|
|
26
|
-
/**
|
|
27
|
-
* Inflates the key from Redis, 3-character symbol
|
|
28
|
-
* into a human-readable JSON path, reflecting the
|
|
29
|
-
* tree-like structure of the unidimensional Hash
|
|
30
|
-
* @private
|
|
31
|
-
*/
|
|
32
|
-
inflateKey(key: string): string;
|
|
33
|
-
filterFields(fullObject: DurableJobExport, block?: ExportFields[], allow?: ExportFields[]): Partial<DurableJobExport>;
|
|
34
|
-
inflateTransition(match: RegExpMatchArray, value: string, transitionsObject: Record<string, TransitionType>): void;
|
|
35
|
-
sortEntriesByCreated(obj: {
|
|
36
|
-
[key: string]: TransitionType;
|
|
37
|
-
}): TransitionType[];
|
|
38
|
-
/**
|
|
39
|
-
* marker names are overloaded with details like sequence, type, etc
|
|
40
|
-
*/
|
|
41
|
-
keyToObject(key: string): {
|
|
42
|
-
index: number;
|
|
43
|
-
dimension?: string;
|
|
44
|
-
secondary?: number;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* idem list has a complicated sort order based on indexes and dimensions
|
|
48
|
-
*/
|
|
49
|
-
sortParts(parts: TimelineType[]): TimelineType[];
|
|
50
|
-
}
|
|
51
|
-
export { ExporterService };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { HotMeshService as HotMesh } from '../hotmesh';
|
|
2
|
-
import { DurableJobExport, ExportOptions } from '../../types/exporter';
|
|
3
|
-
import { JobInterruptOptions } from '../../types/job';
|
|
4
|
-
import { StreamError } from '../../types/stream';
|
|
5
|
-
import { ExporterService } from './exporter';
|
|
6
|
-
export declare class WorkflowHandleService {
|
|
7
|
-
exporter: ExporterService;
|
|
8
|
-
hotMesh: HotMesh;
|
|
9
|
-
workflowTopic: string;
|
|
10
|
-
workflowId: string;
|
|
11
|
-
constructor(hotMesh: HotMesh, workflowTopic: string, workflowId: string);
|
|
12
|
-
export(options?: ExportOptions): Promise<DurableJobExport>;
|
|
13
|
-
/**
|
|
14
|
-
* Sends a signal to the workflow. This is a way to send
|
|
15
|
-
* a message to a workflow that is paused due to having
|
|
16
|
-
* executed `Durable.workflow.waitFor`. The workflow
|
|
17
|
-
* will awaken if no other signals are pending.
|
|
18
|
-
*/
|
|
19
|
-
signal(signalId: string, data: Record<any, any>): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Returns the job state of the workflow. If the workflow has completed
|
|
22
|
-
* this is also the job output. If the workflow is still running, this
|
|
23
|
-
* is the current state of the job, but it may change depending upon
|
|
24
|
-
* the activities that remain.
|
|
25
|
-
*/
|
|
26
|
-
state(metadata?: boolean): Promise<Record<string, any>>;
|
|
27
|
-
/**
|
|
28
|
-
* Returns the current search state of the workflow. This is
|
|
29
|
-
* different than the job state or individual activity state.
|
|
30
|
-
* Search state represents name/value pairs that were added
|
|
31
|
-
* to the workflow. As the workflow is stored in a Redis hash,
|
|
32
|
-
* this is a way to store additional data that is indexed
|
|
33
|
-
* and searchable using the RediSearch module.
|
|
34
|
-
*/
|
|
35
|
-
queryState(fields: string[]): Promise<Record<string, any>>;
|
|
36
|
-
/**
|
|
37
|
-
* Returns the current status of the workflow. This is a semaphore
|
|
38
|
-
* value that represents the current state of the workflow, where
|
|
39
|
-
* 0 is complete and a negative value represents that the flow was
|
|
40
|
-
* interrupted.
|
|
41
|
-
*/
|
|
42
|
-
status(): Promise<number>;
|
|
43
|
-
/**
|
|
44
|
-
* Interrupts a running workflow. Standard Job Completion tasks will
|
|
45
|
-
* run. Subscribers will be notified and the job hash will be expired.
|
|
46
|
-
*/
|
|
47
|
-
interrupt(options?: JobInterruptOptions): Promise<string>;
|
|
48
|
-
/**
|
|
49
|
-
* Waits for the workflow to complete and returns the result. If
|
|
50
|
-
* the workflow response includes an error, this method will rethrow
|
|
51
|
-
* the error, including the stack trace if available.
|
|
52
|
-
* Wrap calls in a try/catch as necessary to avoid unhandled exceptions.
|
|
53
|
-
*/
|
|
54
|
-
result<T>(config?: {
|
|
55
|
-
state?: boolean;
|
|
56
|
-
throwOnError?: boolean;
|
|
57
|
-
}): Promise<T | StreamError>;
|
|
58
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ContextType } from '../../types/durable';
|
|
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
|
-
export declare const Durable: {
|
|
8
|
-
Client: typeof ClientService;
|
|
9
|
-
Connection: typeof ConnectionService;
|
|
10
|
-
Search: typeof Search;
|
|
11
|
-
Worker: typeof WorkerService;
|
|
12
|
-
workflow: typeof WorkflowService;
|
|
13
|
-
/**
|
|
14
|
-
* Shutdown everything. All connections, workers, and clients will be closed.
|
|
15
|
-
* Include in your signal handlers to ensure a clean shutdown.
|
|
16
|
-
*/
|
|
17
|
-
shutdown(): Promise<void>;
|
|
18
|
-
};
|
|
19
|
-
export type { ContextType };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Durable = 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
|
-
exports.Durable = {
|
|
11
|
-
Client: client_1.ClientService,
|
|
12
|
-
Connection: connection_1.ConnectionService,
|
|
13
|
-
Search: search_1.Search,
|
|
14
|
-
Worker: worker_1.WorkerService,
|
|
15
|
-
workflow: workflow_1.WorkflowService,
|
|
16
|
-
/**
|
|
17
|
-
* Shutdown everything. All connections, workers, and clients will be closed.
|
|
18
|
-
* Include in your signal handlers to ensure a clean shutdown.
|
|
19
|
-
*/
|
|
20
|
-
async shutdown() {
|
|
21
|
-
await client_1.ClientService.shutdown();
|
|
22
|
-
await worker_1.WorkerService.shutdown();
|
|
23
|
-
await hotmesh_1.HotMeshService.stop();
|
|
24
|
-
},
|
|
25
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*********** HOTMESH 'DURABLE' 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
|
-
* Redis as the backend.
|
|
7
|
-
*
|
|
8
|
-
* It's particularly useful for organizations with high-speed, high-volume
|
|
9
|
-
* use cases as it uses in-memory Redis Streams for transactional,
|
|
10
|
-
* workflow processing, while adhering to Temporal's developer-friendly syntax.
|
|
11
|
-
*
|
|
12
|
-
* This YAML file can also serve as a useful starting point for building
|
|
13
|
-
* Integration/BPM/Workflow servers in general (MuleSoft, etc) without the need
|
|
14
|
-
* for a physical application server.
|
|
15
|
-
*
|
|
16
|
-
* Possible use cases include:
|
|
17
|
-
* * Orchestration servers
|
|
18
|
-
* * Integration servers
|
|
19
|
-
* * BPMN engines
|
|
20
|
-
* * Reentrant process servers
|
|
21
|
-
* * Service Meshes
|
|
22
|
-
* * Master Data Management systems
|
|
23
|
-
*/
|
|
24
|
-
declare const APP_VERSION = "2";
|
|
25
|
-
declare const APP_ID = "durable";
|
|
26
|
-
/**
|
|
27
|
-
* returns a new durable workflow schema
|
|
28
|
-
* @param {string} app - app name (e.g., 'durable')
|
|
29
|
-
* @param {string} version - number as string (e.g., '1')
|
|
30
|
-
* @returns {string} HotMesh App YAML
|
|
31
|
-
*/
|
|
32
|
-
declare const getWorkflowYAML: (app: string, version: string) => string;
|
|
33
|
-
export { getWorkflowYAML, APP_VERSION, APP_ID };
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { HotMeshService as HotMesh } from '../hotmesh';
|
|
2
|
-
import { RedisClient, RedisMulti } from '../../types/redis';
|
|
3
|
-
import { StoreService } from '../store';
|
|
4
|
-
import { WorkflowSearchOptions } from '../../types/durable';
|
|
5
|
-
export declare class Search {
|
|
6
|
-
jobId: string;
|
|
7
|
-
searchSessionId: string;
|
|
8
|
-
searchSessionIndex: number;
|
|
9
|
-
hotMeshClient: HotMesh;
|
|
10
|
-
store: StoreService<RedisClient, RedisMulti> | null;
|
|
11
|
-
cachedFields: Record<string, string>;
|
|
12
|
-
constructor(workflowId: string, hotMeshClient: HotMesh, searchSessionId: string);
|
|
13
|
-
/**
|
|
14
|
-
* Prefixes the key with an underscore to keep separate from the
|
|
15
|
-
* activity and job history (and searchable via HKEYS)
|
|
16
|
-
* @param {string} key - the key to be sanitized. Wrap in quotes to avoid sanitization.
|
|
17
|
-
* @returns {string} - the sanitized key
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
|
-
safeKey(key: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* For those deployments with a redis stack backend (with the FT module),
|
|
23
|
-
* this method will configure the search index for the workflow. For all
|
|
24
|
-
* others, this method will exit/fail gracefully and not index
|
|
25
|
-
* the fields in the HASH. All values are searchable via HKEYS/HSC/HGET
|
|
26
|
-
* @param {HotMesh} hotMeshClient - the hotmesh client
|
|
27
|
-
* @param {WorkflowSearchOptions} search - the search options
|
|
28
|
-
* @returns {Promise<void>}
|
|
29
|
-
* @example
|
|
30
|
-
* const search = {
|
|
31
|
-
* index: 'my_search_index',
|
|
32
|
-
* prefix: ['my_workflow_prefix'],
|
|
33
|
-
* schema: {
|
|
34
|
-
* field1: { type: 'TEXT', sortable: true },
|
|
35
|
-
* field2: { type: 'NUMERIC', sortable: true }
|
|
36
|
-
* }
|
|
37
|
-
* }
|
|
38
|
-
* await Search.configureSearchIndex(hotMeshClient, search);
|
|
39
|
-
*/
|
|
40
|
-
static configureSearchIndex(hotMeshClient: HotMesh, search?: WorkflowSearchOptions): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* For those deployments with a redis stack backend (with the FT module),
|
|
43
|
-
* this method will list all search indexes.
|
|
44
|
-
*
|
|
45
|
-
* @param {HotMesh} hotMeshClient - the hotmesh client
|
|
46
|
-
* @returns {Promise<string[]>} - the list of search indexes
|
|
47
|
-
* @example
|
|
48
|
-
* const searchIndexes = await Search.listSearchIndexes(hotMeshClient);
|
|
49
|
-
*/
|
|
50
|
-
static listSearchIndexes(hotMeshClient: HotMesh): Promise<string[]>;
|
|
51
|
-
/**
|
|
52
|
-
* increments the index to return a unique search session guid when
|
|
53
|
-
* calling any method that produces side effects (changes the value)
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
getSearchSessionGuid(): string;
|
|
57
|
-
/**
|
|
58
|
-
* Sets the fields listed in args. Returns the
|
|
59
|
-
* count of new fields that were set (does not
|
|
60
|
-
* count fields that were updated)
|
|
61
|
-
* @param args
|
|
62
|
-
* @returns {number}
|
|
63
|
-
* @example
|
|
64
|
-
* const search = new Search();
|
|
65
|
-
* const count = await search.set('field1', 'value1', 'field2', 'value2');
|
|
66
|
-
*/
|
|
67
|
-
set(...args: string[]): Promise<number>;
|
|
68
|
-
/**
|
|
69
|
-
* Returns the value of the field in the HASH stored at key.
|
|
70
|
-
* @param key
|
|
71
|
-
* @returns {string}
|
|
72
|
-
* @example
|
|
73
|
-
* const search = new Search();
|
|
74
|
-
* const value = await search.get('field1');
|
|
75
|
-
*/
|
|
76
|
-
get(key: string): Promise<string>;
|
|
77
|
-
/**
|
|
78
|
-
* Returns the values of all specified fields in the HASH stored at key.
|
|
79
|
-
* @param args
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
mget(...args: string[]): Promise<string[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Deletes the fields provided as args. Returns the
|
|
85
|
-
* count of fields that were deleted.
|
|
86
|
-
*
|
|
87
|
-
* @param args
|
|
88
|
-
* @returns {number}
|
|
89
|
-
* @example
|
|
90
|
-
* sont search = new Search();
|
|
91
|
-
* const count = await search.del('field1', 'field2', 'field3');
|
|
92
|
-
*/
|
|
93
|
-
del(...args: string[]): Promise<number | void>;
|
|
94
|
-
/**
|
|
95
|
-
* Increments the value of a float field by the given amount. Returns the
|
|
96
|
-
* new value of the field after the increment. Pass a negative
|
|
97
|
-
* number to decrement the value.
|
|
98
|
-
*
|
|
99
|
-
* @param key - the key to increment
|
|
100
|
-
* @param val - the value to increment by
|
|
101
|
-
* @returns {number} - the new value
|
|
102
|
-
* @example
|
|
103
|
-
* const search = new Search();
|
|
104
|
-
* const count = await search.incr('field1', 1.5);
|
|
105
|
-
*/
|
|
106
|
-
incr(key: string, val: number): Promise<number>;
|
|
107
|
-
/**
|
|
108
|
-
* Multiplies the value of a field by the given amount. Returns the
|
|
109
|
-
* new value of the field after the multiplication. NOTE:
|
|
110
|
-
* this is exponential multiplication.
|
|
111
|
-
*
|
|
112
|
-
* @param key - the key to multiply
|
|
113
|
-
* @param val - the value to multiply by
|
|
114
|
-
* @returns {number} - the new product of the multiplication
|
|
115
|
-
* @example
|
|
116
|
-
* const search = new Search();
|
|
117
|
-
* const product = await search.mult('field1', 1.5);
|
|
118
|
-
*/
|
|
119
|
-
mult(key: string, val: number): Promise<number>;
|
|
120
|
-
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { HotMeshService as HotMesh } from '../hotmesh';
|
|
2
|
-
import { ActivityConfig, HookOptions, ProxyType, WorkflowContext, WorkflowOptions } from '../../types/durable';
|
|
3
|
-
import { JobInterruptOptions } from '../../types/job';
|
|
4
|
-
import { DurableChildErrorType, DurableProxyErrorType } from '../../types/error';
|
|
5
|
-
import { Search } from './search';
|
|
6
|
-
export declare class WorkflowService {
|
|
7
|
-
/**
|
|
8
|
-
* Returns the synchronous output from the activity (replay)
|
|
9
|
-
* if available locally, revealing whether or not the activity already
|
|
10
|
-
* ran during a prior execution cycle
|
|
11
|
-
* @param {string} prefix - one of: proxy, child, start, wait etc
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
static didRun(prefix: string): Promise<[boolean, number, any]>;
|
|
15
|
-
/**
|
|
16
|
-
* Those methods that may only be called once must be protected by flagging
|
|
17
|
-
* their execution with a unique key (the key is stored in the HASH alongside
|
|
18
|
-
* process state and job state)
|
|
19
|
-
* @private
|
|
20
|
-
*/
|
|
21
|
-
static isSideEffectAllowed(hotMeshClient: HotMesh, prefix: string): Promise<boolean>;
|
|
22
|
-
/**
|
|
23
|
-
* Returns the current workflow context restored
|
|
24
|
-
* from Redis
|
|
25
|
-
*/
|
|
26
|
-
static getContext(): WorkflowContext;
|
|
27
|
-
/**
|
|
28
|
-
* Return a handle to the hotmesh client hosting the workflow execution
|
|
29
|
-
* @returns {Promise<HotMesh>} - a hotmesh client
|
|
30
|
-
*/
|
|
31
|
-
static getHotMesh(): Promise<HotMesh>;
|
|
32
|
-
/**
|
|
33
|
-
* Spawns a child workflow and awaits the return.
|
|
34
|
-
* @template T - the result type
|
|
35
|
-
* @param {WorkflowOptions} options - the workflow options
|
|
36
|
-
* @returns {Promise<T>} - the result of the child workflow
|
|
37
|
-
* @example
|
|
38
|
-
* const result = await Durable.workflow.execChild<typeof resultType>({ ...options });
|
|
39
|
-
*/
|
|
40
|
-
static execChild<T>(options: WorkflowOptions): Promise<T>;
|
|
41
|
-
/**
|
|
42
|
-
* constructs the payload necessary to spawn a child job
|
|
43
|
-
* @private
|
|
44
|
-
*/
|
|
45
|
-
static getChildInterruptPayload(context: WorkflowContext, options: WorkflowOptions, execIndex: number): DurableChildErrorType;
|
|
46
|
-
/**
|
|
47
|
-
* Spawns a child workflow and returns the child Job ID.
|
|
48
|
-
* This method guarantees the spawned child has reserved the Job ID,
|
|
49
|
-
* returning a 'DuplicateJobError' error if not. Otherwise,
|
|
50
|
-
* this is a fire-and-forget method.
|
|
51
|
-
*
|
|
52
|
-
* @param {WorkflowOptions} options - the workflow options
|
|
53
|
-
* @returns {Promise<string>} - the childJobId
|
|
54
|
-
* @example
|
|
55
|
-
* const childJobId = await Durable.workflow.startChild({ ...options });
|
|
56
|
-
*/
|
|
57
|
-
static startChild(options: WorkflowOptions): Promise<string>;
|
|
58
|
-
/**
|
|
59
|
-
* Wraps activities in a proxy that durably runs/re-runs them to completion.
|
|
60
|
-
* TODO: verify that activities do not collide if named same on same server but bound to different workflows
|
|
61
|
-
*
|
|
62
|
-
* @param {ActivityConfig} options - the activity configuration
|
|
63
|
-
* that will be used to wrap the activities.
|
|
64
|
-
* @returns {ProxyType<ACT>} - a proxy object with the same keys as the
|
|
65
|
-
* activities object, but with the values replaced by a wrapped function
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* // import the activities
|
|
69
|
-
* import * as activities from './activities';
|
|
70
|
-
* const proxy = WorkflowService.proxyActivities<typeof activities>({ activities });
|
|
71
|
-
*
|
|
72
|
-
* //or destructure the proxy object, as the function names are the keys
|
|
73
|
-
* const { activity1, activity2 } = WorkflowService.proxyActivities<typeof activities>({ activities });
|
|
74
|
-
*/
|
|
75
|
-
static proxyActivities<ACT>(options?: ActivityConfig): ProxyType<ACT>;
|
|
76
|
-
static wrapActivity<T>(activityName: string, options?: ActivityConfig): T;
|
|
77
|
-
/**
|
|
78
|
-
* constructs the payload necessary to spawn a proxyActivity job
|
|
79
|
-
* @private
|
|
80
|
-
*/
|
|
81
|
-
static getProxyInterruptPayload(context: WorkflowContext, activityName: string, execIndex: number, args: any[], options?: ActivityConfig): DurableProxyErrorType;
|
|
82
|
-
/**
|
|
83
|
-
* Returns a search session for use when reading/writing to the workflow HASH.
|
|
84
|
-
* The search session provides access to methods like `get`, `mget`, `set`, `del`, and `incr`.
|
|
85
|
-
* @returns {Promise<Search>} - a search session
|
|
86
|
-
*/
|
|
87
|
-
static search(): Promise<Search>;
|
|
88
|
-
/**
|
|
89
|
-
* Returns a random number between 0 and 1. This number is deterministic
|
|
90
|
-
* and will never vary for a given seed. This is useful for randomizing
|
|
91
|
-
* pathways in a workflow that can be safely replayed.
|
|
92
|
-
* @returns {number} - a random number between 0 and 1
|
|
93
|
-
*/
|
|
94
|
-
static random(): number;
|
|
95
|
-
/**
|
|
96
|
-
* Sends signal data into any other paused thread (which is currently
|
|
97
|
-
* awaiting the signal)
|
|
98
|
-
* @param {string} signalId - the signal id
|
|
99
|
-
* @param {Record<any, any>} data - the signal data
|
|
100
|
-
* @returns {Promise<string>} - the stream id
|
|
101
|
-
*/
|
|
102
|
-
static signal(signalId: string, data: Record<any, any>): Promise<string>;
|
|
103
|
-
/**
|
|
104
|
-
* Spawns a hook from either the main thread or a hook thread with
|
|
105
|
-
* the provided options; worflowId/TaskQueue/Name are optional and will
|
|
106
|
-
* default to the current workflowId/WorkflowTopic if not provided
|
|
107
|
-
* @param {HookOptions} options - the hook options
|
|
108
|
-
*/
|
|
109
|
-
static hook(options: HookOptions): Promise<string>;
|
|
110
|
-
/**
|
|
111
|
-
* Executes a function once and caches the result. If the function is called
|
|
112
|
-
* again, the cached result is returned. This is useful for wrapping
|
|
113
|
-
* expensive activity calls that should only be run once, but which might
|
|
114
|
-
* not require the cost and safety provided by proxyActivities.
|
|
115
|
-
* @template T - the result type
|
|
116
|
-
*/
|
|
117
|
-
static once<T>(fn: (...args: any[]) => Promise<T>, ...args: any[]): Promise<T>;
|
|
118
|
-
/**
|
|
119
|
-
* Interrupts a running job
|
|
120
|
-
*/
|
|
121
|
-
static interrupt(jobId: string, options?: JobInterruptOptions): Promise<string | void>;
|
|
122
|
-
/**
|
|
123
|
-
* Promise.all (limited to 25 total concurrent workflow)
|
|
124
|
-
*/
|
|
125
|
-
static all<T>(...promises: Promise<T>[]): Promise<T[]>;
|
|
126
|
-
/**
|
|
127
|
-
* Sleeps the workflow for a duration. As the function is reentrant,
|
|
128
|
-
* upon reentry, the function will traverse prior execution paths up
|
|
129
|
-
* until the sleep command and then resume execution thereafter.
|
|
130
|
-
* @param {string} duration - See the `ms` package for syntax examples: '1 minute', '2 hours', '3 days'
|
|
131
|
-
* @returns {Promise<number>} - resolved duration in seconds
|
|
132
|
-
*/
|
|
133
|
-
static sleepFor(duration: string): Promise<number>;
|
|
134
|
-
/**
|
|
135
|
-
* Pauses the workflow until `signalId` is received.
|
|
136
|
-
* @template T - the result type
|
|
137
|
-
* @param {string} signalId - a unique, shareable guid (e.g, 'abc123')
|
|
138
|
-
* @returns {Promise<T>}
|
|
139
|
-
* @example
|
|
140
|
-
* const result = await Durable.workflow.waitFor<typeof resultType>('abc123');
|
|
141
|
-
*/
|
|
142
|
-
static waitFor<T>(signalId: string): Promise<T>;
|
|
143
|
-
}
|