The Worker service Registers worker functions and connects them to the mesh, using the target backend provider/s (Redis, Postgres, NATS, etc).

import { MeshFlow } from '@hotmeshio/hotmesh';
import { Client as Postgres } from 'pg';
import * as workflows from './workflows';

async function run() {
const worker = await MeshFlow.Worker.create({
connection: {
class: Postgres,
options: { connectionString: 'postgres://user:password@localhost:5432/db' }
},
taskQueue: 'default',
workflow: workflows.example,
});

await worker.run();
}

Methods

  • Connects a worker to the mesh.

    Parameters

    Returns Promise<WorkerService>

    import { MeshFlow } from '@hotmeshio/hotmesh';
    import { Client as Postgres } from 'pg';
    import * as workflows from './workflows';

    async function run() {
    const worker = await MeshFlow.Worker.create({
    connection: {
    class: Postgres,
    options: {
    connectionString: 'postgres://user:password@localhost:5432/db'
    },
    },
    taskQueue: 'default',
    workflow: workflows.example,
    });

    await worker.run();
    }