Documentation
¶
Index ¶
- Constants
- func FetchJSON()
- func ParseInput(pricer Pricer, input string) (string, error)
- func PriceTable(el OfferList) string
- func ProcessJSON()
- type EC2Attr
- type EC2Offer
- type EC2OfferIndex
- type EC2OfferParam
- type EC2PriceDimensions
- type EC2Product
- type EC2TermItem
- type EC2Terms
- type JSONOffer
- type Offer
- type OfferIndex
- type OfferList
- type OfferType
- type PriceDB
- func (pd *PriceDB) Get(name string, attr map[string]string) (Offer, error)
- func (pd *PriceDB) Search(name string, attr map[string]string) []Offer
- func (pd *PriceDB) StoreEC2(name string, attr map[string]string, offer EC2Offer) error
- func (pd *PriceDB) StoreRDS(name string, attr map[string]string, offer RDSOffer) error
- type Pricer
- type RDSAttr
- type RDSOffer
- type RDSOfferIndex
- type RDSOfferParam
- type RDSPriceDimensions
- type RDSProduct
- type RDSTermItem
- type RDSTerms
- type Region
Constants ¶
const HoursPerMonth = 730
HoursPerMonth is the average hours in a month. (365*24)/12 = 720
Variables ¶
This section is empty.
Functions ¶
func FetchJSON ¶
func FetchJSON()
FetchJSON downloads all the AWS Pricing JSON files that the tool is aware of how to utilize.
func ParseInput ¶
ParseInput takes a pricer and the input string and returns a string representation of the price
func PriceTable ¶
PriceTable returns a stringified table of all the results
func ProcessJSON ¶
func ProcessJSON()
ProcessJSON does the top level dispatching of processing all the AWS pricing JSON files and distilling them.
Types ¶
type EC2Attr ¶
type EC2Attr struct {
ServiceCode string `json:"servicecode"`
Location string `json:"location"`
LocationType string `json:"locationType"`
InstanceType string `json:"instanceType"`
CurrentGeneration string `json:"currentGeneration"`
InstanceFamily string `json:"instanceFamily"`
VCPU string `json:"vcpu"`
Memory string `json:"memory"`
OperatingSystem string `json:"operatingSystem"`
Tenancy string `json:"tenancy"`
}
EC2Attr identifies a selected list of useful attributes
type EC2Offer ¶
EC2Offer The product/price details for a given EC2 Offering
func (EC2Offer) HourlyPrice ¶
HourlyPrice returns the fractional dollars per hour
func (EC2Offer) RowData ¶
RowData returns data for this item for tablular presentation Should be used in concert with Columns
type EC2OfferIndex ¶
type EC2OfferIndex struct {
FormatVersion string `json:"formatVersion"`
Disclaimer string `json:"disclaimer"`
PublicationDate string `json:"publicationDate"`
Products map[string]EC2Product `json:"products"`
Terms EC2Terms `json:"terms"`
}
EC2OfferIndex is at the root of the EC2 Offer JSON document
type EC2OfferParam ¶
EC2OfferParam stores the unique factors that determine an EC2 Offer
func NewEC2OfferParam ¶
func NewEC2OfferParam(name string, attr map[string]string) (EC2OfferParam, error)
NewEC2OfferParam constructs an EC2 offer from a name & attributes
type EC2PriceDimensions ¶
type EC2PriceDimensions struct {
RateCode string `json:"rateCode"`
Description string `json:"description"`
Unit string `json:"unit"`
PricePerUnit map[string]string `json:"pricePerUnit"`
}
EC2PriceDimensions stores various combinations of billing duration and currency
type EC2Product ¶
type EC2Product struct {
SKU string `json:"sku"`
ProductFamily string `json:"productFamily"`
Attr EC2Attr `json:"attributes"`
}
EC2Product identifies a single product 'leaf' in the JSON document
type EC2TermItem ¶
type EC2TermItem struct {
OfferTermCode string `json:"offerTermCode"`
SKU string `json:"sku"`
PriceDimensions map[string]EC2PriceDimensions `json:"priceDimensions"`
}
EC2TermItem is a given pricing term
type EC2Terms ¶
type EC2Terms struct {
OnDemand map[string]map[string]EC2TermItem
}
EC2Terms tracks the various terms. For now only OnDemand (not prepaid/spot/etc) is used.
type JSONOffer ¶
type JSONOffer struct {
OfferCode string `json:"offerCode"`
VersionIndexURL string `json:"versionIndexUrl"`
CurrentVersionURL string `json:"currentVersionUrl"`
}
JSONOffer identifies a singular Offer File for a given service
type Offer ¶
type Offer interface {
HourlyPrice() float64
Type() OfferType
Name() string
String() string
Columns() []string
RowData() []string
}
Offer is the standard interface for offers. It is implemented by all objects which end up with prices
type OfferIndex ¶
type OfferIndex struct {
FormatVersion string `json:"formatVersion"`
Disclaimer string `json:"disclaimer"`
PublicationDate string `json:"publicationDate"`
Offers map[string]JSONOffer `json:"offers"`
}
OfferIndex contains the top level information about the various Offers aka Amazon Service families
type PriceDB ¶
type PriceDB struct {
// OfferLookup maps a name (like 'm4.xlarge') to a type (EC2)
OfferLookup map[string]OfferType
EC2 map[EC2OfferParam]EC2Offer
RDS map[RDSOfferParam]RDSOffer
}
PriceDB is the high level storage container for all the pricing data. It has utility methods for storing, loading, and searching the price data.
func LoadPriceDB ¶
LoadPriceDB loads the simple pricing "database" into memory The current implementation is a GOB file
func (*PriceDB) Get ¶
Get returns an hourly price (or an error, if such a thing happens) when given a name and optional attributes
type Pricer ¶
type Pricer interface {
StoreEC2(name string, attr map[string]string, offer EC2Offer) error
StoreRDS(name string, attr map[string]string, offer RDSOffer) error
Get(name string, attr map[string]string) (Offer, error)
Search(name string, attr map[string]string) []Offer
}
Pricer is a standard interface for price lookups. Given a name and defined attributes, (such as Region), it will return a floating point hourly price
type RDSAttr ¶
type RDSAttr struct {
ServiceCode string `json:"servicecode"`
Location string `json:"location"`
LocationType string `json:"locationType"`
InstanceType string `json:"instanceType"`
CurrentGeneration string `json:"currentGeneration"`
InstanceFamily string `json:"instanceFamily"`
VCPU string `json:"vcpu"`
Memory string `json:"memory"`
OperatingSystem string `json:"operatingSystem"`
Tenancy string `json:"tenancy"`
DatabaseEngine string `json:"databaseEngine"`
DeploymentOption string `json:"deploymentOption"`
}
RDSAttr identifies a selected list of useful attributes
type RDSOffer ¶
RDSOffer The product/price details for a given RDS Offering
func (RDSOffer) HourlyPrice ¶
HourlyPrice returns the fractional dollars per hour
func (RDSOffer) RowData ¶
RowData returns data for this item for tablular presentation Should be used in concert with Columns
type RDSOfferIndex ¶
type RDSOfferIndex struct {
FormatVersion string `json:"formatVersion"`
Disclaimer string `json:"disclaimer"`
PublicationDate string `json:"publicationDate"`
Products map[string]RDSProduct `json:"products"`
Terms RDSTerms `json:"terms"`
}
RDSOfferIndex is at the root of the RDS Offer JSON document
type RDSOfferParam ¶
type RDSOfferParam struct {
DatabaseEngine string
DeploymentOption string
Region Region
Name string
}
RDSOfferParam stores the unique factors that determine an RDS Offer
func NewRDSOfferParam ¶
func NewRDSOfferParam(name string, attr map[string]string) (RDSOfferParam, error)
NewRDSOfferParam constructs an RDS offer from a name & attributes
type RDSPriceDimensions ¶
type RDSPriceDimensions struct {
RateCode string `json:"rateCode"`
Description string `json:"description"`
Unit string `json:"unit"`
PricePerUnit map[string]string `json:"pricePerUnit"`
}
RDSPriceDimensions stores various combinations of billing duration and currency
type RDSProduct ¶
type RDSProduct struct {
SKU string `json:"sku"`
ProductFamily string `json:"productFamily"`
Attr RDSAttr `json:"attributes"`
}
RDSProduct identifies a single product 'leaf' in the JSON document
type RDSTermItem ¶
type RDSTermItem struct {
OfferTermCode string `json:"offerTermCode"`
SKU string `json:"sku"`
PriceDimensions map[string]RDSPriceDimensions `json:"priceDimensions"`
}
RDSTermItem is a given pricing term
type RDSTerms ¶
type RDSTerms struct {
OnDemand map[string]map[string]RDSTermItem
}
RDSTerms tracks the various terms. For now only OnDemand (not prepaid/spot/etc) is used.