Constructs a Worker without starting its task streams. Workers need only an outbound connection to the Dex Server.
Flow definitions served by this Worker.
Open cache used to hydrate large handler values.
Server connectivity, task capacity, bearer credential, and startup settings; uses local defaults when omitted.
ReadonlyblobOpen cache used to hydrate large handler values.
ReadonlyoptionsServer connectivity, task capacity, bearer credential, and startup settings; uses local defaults when omitted.
ReadonlyregistryFlow definitions served by this Worker.
Stops new tasks and drains handlers before releasing connections.
Idle streams half-close immediately. Busy streams send their final output before half-closing.
Tasks arriving after stop begins are dropped without running a handler, including after half-close.
Streams keep reading until the Server ends them.
After the drain timeout, streams whose handler has not written final output are reset, those handlers
are canceled, and close waits for them to return. A handler whose final output is written still half-closes.
Half-closed streams that the Server has not ended by the drain deadline are reset.
A stream whose final output the Server has not yet confirmed gets a 5-second flush grace after the deadline.
The Server confirms it by ending the stream or assigning the slot's next task.
Close can therefore return up to 5 seconds after the drain deadline.
Dex treats a task dropped on a reset stream as possibly run.
Calls before start and repeated calls after shutdown are safe.
Returns an independent snapshot of slot-kind registrations. Readiness latches after every configured slot kind registers once. Only a permanent rejection with no registered stream makes it false; re-registration clears the slot-kind error. Stop preserves readiness.
Current readiness and slot-kind snapshots. See waitPullRegistered for a startup and readiness example. Treat errors as immutable.
Starts the Worker and waits until close completes shutdown.
A promise resolved after graceful shutdown and handler completion.
Negotiates the Server protocol, synchronizes indexes, and starts polling. The promise resolves after the first slot registers and its Server concurrency limit is checked; call exactly once. Await waitPullRegistered separately to gate readiness on both configured slot kinds.
A promise resolved after protocol negotiation, index synchronization, and the first registration.
Waits until at least one STEP_AND_RPC stream and, when reserved, one RPC_ONLY stream have registered. Safe before or after start and for concurrent callers. Later calls resolve even after shutdown. Reconnects do not reset completion. Use pullRegistrationState for ongoing readiness probes.
Optional AbortSignal and positive timeout in milliseconds; defaults to waiting indefinitely.
A promise resolved after all configured slot kinds have registered once.
Hosts registered Step and RPC handlers through outbound pull streams.
A Worker is one-shot. Call
startto register the first slot orrunto await shutdown, then callclose. Concurrent handlers must synchronize shared state.closestops new tasks, half-closes idle streams, and lets busy handlers send final output before half-closing. It drains forstopDrainTimeoutMs, then resets streams whose handler has not written final output, cancels those handlers, and waits for them to return. Half-closed streams wait for server EOF until the drain deadline and are then reset. A stream whose final output Dex has not yet confirmed, by ending the stream or assigning its next task, gets 5 more seconds, soclosecan return up to 5 seconds later. A handler that ignores cancellation can delay shutdown.Example