Workers

Workers are async Rust functions registered at compile time via #[worker]. Each run becomes an execution graph with durable checkpoints.

LIVE

Run docs_showcase worker

Starts docs_showcase on this server — watch logs, progress, pause/resume/cancel, and the final result.

How to use this demo

  1. Click Run worker — a ~25s graph starts; the execution panel appears below.
  2. In the panel, open Controls and wait until status is Running.
  3. While Running, try Pause, Resume, or Cancel.
  4. When status is done, run again to start a fresh graph (the event stream clears).

Ready — start with step 1.

Execution panel

Graph, controls, and event stream appear here after you click Run worker.

Define a worker

use resuma::prelude::*;
use serde::Deserialize;

#[derive(Deserialize)]
struct EnrichInput {
    url: String,
}

#[worker(intent = "fetch URL and enrich with AI")]
async fn enrich(input: EnrichInput, ctx: WorkerContext) -> Result<Value> {
    ctx.log("fetching");
    let page = ctx.tool("fetch", json!({ "url": input.url })).await?;
    ctx.progress(50);
    let summary = ctx.tool("ai", json!({
        "prompt": "Extract key facts",
        "data": page
    })).await?;
    Ok(summary)
}

WorkerContext API

MethodPurpose
ctx.log(msg)Emit log event (SSE + replay)
ctx.progress(n)0–100 progress hint
ctx.tool(name, args)Call registered tool
ctx.state_set(k, v)Checkpoint key/value
ctx.check_cancelled()Cooperative pause/cancel

Manual registration

WorkerRegistry::new()
    .register(
        "my_worker",
        WorkerMeta {
            intent: "process items".into(),
            resources: Resources::auto(),
        },
        |input, ctx| Box::pin(async move { Ok(input) }),
    )
    .install();

Start a graph

let started = FlowEngine::start("enrich", json!({ "url": "https://example.com" })).await?;
    // started.graph_id, started.access_token, started.plan

HTTP & queue

POST /_resuma/worker/enrich
Authorization: Bearer $RESUMA_EXEC_API_KEY
{ "input": { "url": "https://example.com" } }

POST /_resuma/queue/default
{ "worker": "enrich", "input": { "url": "..." } }

Graph lifecycle

StatusMeaning
runningWorker executing
pausedCooperative stop — resumable
doneSuccess
failedError or operator cancel
  • POST /_resuma/graph/{id}/pause — pause (resumable)
  • POST /_resuma/graph/{id}/resume — continue from checkpoint
  • POST /_resuma/graph/{id}/cancel — permanent abort

← Overview · Queue → · Flow UI →