Dex TypeScript SDK 1.29.0
    Preparing search index...

    Interface PullWorkerOptions

    Configures an outbound pull Worker.

    Pass this as WorkerOptions.pull to customize task capacity and shutdown. Each stream handles one task, while handlers on different streams can run concurrently.

    const worker = new Worker(registry, cache, { pull: { maxConcurrentTasks: 8 } });
    await worker.start();
    const client = new Client(registry, cache);
    try { await client.startFlow(flow, flowId); } finally { await client.close(); await worker.close(); }
    interface PullWorkerOptions {
        appWorkerID?: string;
        idleStreamsPerQueue?: number;
        maxConcurrentTasks?: number;
        reservedRpcTasks?: number;
        stopDrainTimeoutMs?: number;
        stopOnPermanentStreamRejection?: boolean;
    }
    Index

    Properties

    appWorkerID?: string

    Process-unique Worker ID; defaults to host identity plus eight random base32 characters. Use a new ID after every restart. Values contain 1-63 ASCII letters, digits, dots, underscores, or hyphens and cannot equal a registered Flow type.

    idleStreamsPerQueue?: number

    Waiting streams on each queue; zero or omission uses one. A queue keeps one more after a recent reserve decline. Use at least two for heavy Step backlogs. Negative values are invalid.

    maxConcurrentTasks?: number

    Maximum simultaneous handlers; zero or omission uses the logical CPU count. Negative values are invalid.

    reservedRpcTasks?: number

    Reserves capacity to protect synchronous RPC latency from long-running Steps. Unset reserves one slot when resolved capacity is at least two, otherwise zero. With the CPU-count default, Steps get one fewer slot than before. Set zero to opt out. With one slot and no explicit reserve, start warns once that RPCs may wait behind Steps. Flows must stay responsive because RPCs share Worker task capacity with Steps. WaitFor and Execute tasks, including local attempts, are declined when total busy handlers reach maxConcurrentTasks minus this reserve. RPCs can use the full task limit, including API-direct and transactional RPCs. Requires an integer at least zero and below the task limit after its CPU-count default is resolved; construction throws RangeError otherwise. Declines reassign without consuming an attempt. If all Workers remain at their Step limit through the dispatch wait, NO_WORKER_AVAILABLE consumes an attempt and follows the Step retry policy. Local attempts wait the local dispatch wait, then fall back according to their policy. Declines emit a node:util debuglog message under dex:pull with the Flow type. The pullReservedRpcDeclines counter increments; registration readiness is unaffected. A queue keeps one extra idle stream for 30 seconds after its last reserve decline. The Worker does not open it while all task slots are busy.

    const pull: PullWorkerOptions = { maxConcurrentTasks: 8, reservedRpcTasks: 2 };
    
    stopDrainTimeoutMs?: number

    Milliseconds allowed for graceful shutdown and busy Reconnect final-frame delivery; defaults to 30000. Requires a non-negative finite value. After shutdown expiry, Worker.close cancels active handlers and waits for them to return.

    stopOnPermanentStreamRejection?: boolean

    Stops and drains the Worker when a permanent rejection leaves a queue without registered streams. Defaults to false, retrying indefinitely. Worker.run rejects with PullRegistrationError after draining; Worker.start keeps its non-blocking startup behavior.