strategy

package
v0.0.0-...-1c5d739 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchStrategy = errors.New("no such scheduler strategy")
)

Functions

func ScoreHosts

func ScoreHosts(service ServiceConfig, hosts []Host) ([]*ScoredHost, []*ScoredHost)

ScoreHosts returns two arrays of hosts. The first lists hosts that have enough resources to handle the service, sorted in order of combined free resources. The second lists hosts that do not have enough resources to handle the service, sorted in order of percentage memory used were the service deployed to the host.

Types

type BalanceStrategy

type BalanceStrategy struct{}

func (*BalanceStrategy) Name

func (s *BalanceStrategy) Name() string

func (*BalanceStrategy) SelectHost

func (s *BalanceStrategy) SelectHost(service ServiceConfig, hosts []Host) (Host, error)

type Host

type Host interface {
	HostID() string
	TotalCores() int
	TotalMemory() uint64
	RunningServices() []ServiceConfig
}

type PackStrategy

type PackStrategy struct{}

func (*PackStrategy) Name

func (s *PackStrategy) Name() string

func (*PackStrategy) SelectHost

func (s *PackStrategy) SelectHost(service ServiceConfig, hosts []Host) (Host, error)

type PreferSeparateStrategy

type PreferSeparateStrategy struct{}

func (*PreferSeparateStrategy) Name

func (s *PreferSeparateStrategy) Name() string

func (*PreferSeparateStrategy) SelectHost

func (s *PreferSeparateStrategy) SelectHost(service ServiceConfig, hosts []Host) (Host, error)

type RequireSeparateStrategy

type RequireSeparateStrategy struct{}

func (*RequireSeparateStrategy) Name

func (s *RequireSeparateStrategy) Name() string

func (*RequireSeparateStrategy) SelectHost

func (s *RequireSeparateStrategy) SelectHost(service ServiceConfig, hosts []Host) (Host, error)

type ScoredHost

type ScoredHost struct {
	Host         Host
	Score        int
	NumInstances int
}

type ServiceConfig

type ServiceConfig interface {
	GetServiceID() string
	RequestedCorePercent() int
	RequestedMemoryBytes() uint64
	HostPolicy() servicedefinition.HostPolicy
}

type Strategy

type Strategy interface {
	// The name of this strategy
	Name() string
	// Chooses the best host for svc to run on
	SelectHost(svc ServiceConfig, hosts []Host) (Host, error)
}

func Get

func Get(name string) (Strategy, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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