Workflow client. Starts workflows, sends signals, and reads results.

Pass config.events to receive system-event notifications from all escalation operations performed through this client. Events fire post-commit, from this process only — no fanout to other containers. See EventsConfig and SystemEvent in types/system_events for the full ontology.

import { Durable } from '@hotmeshio/hotmesh';
import { Client as Postgres } from 'pg';

const client = new Durable.Client({
connection: {
class: Postgres,
options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' },
},
// optional — wire lifecycle events
events: {
publish: (event) => {
// event.type follows system.escalation.{id}.{verb}
myEventBus.emit(event.type, event.data);
},
},
});

// Start a workflow and await its result
const handle = await client.workflow.start({
args: ['order-123'],
taskQueue: 'orders',
workflowName: 'orderWorkflow',
workflowId: Durable.guid(),
});
const result = await handle.result();

// Send a signal to a running workflow
await handle.signal('approval', { approved: true });

// Cancel a running workflow
await handle.cancel();

Properties

Escalation queue operations — a thin proxy to Escalations.Client that reuses this Durable.Client's engine pool. Calling client.escalations.list(...) is identical to creating a separate new Escalations.Client({ connection }) — just more convenient.

workflow: ClientWorkflow = ...

The Durable Client service provides methods for starting, signaling, and querying workflows. Starting a workflow is the primary use case and is accessed by calling workflow.start().

Methods

  • Any router can be used to deploy and activate the HotMesh distributed executable to the active quorum EXCEPT for those routers in readonly mode.

    Parameters

    • namespace: string = APP_ID
    • version: string = APP_VERSION

    Returns Promise<void>