constraints

package
v0.0.0-...-d2b1cdf Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownConstraintType is the error when unknown Constraint.Type
	// enum is processed.
	ErrUnknownConstraintType = errors.New(
		"unknown enum value for Constraint.Type")
	// ErrUnknownLabelCondition is the error when unknown
	// LabelConstraint.Condition enum is processed.
	ErrUnknownLabelCondition = errors.New(
		"unknown enum value for LabelConstraint.Condition")
)

Functions

func IsNonExclusiveConstraint

func IsNonExclusiveConstraint(constraint *task.Constraint) bool

IsNonExclusiveConstraint returns true if all components of the constraint specification do not use a host label constraint for exclusive attribute.

Types

type EvaluateResult

type EvaluateResult int

EvaluateResult is an enum indicating various possible result.

const (
	// EvaluateResultMatch indicates that given constraint fully matched
	// input labelValues.
	EvaluateResultMatch EvaluateResult = iota
	// EvaluateResultMismatch indicates that given constraint mismatched
	// input labelValues.
	EvaluateResultMismatch
	// EvaluateResultNotApplicable indicates that given constraint is not
	// applicable to input values.
	EvaluateResultNotApplicable
)

type Evaluator

type Evaluator interface {
	// Evaluate returns true if given constraint is satisfied on
	// these labelValues.
	Evaluate(
		constraint *task.Constraint,
		labelValues LabelValues,
	) (EvaluateResult, error)
}

Evaluator is the interface to evaluate whether given LabelValueSet satisifies given constraint.

func NewEvaluator

func NewEvaluator(kind task.LabelConstraint_Kind) Evaluator

NewEvaluator return a new instance of evaluator which filters out constraints of different kind.

type LabelValues

type LabelValues map[string]map[string]uint32

LabelValues tracks how many times a value presents for a given label key. First level key is label key, second level key is label value. This is the subject of constraint evaluation process.

func GetHostLabelValues

func GetHostLabelValues(
	hostname string,
	attributes []*mesos.Attribute) LabelValues

GetHostLabelValues returns label counts for a host and its attributes, which can be used to evaluate a constraint. NOTE: `hostname` is added unconditionally, to make sure hostname based constraints can be done regardless of attribute configuration.

func (LabelValues) Merge

func (lv LabelValues) Merge(additionalLV LabelValues)

Merge merges additional label values into current label values. Values of the same label will be merged as well.

Jump to

Keyboard shortcuts

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