@hotmeshio/hotmesh
Version:
Serverless Workflow
109 lines (104 loc) • 3.27 kB
TypeScript
import { HotMesh } from '../hotmesh';
import { ClientConfig, ClientWorkflow, Connection, WorkflowOptions } from '../../types/meshflow';
/**
* The MeshFlow `Client` service is functionally
* equivalent to the Temporal `Client` service.
* Start a new workflow execution by calling
* `workflow.start`. Note the direct connection to
* Postgres.
*
* NATS can be used as the message broker if advanced
* messaging is required (i.e, patterned subscriptions).
* @example
* ```typescript
* //client.ts
* import { Client, HotMesh } from '@hotmeshio/hotmesh';
* import { Client as Postgres } from 'pg';
* async function run(): Promise<string> {
* const client = new Client({
* connection: {
* class: Postgres,
* options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
* }
* });
* const handle = await client.workflow.start({
* args: ['HotMesh'],
* taskQueue: 'default',
* workflowName: 'example',
* workflowId: HotMesh.guid()
* });
* return await handle.result();
* //returns ['Hello HotMesh', '¡Hola, HotMesh!']
* }
* ```
*/
export declare class ClientService {
/**
* @private
*/
connection: Connection;
/**
* @private
*/
options: WorkflowOptions;
/**
* @private
*/
static topics: string[];
/**
* @private
*/
static instances: Map<string, HotMesh | Promise<HotMesh>>;
/**
* @private
*/
constructor(config: ClientConfig);
/**
* @private
*/
getHotMeshClient: (workflowTopic: string | null, namespace?: string) => Promise<HotMesh>;
/**
* Creates a stream where messages can be published to ensure there is a
* channel in place when the message arrives (a race condition for those
* platforms without implicit topic setup).
* @private
*/
static createStream: (hotMeshClient: HotMesh, workflowTopic: string, namespace?: string) => Promise<void>;
hashOptions(): string;
/**
* It is possible for a client to invoke a workflow without first
* creating the stream. This method will verify that the stream
* exists and if not, create it.
* @private
*/
verifyStream: (hotMeshClient: HotMesh, workflowTopic: string, namespace?: string) => Promise<void>;
/**
* @private
*/
search: (hotMeshClient: HotMesh, index: string, query: string[]) => Promise<string[]>;
/**
* The MeshFlow `Client` service is functionally
* equivalent to the Temporal `Client` service.
* Starting a workflow is the primary use case and
* is accessed by calling workflow.start().
*/
workflow: ClientWorkflow;
/**
* Any router can be used to deploy and activate the HotMesh
* distributed executable to the active quorum EXCEPT for
* those routers in `readonly` mode.
*/
deployAndActivate(namespace?: string, version?: string): Promise<void>;
/**
* @private
*/
verifyWorkflowActive(hotMesh: HotMesh, appId?: string, count?: number): Promise<boolean>;
/**
* @private
*/
activateWorkflow(hotMesh: HotMesh, appId?: string, version?: string): Promise<void>;
/**
* @private
*/
static shutdown(): Promise<void>;
}