Documentation
¶
Overview ¶
Package buildrunners decides when elastic build runners should be created or destroyed. It is pure: callers gather the facts and act on the plan.
Index ¶
Constants ¶
const ( KindPlatform = "platform" KindCapacity = "capacity" )
Demand kinds.
const ( CodeNoAccount = "no_account" CodeNoRegion = "no_region_allowed" CodeNoSize = "no_size_for_arch" CodeBudgetZero = "budget_zero" CodeMaxRunners = "max_runners" CodePriceUnknown = "price_unknown" CodeBudgetExceeded = "budget_exceeded" CodeUnknownArch = "unknown_arch" )
Stable refusal codes, safe to match on in the API, audit rows and the dashboard.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Caps ¶
type Caps struct {
AccountID string
MaxRunners int
MaxMonthlyUSD float64
IdleTTL time.Duration
AllowedRegions []string
// SizeByArch maps an arch such as linux/arm64 to the one size used for it.
SizeByArch map[string]string
// PriceBySize is the listed monthly price per size; a missing size is refused.
PriceBySize map[string]float64
// SpentMonthUSD is what live and past elastic runners already cost this month.
SpentMonthUSD float64
}
Caps are every limit the planner obeys. Zero values refuse, so a caller that forgets a field creates nothing.
type Destroy ¶
type Destroy struct {
RunnerID string `json:"runner_id"`
Arch string `json:"arch"`
IdleSeconds int64 `json:"idle_seconds"`
Reason string `json:"reason"`
}
Destroy asks for one idle elastic runner to be removed.
type Plan ¶
type Plan struct {
Provisions []Provision `json:"provisions"`
Destroys []Destroy `json:"destroys"`
Refusals []Refusal `json:"refusals"`
}
Plan is the full outcome of one Decide call.
type Provision ¶
type Provision struct {
Arch string `json:"arch"`
Size string `json:"size"`
Region string `json:"region"`
AccountID string `json:"account_id"`
Kind string `json:"kind"`
Apps []string `json:"apps"`
MonthlyUSD float64 `json:"monthly_usd"`
}
Provision asks for one new runner.
type Refusal ¶
type Refusal struct {
Arch string `json:"arch"`
Code string `json:"code"`
Reason string `json:"reason"`
}
Refusal says why a demand got no runner.
type Runner ¶
type Runner struct {
ID string `json:"id"`
Arch string `json:"arch"`
Elastic bool `json:"elastic"`
Cordoned bool `json:"cordoned"`
ActiveBuilds int `json:"active_builds"`
// IdleSince is the last build end, or the enroll time when it never built.
IdleSince time.Time `json:"idle_since"`
MonthlyUSD float64 `json:"monthly_usd"`
}
Runner is one build runner as the planner sees it.