Help us shape the future of Go! Take the 2026 Go Developer Survey

capacity

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package capacity is what GET /capacity shows: each runtime's room, beside what Pando has committed to apps on it (R-242, R-243, R-245).

The runtime's half is a reading taken in the background and shared by every request (issue #72). Sampling what is in use means reading stats for every running container — about a second, and work in proportion to how many apps there are — and doing it on every view meant an install with twenty thousand apps sampled twenty thousand containers each time somebody opened the screen. So a reading is taken every Interval while somebody is looking, and each response says when its reading was taken.

The committed half is not part of the reading. It is read on every request from Allocations, the same sum the planner's capacity check reads at plan time, which is cheap (migration 60) — so what this screen calls committed and what a refused deploy says agree to the moment, never to the last reading.

Index

Constants

View Source
const (
	DefaultInterval = 30 * time.Second
	DefaultIdle     = 5 * time.Minute
)

Defaults [P]. Thirty seconds is old enough to spare the runtimes and young enough that a screen left open shows a host filling up while it does. A screen nobody has asked for in five minutes stops being refreshed.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reading

type Reading struct {
	AdapterRef string

	// Reachable is false when the runtime did not answer; nothing else in
	// the reading is then known.
	Reachable bool
	Capacity  api.Capacity

	// InUse is present only from a runtime that reports usage (R-245) and
	// answered for it.
	InUse *api.InUse
}

Reading is one runtime's answer, as of a snapshot.

type Runtime

type Runtime struct {
	Reading
	Allocated planner.Allocation
}

Runtime is one runtime's entry in a view: its reading, and what is committed on it now.

type Snapshot

type Snapshot struct {
	TakenAt  time.Time
	Readings []Reading
}

Snapshot is every runtime's reading, taken together.

type Snapshots

type Snapshots struct {
	Registry    *api.Registry
	Allocations planner.Allocations
	Clock       clock.Clock
	Logger      *zap.Logger

	// Interval is how often a reading is taken while somebody is looking,
	// and Idle how long after the last request the readings stop. Defaults
	// when zero.
	Interval time.Duration
	Idle     time.Duration
	// contains filtered or unexported fields
}

Snapshots keeps the latest reading of every runtime. The zero value is not usable: Registry and Allocations are required.

func (*Snapshots) Run

func (s *Snapshots) Run(ctx context.Context)

Run takes a reading every Interval while somebody has asked within Idle, until ctx ends.

func (*Snapshots) View

func (s *Snapshots) View(ctx context.Context) (View, error)

View returns the latest reading with what is committed now.

A request that finds no reading, or one older than Idle — nobody has looked for a while, so nothing kept it fresh — waits for a new one, shared with any other request waiting at the same moment.

type View

type View struct {
	// TakenAt is when the runtimes were read, and Interval how often they
	// are read again while somebody is looking. Allocated is as of the
	// request.
	TakenAt  time.Time
	Interval time.Duration
	Runtimes []Runtime
}

View is what GET /capacity shows.

Jump to

Keyboard shortcuts

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