workers

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package workers records each eval worker's check-in and tells the owner whether it is online and on the common sandbox image. Provider keys live on the server, so a worker needs nothing per provider.

Index

Constants

View Source
const StaleAfter = 5 * time.Minute

StaleAfter is how long a worker may be silent before it shows as offline.

Variables

This section is empty.

Functions

func Readiness

func Readiness(list []Worker, now time.Time)

Readiness fills each worker's problems: offline, or on a sandbox image the other workers do not run.

func RegisterRoutes

func RegisterRoutes(api huma.API, s *Store, keys *auth.KeyStore, publicURL func() string)

RegisterRoutes serves the check-in to workers and the list to owners.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store reads and writes check-ins.

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

NewStore returns a store on pool.

func (*Store) Checkin

func (s *Store) Checkin(ctx context.Context, c WorkersCheckin) error

Checkin records one report.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]Worker, error)

List returns every worker seen in the last day, newest first.

type Worker

type Worker struct {
	WorkersCheckin
	FirstSeen time.Time `json:"first_seen"`
	LastSeen  time.Time `json:"last_seen"`
	// Problems are why the worker cannot run the configured panel. Empty means ready.
	Problems []string `json:"problems"`
}

Worker is one worker's last check-in and its readiness.

type WorkersCheckin

type WorkersCheckin struct {
	WorkerID         string `json:"worker_id" minLength:"1" maxLength:"200"`
	Version          string `json:"version"`
	Driver           string `json:"driver"`
	HardwareIsolated bool   `json:"hardware_isolated"`
	NetworkPolicy    bool   `json:"network_policy"`
	Concurrency      int    `json:"concurrency"`
	SandboxImage     string `json:"sandbox_image"`
	// Harness is the agent CLI and version the sandbox image runs.
	Harness string `json:"harness,omitempty"`
}

WorkersCheckin is what a worker reports on each poll.

type WorkersCheckinReply

type WorkersCheckinReply struct {
	OK bool `json:"ok"`
}

WorkersCheckinReply acknowledges a check-in.

type WorkersEnvVar

type WorkersEnvVar struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Secret bool   `json:"secret"`
}

type WorkersKeyBody

type WorkersKeyBody struct {
	Name string `json:"name" minLength:"1" maxLength:"64"`
}

type WorkersKeyReply

type WorkersKeyReply struct {
	Key string `json:"key"`
	// Env is every variable the new worker needs, filled in. Provider keys
	// stay on the server.
	Env []WorkersEnvVar `json:"env"`
}

type WorkersListBody

type WorkersListBody struct {
	Workers []Worker `json:"workers"`
}

Jump to

Keyboard shortcuts

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