scheduler

package
v0.0.0-...-58c0a64 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAlgorithm error for invalid algorithm input
	ErrInvalidAlgorithm = fmt.Errorf("invalid Algorithm")
)

Functions

This section is empty.

Types

type Algorithm

type Algorithm string

Algorithm name of the algo for scheduling

const (
	// Random Algo type
	Random Algorithm = "Random"

	// LoadBalance algo type
	LoadBalance Algorithm = "LoadBalance"
)

type IAlgoImpl

type IAlgoImpl interface {
	// GetNode method returns the selected node for scheduling
	GetNode(nodebindings []*nodebinding.Model, nodes map[string]*node.Model) (*node.Model, error)
}

IAlgoImpl defines interface for scheduling algorithm implementations

func GetAlgorithmImpl

func GetAlgorithmImpl(algorithm Algorithm) (IAlgoImpl, error)

GetAlgorithmImpl is a factory method which returns the required impl of the algorithm

type IScheduler

type IScheduler interface {
	// Schedule implemented by Scheduler based on current subscription and current load on nodes
	Schedule(*subscription.Model, int, []*nodebinding.Model, map[string]*node.Model) (*nodebinding.Model, error)
}

IScheduler is the interface implemented by Schedulers

func New

func New(algo Algorithm) (IScheduler, error)

New returns a new instance of scheduler

type LoadBalanceAlgoImpl

type LoadBalanceAlgoImpl struct {
}

LoadBalanceAlgoImpl implements load based scheduler algorithm

func (*LoadBalanceAlgoImpl) GetNode

func (algo *LoadBalanceAlgoImpl) GetNode(nodebindings []*nodebinding.Model, nodes map[string]*node.Model) (*node.Model, error)

GetNode method returns the selected node for scheduling based on current load

type NodeCount

type NodeCount struct {
	Key   string
	Count int
}

NodeCount holds counts of the scheduled subscription on a node

type NodeCountList

type NodeCountList []NodeCount

NodeCountList represents array of NodeCount

func (NodeCountList) Len

func (p NodeCountList) Len() int

func (NodeCountList) Less

func (p NodeCountList) Less(i, j int) bool

func (NodeCountList) Swap

func (p NodeCountList) Swap(i, j int)

type RandomAlgoImpl

type RandomAlgoImpl struct {
}

RandomAlgoImpl implements a random scheduling algorithm

func (*RandomAlgoImpl) GetNode

func (algo *RandomAlgoImpl) GetNode(nodebindings []*nodebinding.Model, nodes map[string]*node.Model) (*node.Model, error)

GetNode method returns the selected node for scheduling selecting one randomly

type Scheduler

type Scheduler struct {
	Algorithm Algorithm
	// contains filtered or unexported fields
}

Scheduler struct for subsciption scheduling on worker nodes

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(sub *subscription.Model, partition int, nbs []*nodebinding.Model, nodes map[string]*node.Model) (*nodebinding.Model, error)

Schedule schedules a subsciption on a node and returns a nodebinding model

Jump to

Keyboard shortcuts

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