agent

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 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 agent connects the runner to Backproof.

Index

Constants

View Source
const (
	ExitPassed       = 0
	ExitBackupFailed = 1
	ExitRunnerError  = 2
)

Exit codes of a one-shot run, which CI systems act on.

Variables

This section is empty.

Functions

func DefaultCapabilities

func DefaultCapabilities() api.Capabilities

DefaultCapabilities lists what this build of the runner can do.

func ToResult

func ToResult(result job.Result, tableKey job.TableKeyFunc) api.JobResult

ToResult turns a job's result into what is sent to Backproof. docs/payload.md lists every field.

Types

type Agent

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

Agent polls Backproof for due jobs and runs them.

func New

func New(options Options) *Agent

New returns an agent.

func (*Agent) Run

func (a *Agent) Run(ctx, jobs context.Context) error

Run polls until ctx ends, then waits for the running jobs to finish. Ending jobs stops those jobs as well, so a drain can be cut short.

func (*Agent) RunOnce

func (a *Agent) RunOnce(ctx, jobs context.Context) (OnceSummary, error)

RunOnce runs the jobs that are due, one after another, and returns when none are left.

type JobContext

type JobContext struct {
	OnStage     func(job.Stage)
	RunningJobs func() []string
}

JobContext connects a running job to the agent.

type JobRunnerOptions

type JobRunnerOptions struct {
	Engine      job.Engine
	Logger      *slog.Logger
	WorkDir     string
	DiskMargin  float64
	Lookup      config.LookupFunc
	SourcesFile string
	// RunnerKey opens the keys sealed for this runner in the dashboard.
	RunnerKey config.Secret
}

JobRunnerOptions configures how claimed jobs are run.

type OnceSummary

type OnceSummary struct {
	Passed int
	Failed int
	Errors int
}

OnceSummary counts the outcomes of a one-shot run.

func (OnceSummary) ExitCode

func (s OnceSummary) ExitCode(runErr error) int

ExitCode reports a broken backup first, because that is the finding someone has to act on.

type Options

type Options struct {
	Client       *api.RunnerClient
	Run          Runner
	Logger       *slog.Logger
	Concurrency  int
	Version      string
	Capabilities api.Capabilities
}

Options configures an Agent.

type RegisterOptions

type RegisterOptions struct {
	InstallToken config.Secret
	Name         string
	APIURL       string
	FilePath     string
}

RegisterOptions configures a registration.

type Registration

type Registration struct {
	RunnerID    string
	Name        string
	Fingerprint string
}

Registration describes a newly registered runner.

func Register

func Register(ctx context.Context, client *api.RunnerClient, options RegisterOptions) (Registration, error)

Register trades an install token for a runner credential and saves it with a new key pair.

type Runner

type Runner func(ctx context.Context, assigned api.Job, jobContext JobContext) api.JobResult

Runner tests the backup of one claimed job.

func NewJobRunner

func NewJobRunner(options JobRunnerOptions) Runner

NewJobRunner returns the Runner that tests a claimed job's latest backup.

Jump to

Keyboard shortcuts

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