demand

package
v0.0.0-...-33bb219 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 7 Imported by: 12

Documentation

Overview

Package demand defines Tasks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

type Task struct {
	// Name
	Name string

	// Scheduler
	Demand    int
	Requested int
	Running   int

	// Container config info
	FamilyName      string
	Image           string
	Command         string
	PublishAllPorts bool
	NetworkMode     string
	Env             []string

	// Scaling config
	IsScalable    bool
	Priority      int
	MaxDelta      int
	MinContainers int
	MaxContainers int

	// The target we're aiming for
	Target target.Target

	// Measurements
	Metric metric.Metric

	// Scaling calculation of the ideal number of containers we'd have if there were no other tasks
	IdealContainers int
}

Task describes an app (or you might want to call it a service, or a container). It has all the info for starting / stopping an instance of a task, scaling config & params, the target and metric we use for this task, and state information about the number of tasks.

func (*Task) CanScaleDown

func (t *Task) CanScaleDown() int

CanScaleDown returns the number we could scale down by

func (*Task) IsRemainder

func (t *Task) IsRemainder() bool

IsRemainder returns true if this task uses up unused resources

func (*Task) ScaleDownCount

func (t *Task) ScaleDownCount() (delta int)

ScaleDownCount tells us how many we should scale down by Call this after IdealContainers has been updated

func (*Task) ScaleUpCount

func (t *Task) ScaleUpCount() (delta int)

ScaleUpCount tells us how many containers to scale up by Call this after IdealContainers has been updated

type Tasks

type Tasks struct {
	Tasks         []*Task
	MaxContainers int
	sync.RWMutex
}

Tasks is a list of tasks, with a global lock. Global config about tasks can go here too.

func (*Tasks) CheckCapacity

func (tasks *Tasks) CheckCapacity() int

CheckCapacity returns number of containers we have space for

func (*Tasks) Exited

func (tasks *Tasks) Exited() (done bool)

Exited returns whether tasks have all drained down to 0 so we can quit microscaling

func (*Tasks) GetTask

func (tasks *Tasks) GetTask(name string) (task *Task, err error)

GetTask returns the task identified by name

func (*Tasks) PrioritySort

func (tasks *Tasks) PrioritySort(reverse bool)

PrioritySort reorders tasks in priority order (or reverse priority order)

Jump to

Keyboard shortcuts

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