autoscale

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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildWorkload

func BuildWorkload(deployment *models.Deployment, composeContent string, replicas int, proxyNetwork string) (orchestrator.Workload, error)

func Reconcile

func Reconcile(policy Policy, state State, input Input) (State, Decision)

func ValidatePolicy

func ValidatePolicy(policy Policy) error

Types

type Action

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

type ActionExecutor

type ActionExecutor interface {
	Execute(context.Context, string, routing.Route, Decision) (Execution, error)
}

type Activation

type Activation struct {
	Workload orchestrator.Status `json:"workload"`
	Route    routing.Route       `json:"route"`
}

type Activator

type Activator struct {
	// contains filtered or unexported fields
}

func NewActivator

func NewActivator(orchestratorProvider orchestrator.Provider, routingProvider routing.Provider, stopper ServiceStopper) *Activator

func (*Activator) Activate

func (a *Activator) Activate(ctx context.Context, deployment, service string, workload orchestrator.Workload, route routing.Route) (Activation, error)

func (*Activator) ActivateDurably

func (a *Activator) ActivateDurably(ctx context.Context, deployment, service string, workload orchestrator.Workload, route routing.Route, persist func(Activation) error) (Activation, error)

type ActiveStore

type ActiveStore interface {
	PolicyStore
	ActiveStates() (map[string]State, error)
}

type Compatibility

type Compatibility struct {
	Compatible bool                  `json:"compatible"`
	Service    string                `json:"service,omitempty"`
	Image      string                `json:"image,omitempty"`
	Blockers   []string              `json:"blockers"`
	Warnings   []string              `json:"warnings"`
	Services   []string              `json:"services"`
	Workload   *models.ScalingConfig `json:"workload,omitempty"`
}

func AssessCompatibility

func AssessCompatibility(deployment *models.Deployment, composeContent string) Compatibility

type Decision

type Decision struct {
	Action    Action                 `json:"action"`
	Replicas  int                    `json:"replicas,omitempty"`
	Resources orchestrator.Resources `json:"resources,omitempty"`
	Reason    string                 `json:"reason"`
}

type EventPublisher

type EventPublisher interface {
	Publish(events.Event) (events.IngestResult, error)
}

type Execution

type Execution struct {
	Decision Decision            `json:"decision"`
	Status   orchestrator.Status `json:"status"`
	Route    routing.Route       `json:"route,omitempty"`
	Pending  bool                `json:"pending"`
}

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(orchestrator orchestrator.Provider, routing routing.Provider) *Executor

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, workloadID string, route routing.Route, decision Decision) (Execution, error)

type Input

type Input struct {
	Now               time.Time
	Replicas          int
	CPUPercent        float64
	MemoryPercent     float64
	Diagnosis         capacity.Diagnosis
	FleetOffer        capacity.Offer
	RequiresFleet     bool
	CurrentResources  orchestrator.Resources
	SuggestedResource orchestrator.Resources
}

type Policy

type Policy struct {
	Enabled            bool          `json:"enabled"`
	MinReplicas        int           `json:"min_replicas"`
	MaxReplicas        int           `json:"max_replicas"`
	ScaleUpPercent     float64       `json:"scale_up_percent"`
	ScaleDownPercent   float64       `json:"scale_down_percent"`
	ScaleUpWindows     int           `json:"scale_up_windows"`
	ScaleDownWindows   int           `json:"scale_down_windows"`
	Cooldown           time.Duration `json:"cooldown"`
	AllowFleetCapacity bool          `json:"allow_fleet_capacity"`
}

func DefaultPolicy

func DefaultPolicy() Policy

type PolicyStore

type PolicyStore interface {
	Policy(string) (Policy, error)
	State(string) (State, error)
	SetState(string, State) error
}

type ReconcileResult

type ReconcileResult struct {
	State     State      `json:"state"`
	Decision  Decision   `json:"decision"`
	Execution *Execution `json:"execution,omitempty"`
}

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(store PolicyStore, executor ActionExecutor, publisher EventPublisher, node string) *Runner

func (*Runner) Reconcile

func (r *Runner) Reconcile(ctx context.Context, deployment string, input Input, route routing.Route) (ReconcileResult, error)

type RuntimeFactory

type RuntimeFactory interface {
	Build(context.Context, string, State) (RuntimeSession, error)
}

type RuntimeSession

type RuntimeSession struct {
	Input    Input
	Executor ActionExecutor
	Close    func() error
}

type ServiceStopper

type ServiceStopper interface {
	StopService(string, string) (string, error)
}

type ServiceStopperFunc

type ServiceStopperFunc func(string, string) (string, error)

func (ServiceStopperFunc) StopService

func (f ServiceStopperFunc) StopService(deployment, service string) (string, error)

type State

type State struct {
	HighWindows int                     `json:"high_windows"`
	LowWindows  int                     `json:"low_windows"`
	LastAction  time.Time               `json:"last_action,omitempty"`
	Active      bool                    `json:"active"`
	Provider    orchestrator.ProviderID `json:"provider,omitempty"`
	Service     string                  `json:"service,omitempty"`
	Replicas    int                     `json:"replicas,omitempty"`
	Route       routing.Route           `json:"route,omitempty"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(deploymentsPath string) (*Store, error)

func (*Store) ActiveStates

func (s *Store) ActiveStates() (map[string]State, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) Policy

func (s *Store) Policy(deployment string) (Policy, error)

func (*Store) SetPolicy

func (s *Store) SetPolicy(deployment string, policy Policy) error

func (*Store) SetState

func (s *Store) SetState(deployment string, state State) error

func (*Store) State

func (s *Store) State(deployment string) (State, error)

type Supervisor

type Supervisor struct {
	// contains filtered or unexported fields
}

func NewSupervisor

func NewSupervisor(store ActiveStore, factory RuntimeFactory, publisher EventPublisher, node string, interval time.Duration) *Supervisor

func (*Supervisor) Run

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

func (*Supervisor) Tick

func (s *Supervisor) Tick(ctx context.Context) error

Jump to

Keyboard shortcuts

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