Workers Overview
Workers are external processes that poll the workflow-graph server for jobs, execute them, and report results. They communicate over HTTP, so you can write workers in any language.
Three Ways to Run a Worker
- Standalone binary — run the pre-built Rust worker with env vars
- Embedded SDK — use the
workflow-graph-worker-sdkcrate as a library in your own Rust binary - Custom HTTP client — implement the worker protocol in any language
Standalone Binary
The simplest way to run a worker:
cargo run -p workflow-graph-worker-sdkEnvironment Variables
| Variable | Default | Description |
|---|---|---|
SERVER_URL | http://localhost:3000 | Server base URL |
WORKER_LABELS | (empty) | Comma-separated capability labels |
SERVER_URL=http://my-server:3000 \WORKER_LABELS=docker,linux,gpu \cargo run -p workflow-graph-worker-sdkThe standalone binary:
- Executes the job’s
commandfield viash -c - Streams stdout/stderr as log chunks
- Sends heartbeats automatically
- Checks for cancellation
Limitation: The standalone binary only runs shell commands. For Docker containers, API calls, or structured outputs, use the Worker SDK or a custom worker.
Worker Lifecycle
Register → Poll for jobs → Claim job → Execute ↑ │ │ ├─ Send heartbeats (concurrent) │ ├─ Stream logs (concurrent) │ ├─ Check cancellation (concurrent) │ │ │ ▼ └──── Report result (success/failure)- Register with the server, declaring capability labels
- Poll for available jobs matching your labels
- Claim a job atomically (lease-based, prevents double-claiming)
- Execute the job command while concurrently:
- Sending heartbeats to keep the lease alive
- Streaming log output
- Checking for cancellation
- Report success (with optional outputs) or failure (with retry hint)
- Loop back to step 2