algorithm

package
v0.0.0-...-c00f92a Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Algorithms = map[string]AlgorithmInterface{}

	// Operator Actions
	TerminateAction        = "terminate"
	CompleteAction         = "complete"
	ScaleAction            = "scale"
	ResetCounterAction     = "resetCounter"
	JobsMatrixUpdateAction = "updateJobsMatrix"

	// Queue actions
	SubmitAction  = "submit"
	JobInfoAction = "jobinfo"
)

A lookup of registered algorithms by name

Functions

func List

func List() map[string]AlgorithmInterface

List returns known backends

func Register

func Register(algorithm AlgorithmInterface)

Register a new backend by name

Types

type AlgorithmDecision

type AlgorithmDecision struct {

	// Scale up or down by size (e.g., negative value is size)
	Scale int32 `json:"scale"`

	// Send payload back to gRPC sidecar service
	Payload string `json:"payload"`

	// Action to ask the queue or operator to take
	Action string `json:"action"`

	// Jobs matrix
	Jobs []api.Job
}

An algorithm must return a decision for the operator to take

func (*AlgorithmDecision) IsQueueRequest

func (a *AlgorithmDecision) IsQueueRequest() bool

IsQueueRequest determines if the action should be sent to the queue Right now this is only the submit action

func (*AlgorithmDecision) ToJson

func (e *AlgorithmDecision) ToJson() (string, error)

ToJson serializes to json

type AlgorithmInterface

type AlgorithmInterface interface {
	Name() string
	Description() string

	// Let's assume an algorithm can make a decision based on the gRPC payload
	MakeDecision(*api.Ensemble, *api.Member, interface{}, []api.Job) (AlgorithmDecision, error)
	Validate(AlgorithmOptions) bool

	// Check that an algorithm is supported for a member type, and the member is valid
	Check(AlgorithmOptions, *api.Member) error
}

An algorithm interface determines behavior for scaling and termination. Each algorithm can interact with the member gRPC client to:

get a current state or other metadata required to make a decision
directly influence the queue and submission (advanced)

func Get

func Get(name string) (AlgorithmInterface, error)

Get a backend by name

func GetOrFail

func GetOrFail(name string) AlgorithmInterface

GetOrFail ensures we can find the entry

type AlgorithmOptions

type AlgorithmOptions map[string]intstr.IntOrString

AlgorithmOptions allow packaging named values of different types This is an alternative to using interfaces.

Jump to

Keyboard shortcuts

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