Documentation ¶
Index ¶
- func Less(tuple1, tuple2 []float64) bool
- type Assignment
- type Entities
- type Entity
- type Group
- type Ordering
- type RelocationRank
- type Requirement
- type Reservation
- type Reserved
- type ScopeSet
- type Transcript
- func (transcript *Transcript) Add(other *Transcript)
- func (transcript *Transcript) Copy() *Transcript
- func (transcript *Transcript) IncFailed()
- func (transcript *Transcript) IncPassed()
- func (transcript *Transcript) String() string
- func (transcript *Transcript) Subscript(transcriptable Transcriptable) *Transcript
- type Transcriptable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Assignment ¶
type Assignment struct { // Entity to be placed. Entity *Entity // AssignedGroup the Group that the Entity got assigned to. AssignedGroup *Group // Failed is true if the assignment failed. Failed bool // Transcript holds the placement transcript of the placement of the entity. Transcript *Transcript }
Assignment represents a placement of an entity in a given group or the failure to be able to place the entity in a group that satisfies all requirements of the entity.
func NewAssignment ¶
func NewAssignment(entity *Entity) *Assignment
NewAssignment creates a new empty assignment for the entity.
type Entities ¶
Entities represents a set of entities.
type Entity ¶
type Entity struct { Name string Reservation Reserved Requirement Requirement Ordering Ordering Relations *labels.Bag Metrics *metrics.Set }
Entity represents an task, process or some entity that should run on a group.
type Group ¶
type Group struct { Name string Labels *labels.Bag Metrics *metrics.Set Relations *labels.Bag Entities Entities }
Group represents a host or other physical entity which can contain entities.
type Ordering ¶
type Ordering interface { // Tuple returns a tuple of floats created from the group, scope groups and the entity. Tuple(group *Group, scopeSet *ScopeSet, entity *Entity) []float64 }
Ordering returns a tuple of floats given a group relative to an entity and a scope of groups.
func NameOrdering ¶
func NameOrdering() Ordering
NameOrdering returns a new ordering by the group name.
type RelocationRank ¶
type RelocationRank struct { // Entity to be relocated. Entity *Entity // CurrentGroup the group where the entity is currently placed. CurrentGroup *Group // Rank is a lower bound on the number of groups different from the current group which are better than the current // group. Rank int // Transcript holds the relocation transcript of the relocation rank of the entity. Transcript *Transcript }
RelocationRank contains a rank (number) that represents how many other groups, different than the currently assigned, that are better to place this entity on.
func NewRelocationRank ¶
func NewRelocationRank(entity *Entity, current *Group) *RelocationRank
NewRelocationRank creates a new relocation rank for the entity.
type Requirement ¶
type Requirement interface { // Passed returns true iff group passes the requirement in relation to the given scope. Passed(group *Group, scopeSet *ScopeSet, entity *Entity, transcript *Transcript) bool // The requirement should be transcript-able, so we can get metrics about how many groups pass and fail the // requirement. Transcriptable }
Requirement tells if a given group passes the requirements for a given entity in relation to the given scope.
func FailedRequirement ¶
func FailedRequirement() Requirement
FailedRequirement returns a requirement that never passes.
type Reservation ¶
Reservation stores the reservation of an entity on a group
type ScopeSet ¶
type ScopeSet struct {
// contains filtered or unexported fields
}
ScopeSet contains a set of pre-computed label or relation bags for a given group and scope. The methods label scope and relation scope will return the labels or relations in the scope if they are pre-computed, else they will be computed and stored for the next call.
func NewScopeSet ¶
NewScopeSet creates a new scope set for use in computations that need the label or relation scope of a group.
func (*ScopeSet) CompleteScope ¶
CompleteScope returns the union of all groups that have ever been in scope for any call to LabelScope or RelationScope. Notice that the result will change depending on which calls are made to LabelScope and RelationScope.
func (*ScopeSet) Copy ¶
Copy makes a shallow copy of the scope set where the label bags are the same as in the original.
func (*ScopeSet) LabelScope ¶
LabelScope finds all labels in scope of the given group and caches them for the next call.
func (*ScopeSet) RelationScope ¶
RelationScope finds all relations in scope of the given group and caches them for the next call.
func (*ScopeSet) ScopeGroups ¶
ScopeGroups returns the set of groups, given to a scope set when it is created, which are used as the basis for all scope calculations.
type Transcript ¶
type Transcript struct { Requirement string GroupsPassed int GroupsFailed int Subscripts map[Transcriptable]*Transcript }
Transcript represents a transcript of which requirements passed and failed when evaluating groups for an entity.
func NewTranscript ¶
func NewTranscript(name string) *Transcript
NewTranscript creates a new transcript with a description.
func (*Transcript) Add ¶
func (transcript *Transcript) Add(other *Transcript)
Add will add the other transcript into this transcript by merging them.
func (*Transcript) Copy ¶
func (transcript *Transcript) Copy() *Transcript
Copy creates a deep copy of the transcript and all sub-transcripts, but with a shallow copy of all the transcriptables.
func (*Transcript) IncFailed ¶
func (transcript *Transcript) IncFailed()
IncFailed will increment the number of groups that failed the requirements.
func (*Transcript) IncPassed ¶
func (transcript *Transcript) IncPassed()
IncPassed will increment the number of groups that passed the requirements.
func (*Transcript) String ¶
func (transcript *Transcript) String() string
String will create a human readable representation of the transcript.
func (*Transcript) Subscript ¶
func (transcript *Transcript) Subscript(transcriptable Transcriptable) *Transcript
Subscript will create a sub transcript with the given description if one does not exist.
type Transcriptable ¶
type Transcriptable interface { // String will return a human readable string representation of the transcript-able. String() string // Composite will return true iff the transcript-able is composed of other transcript-ables and a type name describing // the type of transcript-able. Composite() (composite bool, typeName string) }
Transcriptable represents something we can create a transcript for, it is usually a requirement which can be composed of sub-requirements, hence we want a human readable name in the string-method and to know whatever it is composite in the composite-method and the type of composition.
func EmptyTranscript ¶
func EmptyTranscript() Transcriptable
EmptyTranscript returns an empty transcript.