Skip to content
Documentation

Workers

Workers are external processes that speak CAP, subscribe on NATS, hydrate context pointers, execute work, and publish job results and heartbeats back to the control plane.

Bus subjects
sys.job.submitsys.job.resultsys.job.progresssys.job.cancelsys.heartbeatjob.*worker.<id>.jobs
Heartbeat fields

CAP heartbeats advertiseworker_id,pool,max_parallel_jobs, CPU/memory load, capabilities, labels, and optional progress hints.

Go example from the core repo

examples/hello-worker-go/main.go
agent := &runtime.Agent{
  NATSURL:  envOr("NATS_URL", "nats://127.0.0.1:4222"),
  RedisURL: envOr("REDIS_URL", "redis://:cordum-dev@127.0.0.1:6379/0"),
  SenderID: workerID,
}

runtime.Register(agent, "job.hello-pack.echo", handler)
runtime.Register(agent, runtime.DirectSubject(workerID), handler)

if err := agent.Start(); err != nil {
  log.Fatalf("runtime start: %v", err)
}

The CAP protobuf definitions live in the separatecaprepository, while the core repo includes a higher-level Go runtime used by the built-in examples.

SDK status

  • Go, Python, and Node have the most complete high-level runtime helpers today.
  • The cap repository also includes SDK directories for cpp, dotnet, java, php, ruby, and rust.
  • Cordum’s own hello worker example in the core repo uses github.com/cordum/cordum/sdk/runtime.
Source of truth:cap/sdk/README.md