Workers

A worker is any long-running process that claims jobs from Mobius and runs them. Workers are how your code participates in workflows — Mobius doesn't run your business logic, it coordinates the workers that do.

The protocol

The worker protocol is intentionally tiny. Three HTTP endpoints:

EndpointPurpose
POST /projects/{handle}/jobs/claimLong-poll for the next job
POST /projects/{handle}/jobs/{id}/heartbeatKeep an in-progress job alive
POST /projects/{handle}/jobs/{id}/completeReport the job result

Anything that can speak HTTP can be a worker. We ship official SDKs for Go and TypeScript, but a Bash script with curl would work too.

SDK example

w, err := worker.New(worker.Config{
    BaseURL:        "https://api.mobius.deepnoodle.ai",
    APIKey:         os.Getenv("MOBIUS_API_KEY"),
    Name:           "image-resizer",
    Concurrency:    4,
    DrainTimeout:   30 * time.Second,
    Handler: func(ctx context.Context, job *worker.Task) (*worker.Result, error) {
        // do work...
        return &worker.Result{Output: map[string]any{"size": 1024}}, nil
    },
})

Heartbeats and timeouts

A worker that stops sending heartbeats is presumed dead. Mobius will reclaim the job and hand it to another worker after the configured job timeout.

The Go SDK manages heartbeats automatically — you only need to make sure your handler returns or the context completes before the timeout.

Graceful shutdown

When the worker process receives SIGTERM, the SDK stops claiming new jobs but lets in-flight handlers finish. The DrainTimeout caps how long it waits before forcibly exiting. This lets you deploy without dropping work.

See also