Dex TypeScript SDK 1.35.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

    Legacy per-queue idle stream option; zero or omission formerly used one. Still accepts nonnegative integers; invalid values throw RangeError.

    Has no effect. Each maxConcurrentTasks slot has one long-lived stream.

    maxConcurrentTasks?: number

    Number of execution slots, each represented by one long-lived poll stream. Zero or omission uses the logical CPU count. Negative values are invalid. Worker.start fails if this exceeds the Server per-Worker limit, matching.maxConcurrentTasksCap.

    reservedRpcTasks?: number

    Number of long-lived slots that accept only RPCs. Unset reserves one slot when maxConcurrentTasks resolves to at least two, otherwise zero. Set zero to let every slot accept Steps and RPCs. Steps are never declined for capacity. With one slot and no explicit reserve, start warns once that RPCs may wait behind Steps. Requires an integer at least zero and less than maxConcurrentTasks; construction throws RangeError otherwise. RPCs can use shared slots and reserved slots. Reservation is capacity, not a latency guarantee.

    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; zero selects the default. On stop, idle streams half-close immediately; busy streams send final output before half-closing. Tasks arriving after stop begins are dropped. Half-closed streams keep reading until the Server ends them. On expiry, streams whose handler has not written final output are reset and their handlers canceled; close waits for handlers to return. A handler whose final output is written still half-closes. Half-closed streams without Server EOF are reset at the deadline. A stream whose final output the Server has not yet confirmed gets 5 more seconds, so close can return that much later. A Server-requested reconnect uses the same timeout and grace. Dex treats a task dropped on such a reset stream as possibly run.

    stopOnPermanentStreamRejection?: boolean

    Stops and drains the Worker when a permanent rejection leaves a slot kind without registered streams. Defaults to false, retrying indefinitely. Worker.run rejects with PullRegistrationError after draining; Worker.start waits for the first successful registration and the Server concurrency-limit check.