Documentation ¶
Overview ¶
Package spotadvisor provides an interface for utilizing spot instance interrupt rate data and savings data from AWS.
Index ¶
- Constants
- type AwsRegion
- type InstanceType
- type InterruptProbability
- type InterruptRange
- type OsType
- type SimpleLogger
- type SpotAdvisor
- func (sa *SpotAdvisor) FilterByMaxInterruptProbability(ot OsType, ar AwsRegion, candidates []string, ip InterruptProbability) (filtered []string, err error)
- func (sa *SpotAdvisor) GetInstancesWithMaxInterruptProbability(ot OsType, region AwsRegion, ip InterruptProbability) (map[string]bool, error)
- func (sa *SpotAdvisor) GetInterruptRange(ot OsType, ar AwsRegion, it InstanceType) (InterruptRange, error)
- func (sa *SpotAdvisor) GetMaxInterruptProbability(ot OsType, ar AwsRegion, it InstanceType) (InterruptProbability, error)
Constants ¶
const ( Linux = OsType("Linux") Windows = OsType("Windows") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InstanceType ¶
type InstanceType string
InstanceType is an EC2 instance type name like "r5a.large".
type InterruptProbability ¶
type InterruptProbability int
InterruptProbability is an upper bound used to indicate multiple interrupt ranges; it should only be used via the pre-defined constants in this package.
const ( LessThanFivePct InterruptProbability = iota LessThanTenPct LessThanFifteenPct LessThanTwentyPct Any )
These need to be in their own const block to ensure iota starts at 0.
func (InterruptProbability) String ¶
func (ir InterruptProbability) String() string
type InterruptRange ¶
type InterruptRange int
InterruptRange is the AWS defined interrupt range for an instance type; it should only be used via the pre-defined constants in this package.
const ( ZeroToFivePct InterruptRange = iota FiveToTenPct TenToFifteenPct FifteenToTwentyPct GreaterThanTwentyPct )
These need to be in their own const block to ensure iota starts at 0.
func (InterruptRange) String ¶
func (ir InterruptRange) String() string
type OsType ¶
type OsType string
OsType should only be used via the pre-defined constants in this package.
type SimpleLogger ¶
type SimpleLogger interface {
Printf(string, ...interface{})
}
SimpleLogger is a bare-bones logger interface which allows many logger implementations to be used with SpotAdvisor. The default Go log.Logger and grailbio/base/log.Logger implement this interface.
type SpotAdvisor ¶
type SpotAdvisor struct {
// contains filtered or unexported fields
}
SpotAdvisor provides an interface for utilizing spot instance interrupt rate data and savings data from AWS.
func NewSpotAdvisor ¶
func NewSpotAdvisor(log SimpleLogger, done <-chan struct{}) (*SpotAdvisor, error)
NewSpotAdvisor initializes and returns a SpotAdvisor instance. If initialization fails, a nil SpotAdvisor is returned with an error. The underlying data is asynchronously updated, until the done channel is closed. Errors during updates are non-fatal and will not prevent future updates.
func (*SpotAdvisor) FilterByMaxInterruptProbability ¶
func (sa *SpotAdvisor) FilterByMaxInterruptProbability(ot OsType, ar AwsRegion, candidates []string, ip InterruptProbability) (filtered []string, err error)
FilterByMaxInterruptProbability returns a subset of the input candidates by removing instance types which have a probability of interruption greater than ip.
func (*SpotAdvisor) GetInstancesWithMaxInterruptProbability ¶
func (sa *SpotAdvisor) GetInstancesWithMaxInterruptProbability(ot OsType, region AwsRegion, ip InterruptProbability) (map[string]bool, error)
GetInstancesWithMaxInterruptProbability returns the set of spot instance types with an interrupt probability less than or equal to ip, with the given OS and region.
func (*SpotAdvisor) GetInterruptRange ¶
func (sa *SpotAdvisor) GetInterruptRange(ot OsType, ar AwsRegion, it InstanceType) (InterruptRange, error)
GetInterruptRange returns the interrupt range for the instance type with the given OS and region.
func (*SpotAdvisor) GetMaxInterruptProbability ¶
func (sa *SpotAdvisor) GetMaxInterruptProbability(ot OsType, ar AwsRegion, it InstanceType) (InterruptProbability, error)
GetMaxInterruptProbability is a helper method to easily get the max interrupt probability of an instance type (i.e. the upper bound of the interrupt range for that instance type).