Documentation ¶
Index ¶
- Constants
- Variables
- type EC2Pricing
- func (p *EC2Pricing) GetOnDemandInstanceTypeCost(instanceType string) (float64, error)
- func (p *EC2Pricing) GetSpotInstanceTypeNDayAvgCost(instanceType string, availabilityZones []string, days int) (float64, error)
- func (p *EC2Pricing) OnDemandCacheCount() int
- func (p *EC2Pricing) RefreshOnDemandCache() error
- func (p *EC2Pricing) RefreshSpotCache(days int) error
- func (p *EC2Pricing) Save() error
- func (p *EC2Pricing) SpotCacheCount() int
- type EC2PricingIface
- type OnDemandPricing
- type SpotPricing
Constants ¶
const (
ODCacheFileName = "on-demand-pricing-cache.json"
)
const (
SpotCacheFileName = "spot-pricing-cache.gob"
)
Variables ¶
var (
DefaultSpotDaysBack = 30
)
Functions ¶
This section is empty.
Types ¶
type EC2Pricing ¶
type EC2Pricing struct { ODPricing *OnDemandPricing SpotPricing *SpotPricing }
EC2Pricing is the public struct to interface with AWS pricing APIs
func New ¶
func New(sess *session.Session) *EC2Pricing
New creates an instance of instance-selector EC2Pricing
func NewWithCache ¶ added in v2.1.0
func (*EC2Pricing) GetOnDemandInstanceTypeCost ¶ added in v2.1.0
func (p *EC2Pricing) GetOnDemandInstanceTypeCost(instanceType string) (float64, error)
GetOnDemandInstanceTypeCost retrieves the on-demand hourly cost for the specified instance type
func (*EC2Pricing) GetSpotInstanceTypeNDayAvgCost ¶
func (p *EC2Pricing) GetSpotInstanceTypeNDayAvgCost(instanceType string, availabilityZones []string, days int) (float64, error)
GetSpotInstanceTypeNDayAvgCost retrieves the spot price history for a given AZ from the past N days and averages the price Passing an empty list for availabilityZones will retrieve avg cost for all AZs in the current AWSSession's region
func (*EC2Pricing) OnDemandCacheCount ¶ added in v2.1.0
func (p *EC2Pricing) OnDemandCacheCount() int
OnDemandCacheCount returns the number of items in the OD cache
func (*EC2Pricing) RefreshOnDemandCache ¶ added in v2.1.0
func (p *EC2Pricing) RefreshOnDemandCache() error
RefreshOnDemandCache makes a bulk request to the pricing api to retrieve all instance type pricing and stores them in a local cache
func (*EC2Pricing) RefreshSpotCache ¶ added in v2.1.0
func (p *EC2Pricing) RefreshSpotCache(days int) error
RefreshSpotCache makes a bulk request to the ec2 api to retrieve all spot instance type pricing and stores them in a local cache
func (*EC2Pricing) Save ¶ added in v2.1.0
func (p *EC2Pricing) Save() error
func (*EC2Pricing) SpotCacheCount ¶ added in v2.1.0
func (p *EC2Pricing) SpotCacheCount() int
SpotCacheCount returns the number of items in the spot cache
type EC2PricingIface ¶
type EC2PricingIface interface { GetOnDemandInstanceTypeCost(instanceType string) (float64, error) GetSpotInstanceTypeNDayAvgCost(instanceType string, availabilityZones []string, days int) (float64, error) RefreshOnDemandCache() error RefreshSpotCache(days int) error OnDemandCacheCount() int SpotCacheCount() int Save() error }
EC2PricingIface is the EC2Pricing interface mainly used to mock out ec2pricing during testing
type OnDemandPricing ¶ added in v2.1.0
type OnDemandPricing struct { Region string FullRefreshTTL time.Duration DirectoryPath string sync.RWMutex // contains filtered or unexported fields }
func LoadODCacheOrNew ¶ added in v2.1.0
func LoadODCacheOrNew(pricingClient pricingiface.PricingAPI, region string, fullRefreshTTL time.Duration, directoryPath string) *OnDemandPricing
func (*OnDemandPricing) Clear ¶ added in v2.1.0
func (c *OnDemandPricing) Clear() error
func (*OnDemandPricing) Count ¶ added in v2.1.0
func (c *OnDemandPricing) Count() int
Count of items in the cache
func (*OnDemandPricing) Get ¶ added in v2.1.0
func (c *OnDemandPricing) Get(instanceType string) (float64, error)
func (*OnDemandPricing) Refresh ¶ added in v2.1.0
func (c *OnDemandPricing) Refresh() error
func (*OnDemandPricing) Save ¶ added in v2.1.0
func (c *OnDemandPricing) Save() error
type SpotPricing ¶ added in v2.1.0
type SpotPricing struct { Region string FullRefreshTTL time.Duration DirectoryPath string sync.RWMutex // contains filtered or unexported fields }
func LoadSpotCacheOrNew ¶ added in v2.1.0
func (*SpotPricing) Clear ¶ added in v2.1.0
func (c *SpotPricing) Clear() error
func (*SpotPricing) Count ¶ added in v2.1.0
func (c *SpotPricing) Count() int
Count of items in the cache
func (*SpotPricing) Refresh ¶ added in v2.1.0
func (c *SpotPricing) Refresh(days int) error
func (*SpotPricing) Save ¶ added in v2.1.0
func (c *SpotPricing) Save() error