capacity

package
v0.4.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string
const (
	ActionNone           Action = "none"
	ActionIncreaseMemory Action = "increase_memory"
	ActionIncreaseCPU    Action = "increase_cpu"
	ActionAddReplica     Action = "add_replica"
	ActionNotify         Action = "notify"
)

type Container

type Container struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	CPUPercent  float64 `json:"cpu_percent"`
	CPULimit    float64 `json:"cpu_limit"`
	MemoryUsage uint64  `json:"memory_usage"`
	MemoryLimit uint64  `json:"memory_limit"`
}

type Diagnosis

type Diagnosis struct {
	Pressure         Pressure `json:"pressure"`
	Resource         string   `json:"resource,omitempty"`
	Action           Action   `json:"action"`
	CurrentLimit     float64  `json:"current_limit,omitempty"`
	RecommendedLimit float64  `json:"recommended_limit,omitempty"`
	Reason           string   `json:"reason"`
}

func Diagnose

func Diagnose(host Host, container Container, policy Policy) Diagnosis

type Host

type Host struct {
	CPUCores        float64 `json:"cpu_cores"`
	CPUUsagePercent float64 `json:"cpu_usage_percent"`
	MemoryTotal     uint64  `json:"memory_total"`
	MemoryAvailable uint64  `json:"memory_available"`
}

type Offer

type Offer struct {
	Enabled         bool    `json:"enabled"`
	AvailableCPU    float64 `json:"available_cpu"`
	AvailableMemory uint64  `json:"available_memory"`
	Reason          string  `json:"reason"`
}

func FleetOffer

func FleetOffer(host Host, policy Policy, enabled bool) Offer

type Policy

type Policy struct {
	AllocationThresholdPercent float64 `json:"allocation_threshold_percent"`
	HostThresholdPercent       float64 `json:"host_threshold_percent"`
	HostMemoryReserve          uint64  `json:"host_memory_reserve"`
	HostCPUReserve             float64 `json:"host_cpu_reserve"`
	MemoryStepPercent          float64 `json:"memory_step_percent"`
	CPUStepPercent             float64 `json:"cpu_step_percent"`
	MaxMemory                  uint64  `json:"max_memory"`
	MaxCPU                     float64 `json:"max_cpu"`
	AllowVertical              bool    `json:"allow_vertical"`
	AllowHorizontal            bool    `json:"allow_horizontal"`
}

func DefaultPolicy

func DefaultPolicy() Policy

func PolicyFromConfig

func PolicyFromConfig(cfg config.CapacityConfig) Policy

type Pressure

type Pressure string
const (
	PressureNone       Pressure = "none"
	PressureAllocation Pressure = "allocation"
	PressureHost       Pressure = "host"
)

Jump to

Keyboard shortcuts

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