worker

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package worker is the headless host that executes agent runs queued by other processes (a web server, an API, a scheduler): it connects to the shared Redis queue and Postgres store, consumes runs, and exposes an admin HTTP server (/healthz, /readyz, /metrics). Several workers can run in parallel, each with its own sandboxes.

Index

Constants

View Source
const DefaultAddr = "127.0.0.1:9090"

DefaultAddr is the admin address when neither Options.Addr nor HARNESS_WORKER_ADDR is set.

Variables

View Source
var ErrPrivateQueue = errors.New("worker: the run queue is in memory, private to this process, so no other process can queue work for it (connect Redis, or pass Standalone)")

ErrPrivateQueue: the worker's run queue lives in its own memory, so it could never receive work.

Functions

func Run

func Run(ctx context.Context, o Options) error

Run builds the harness, serves the admin endpoints and consumes runs until ctx is done (or, with Once, until the queue is drained). On ctx done it stops claiming, lets in-flight runs finish for RUNTIME_SHUTDOWN_GRACE_SECONDS (then the runtime interrupts them and records why) and returns nil.

Types

type Options

type Options struct {
	// Config is the environment configuration (default: config.Load()).
	Config *config.Config
	// Addr is the admin listen address (default: HARNESS_WORKER_ADDR, else 127.0.0.1:9090).
	Addr string
	// Standalone allows a private in-memory queue and store (a single process; mostly for tests and demos).
	Standalone bool
	// Once processes the queued runs until none is queued or running, then returns.
	Once bool
	// IdleFor is how long the queue must stay empty in Once mode (default 1 s).
	IdleFor time.Duration
	// RuntimeID names this worker in run ownership (default: hostname-random).
	RuntimeID string

	// Overrides, mostly for tests; nil builds them from Config.
	Store   harness.Store
	Redis   redis.UniversalClient
	Models  llm.Factory
	Backend sandbox.Backend

	// OnListening is called with the admin address once the server accepts connections.
	OnListening func(addr string)
}

Options configures Run. The zero value reads everything from the environment.

type Wiring

type Wiring struct {
	Store   string // postgres | memory | the Go type of a custom store
	Queue   string // redis | memory
	Sandbox string // opensandbox | local | custom | none
}

Wiring says what the harness of a worker is connected to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL