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 ¶
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 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 ¶
Run takes a reading every Interval while somebody has asked within Idle, until ctx ends.