replay

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 10 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

The idle window advice. Ports manager packages/fleet/src/idle.ts (idleWindowAdvice, intersect).

The idle window replay: a workload's requests per minute replayed against idle windows with the router's rules. Ports manager packages/fleet/src/idle.ts (IDLE_WINDOWS, windowsFor, checkMinutesOf, replayIdle, recommendWindow).

Index

Constants

This section is empty.

Variables

View Source
var IdleWindows = []int{5, 10, 15, 20, 30, 45, 60, 90, 120}

IdleWindows are the nine windows tried, in minutes.

Functions

func CheckMinutes

func CheckMinutes(schedule *string) int

CheckMinutes returns a router's check period from its schedule: rate(n minutes) or rate(n hours), 5 minutes otherwise (nil schedule included).

func Recommend

func Recommend(rows []WakeRow) int

Recommend returns the shortest of the nine windows whose wakes are at most wakes(longest) + 10% of what the longest avoids against the shortest; the same wakes everywhere (no request, or no gap), the shortest, which saves the most at no cost.

func Windows

func Windows(current int) []int

Windows returns the windows tried: the nine, and the current one when it is not among them.

Types

type Actual

type Actual struct {
	Wakes         int  `json:"wakes"`
	ReplayedWakes int  `json:"replayedWakes"`
	Noisy         bool `json:"noisy"`
}

Actual compares the real wakes with the replay's.

type Input

type Input struct {
	Ctx              context.Context
	Requests         RequestMinutes
	Current          int
	CheckMinutes     int
	WakeMs           *float64
	StartAsleep      bool
	ActualWakes      int
	ActualFrom       *string
	Stopped          []stopped.Item
	Hourly           func(context.Context, stopped.Item) (*float64, error)
	Baseline         prices.Baseline
	WakerTargetGroup bool
	Now              time.Time
	Running          []Period
}

Input is idleWindowAdvice's argument. WakeMs, ActualFrom and Stopped are nil when Node's are null; Running nil is a backend running all the time. Ctx defaults to context.Background().

type Period

type Period struct {
	From string `json:"from"`
	To   string `json:"to"`
}

Period is a time span, both ends as ISO dates.

type ReplayInput

type ReplayInput struct {
	Requests     RequestMinutes `json:"requests"`
	Windows      []int          `json:"windows"`
	CheckMinutes int            `json:"checkMinutes"`
	WakeSeconds  float64        `json:"wakeSeconds"`
	StartAsleep  bool           `json:"startAsleep"`
}

ReplayInput is replayIdle's argument.

type ReplayedWindow

type ReplayedWindow struct {
	Minutes int      `json:"minutes"`
	Asleep  []Period `json:"asleep"`
	Wakes   int      `json:"wakes"`
	WokeAt  []string `json:"wokeAt"`
}

ReplayedWindow is one window's replay.

func Replay

func Replay(in ReplayInput) ([]ReplayedWindow, error)

Replay replays each window over the requests.

type RequestMinutes

type RequestMinutes struct {
	From    string   `json:"from"`
	To      string   `json:"to"`
	Minutes [][2]int `json:"minutes"`
}

RequestMinutes are the minutes with requests, as offsets from From with their counts.

type Result

type Result struct {
	ComputedAt       string   `json:"computedAt"`
	From             string   `json:"from"`
	To               string   `json:"to"`
	Current          int      `json:"current"`
	Recommended      int      `json:"recommended"`
	CheckMinutes     int      `json:"checkMinutes"`
	WakeSeconds      *float64 `json:"wakeSeconds"`
	Priced           bool     `json:"priced"`
	Windows          []Row    `json:"windows"`
	Actual           Actual   `json:"actual"`
	WakerTargetGroup bool     `json:"wakerTargetGroup"`
}

Result is the Node IdleWindowAdvice.

func Advice

func Advice(in Input) (Result, error)

Advice is the advice of a workload.

type Row

type Row struct {
	Minutes           int      `json:"minutes"`
	AsleepHours       float64  `json:"asleepHours"`
	USDMonth          *float64 `json:"usdMonth"`
	WakesPerDay       float64  `json:"wakesPerDay"`
	WaitSecondsPerDay *float64 `json:"waitSecondsPerDay"`
}

Row is one window's figures.

type WakeRow

type WakeRow struct {
	Minutes int     `json:"minutes"`
	Wakes   float64 `json:"wakes"`
}

WakeRow is a window with its wakes.

Jump to

Keyboard shortcuts

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