workers

package
v0.19.0 Latest Latest
Warning

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

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

Documentation

Overview

Package workers records each eval worker's check-in and tells the owner whether it can run the configured judge and panel.

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, cfg *evalqueue.EvalConfig, now time.Time)

Readiness fills each worker's problems against the configured panel and the other workers' sandbox image.

func RegisterRoutes

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

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

Types

type ProviderSource

type ProviderSource interface {
	EvalConfig(ctx context.Context) (*evalqueue.EvalConfig, error)
	Backends(ctx context.Context) ([]evalqueue.EvalBackend, error)
}

ProviderSource lists the server's providers and the configured panel.

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 Verification

type Verification struct {
	Provider string   `json:"provider"`
	OK       bool     `json:"ok"`
	Detail   string   `json:"detail"`
	Models   []string `json:"models"`
}

Verification is one provider check a worker ran with its own credential.

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"`
	Pinned           string         `json:"pinned,omitempty"`
	Credentials      []string       `json:"credentials" maxItems:"64"`
	Verifications    []Verification `json:"verifications" maxItems:"32"`
}

WorkersCheckin is what a worker reports on each poll.

type WorkersCheckinReply

type WorkersCheckinReply struct {
	Providers []evalqueue.EvalBackend `json:"providers"`
}

WorkersCheckinReply names the providers a worker must hold credentials for.

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, with the key and the
	// endpoint filled in and each provider credential left for the owner.
	Env []WorkersEnvVar `json:"env"`
}

type WorkersListBody

type WorkersListBody struct {
	Workers []Worker `json:"workers"`
	// Models is every model id any worker listed, per provider, for the
	// panel's dropdowns.
	Models map[string][]string `json:"models"`
}

Jump to

Keyboard shortcuts

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