strategy

package
v0.0.0-...-b1a0dc5 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterEvaluatorConstructor

func RegisterEvaluatorConstructor(strat conf.Strategy, con EvaluatorConstructor) error

RegisterEvaluatorConstructor registers an EvaluatorConstructor for use with a given name. This can then be referenced from a conf.Criteria.Strategy for use.

func SortCreationTimestampAsc

func SortCreationTimestampAsc(pods []v1.Pod) []v1.Pod

Types

type Evaluator

type Evaluator func([]v1.Pod) []v1.Pod

Evaluator is the logic kernel used to evaluate kicking a set of pods

func ApplyFilter

func ApplyFilter(filter Filter) Evaluator

ApplyFilter returns a eval that filters a set of v1.Pods and returns a new slice of pods that match the filter.

func CoolDown

func CoolDown(cd time.Duration, eval Evaluator) Evaluator

func EvaluatorSeive

func EvaluatorSeive(evaluators ...Evaluator) Evaluator

func FilterPodSet

func FilterPodSet(filterSet []v1.Pod) Evaluator

func Limit

func Limit(limit int64) Evaluator

func OlderThan

func OlderThan(maxAge time.Duration) Evaluator

func Spread

func Spread(maxAge time.Duration, eval Evaluator) Evaluator

func SpreadFast

func SpreadFast(maxAge time.Duration, limit int64, eval Evaluator) Evaluator

type EvaluatorConstructor

type EvaluatorConstructor func(conf.Criteria) Evaluator

EvaluatorConstructor defines a constructor function for an Evaluator

func RetrieveEvaluatorConstructor

func RetrieveEvaluatorConstructor(strat conf.Strategy) (EvaluatorConstructor, error)

RetrieveEvaluatorConstructor retrieves a registered EvaluatorConstructor.

type Filter

type Filter func(v1.Pod) bool

Filter provides the core concept of a simple set of functional filters to be used as a convenience for defining your own strategies

func And

func And(filters ...Filter) Filter

And groups a set of filters into a single filter where all grouped filters must pass for it to pass. This takes advantage of early exit so ensure you place your least likely to match values in front to optimize the filter.

func NamePrefixFilter

func NamePrefixFilter(prefix string) Filter

NamePrefixFilter matches when the passed v1.Pod.Name has the passed prefix

func NameSpaceFilter

func NameSpaceFilter(namespace string) Filter

NameSpaceFilter matches when the passed v1.Pod.Namespace is equivalent to the passed namespace

func Not

func Not(filter Filter) Filter

Not inverts the result of the passed Filter

func Or

func Or(filters ...Filter) Filter

Or groups a set of filters into a single filter where at least one grouped filter must pass for it to pass. This takes advantage of early exit so ensure you place your most likely to match values in front to optimize the filter.

func StatusFilter

func StatusFilter(status v1.PodPhase) Filter

StatusFilter matches when the passed v1.Pod.Status.Phase is equivalent to the passed Status

type Strategy

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

Strategy is an object used to statefully evaluate a set of v1.Pod for to be kicked

func NewGroup

func NewGroup(cs []conf.Criteria) ([]*Strategy, error)

NewGroup is a convenience function to create a group of strategies in a single call

func NewStrategy

func NewStrategy(c conf.Criteria) (*Strategy, error)

NewStrategy builds and returns a new Strategy for the provided conf.Criteria, returning an error if unable to do so.

func (*Strategy) Criteria

func (s *Strategy) Criteria() conf.Criteria

Criteria return the conf.Criteria used to create this Strategy

func (*Strategy) Evaluate

func (s *Strategy) Evaluate(pods []v1.Pod) []v1.Pod

Evaluate performs the evaluation defined by the conf.Criteria used to create this Strategy

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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