width

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const LogKey = "width:log"

LogKey is the per-tick sample stream the fold integrates.

Variables

This section is empty.

Functions

func DesiredKey

func DesiredKey(friend string) string

DesiredKey returns the key for friend's declared slots hash (nova-config apply writes it; the slots field is the width the friend asked for).

func FillstateKey

func FillstateKey(friend string) string

FillstateKey returns the key for friend's fillstate hash.

func FleetLine

func FleetLine(working, slots, deficit int) string

FleetLine formats the WIDTH fleet line.

func UnmeasuredLine

func UnmeasuredLine(friend, slots string) string

UnmeasuredLine is the WIDTH row for a friend that has declared slots in friend:<f>:desired but no fillstate yet: slots prints the declared value (or ? when it is not an integer) and every measured field prints ?, since stale or missing prints ?, never a guess (#3615).

Types

type Fillstate

type Fillstate struct {
	Friend        string
	Slots         int
	Leased        int
	Working       int
	Deficit       int
	Eligible      int
	IdleNoReady   int
	IdleDeps      int
	IdleInput     int
	IdleUnfilled  int
	Peak          int
	PeakAt        int64
	UnfilledSince int64
	At            int64
}

Fillstate represents friend:<f>:fillstate data.

func ParseFillstate

func ParseFillstate(friend string, m map[string]string) Fillstate

ParseFillstate parses a Redis HGetAll map into a Fillstate struct.

func ReadFillstate

func ReadFillstate(ctx context.Context, st *store.Store, friend string) (Fillstate, bool, error)

ReadFillstate reads friend:<f>:fillstate for one friend.

func (Fillstate) IdleString

func (fs Fillstate) IdleString() string

IdleString formats the typed idle counts into <reason>:<n>,...

func (Fillstate) Line

func (fs Fillstate) Line(nowMs int64) string

Line returns the WIDTH row string. If stale (> 3s old), prints "?" for all fields.

type Policy

type Policy struct {
	RebalanceTicks int
	Readers        []string
	Builders       []string
	Coordinator    string
}

Policy is what one width tick reads from config.

type Row

type Row struct {
	Fillstate  Fillstate
	Measured   bool   // friend:<f>:fillstate exists
	Declared   bool   // friend:<f>:desired exists
	DesiredRaw string // friend:<f>:desired slots, as stored
}

Row is one friend's WIDTH row as read in one pipeline: the fillstate when there is one, else the declared slots from friend:<f>:desired.

func ReadRows

func ReadRows(ctx context.Context, st *store.Store, friends []string) ([]Row, error)

ReadRows reads fillstate and desired for each friend in one pipeline.

func (Row) DesiredSlots

func (r Row) DesiredSlots() int

DesiredSlots is the declared slots as an integer (0 when absent or not one).

func (Row) Line

func (r Row) Line(nowMs int64) string

Line returns the row's WIDTH line: the fillstate line when measured, the unmeasured line when only declared. Callers check Measured || Declared.

Jump to

Keyboard shortcuts

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