pricing

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAWSPricingClient

func NewAWSPricingClient(cfg aws.Config, region string) *pricing.Client

NewAWSPricingClient returns a pricing API client configured based on a particular region.

Types

type AWSProvider

type AWSProvider struct {
	Region        string
	EC2Client     ec2.DescribeSpotPriceHistoryAPIClient
	PricingClient pricing.GetProductsAPIClient
}

func NewAWSProvider

func NewAWSProvider(cfg aws.Config) *AWSProvider

func (*AWSProvider) GetFargatePricing

func (p *AWSProvider) GetFargatePricing(ctx context.Context) (FargatePrice, error)

func (*AWSProvider) GetOnDemandPricing

func (p *AWSProvider) GetOnDemandPricing(ctx context.Context) (OnDemandPriceList, error)

func (*AWSProvider) GetSpotPricing

func (p *AWSProvider) GetSpotPricing(ctx context.Context) (SpotPriceList, error)

type FargatePrice

type FargatePrice struct {
	VCPUPerHour float64
	GBPerHour   float64
}

FargatePrice is the price for Fargate.

type OnDemandPriceList

type OnDemandPriceList map[string]float64

OnDemandPriceList is a map of instance type to on-demand price.

type Provider

type Provider interface {
	GetOnDemandPricing(context.Context) (OnDemandPriceList, error)
	GetSpotPricing(context.Context) (SpotPriceList, error)
	GetFargatePricing(context.Context) (FargatePrice, error)
}

Provider is the interface used for provider implementation.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(provider Provider) *Repository

func (*Repository) FargateLastUpdated

func (pr *Repository) FargateLastUpdated() time.Time

FargateLastUpdated returns the time that the Fargate pricing was last updated.

func (*Repository) FargatePrice

func (pr *Repository) FargatePrice(cpu, memory float64) (float64, bool)

func (*Repository) InstanceTypes

func (pr *Repository) InstanceTypes() []string

InstanceTypes returns the list of all instance types for which either a spot or on-demand price is known.

func (*Repository) OnDemandLastUpdated

func (pr *Repository) OnDemandLastUpdated() time.Time

OnDemandLastUpdated returns the time that the on-demand pricing was last updated.

func (*Repository) OnDemandPrice

func (pr *Repository) OnDemandPrice(instanceType string) (float64, bool)

OnDemandPrice returns the last known on-demand price for a given instance type, returning an error if there is no known on-demand pricing for the instance type.

func (*Repository) SpotLastUpdated

func (pr *Repository) SpotLastUpdated() time.Time

SpotLastUpdated returns the time that the spot pricing was last updated.

func (*Repository) SpotPrice

func (pr *Repository) SpotPrice(instanceType string, zone string) (float64, bool)

SpotPrice returns the last known spot price for a given instance type and zone, returning an error if there is no known spot pricing for that instance type or zone.

func (*Repository) UpdateFargatePricing

func (pr *Repository) UpdateFargatePricing(ctx context.Context) error

func (*Repository) UpdateOnDemandPricing

func (pr *Repository) UpdateOnDemandPricing(ctx context.Context) error

func (*Repository) UpdatePricing

func (pr *Repository) UpdatePricing(ctx context.Context) error

func (*Repository) UpdateSpotPricing

func (pr *Repository) UpdateSpotPricing(ctx context.Context) error

type SpotPriceList

type SpotPriceList map[string]map[string]float64

SpotPriceList is a map of instance type and zone to spot price.

type StaticProvider

type StaticProvider struct{}

func NewStaticProvider

func NewStaticProvider() *StaticProvider

func (*StaticProvider) GetFargatePricing

func (p *StaticProvider) GetFargatePricing(_ context.Context) (FargatePrice, error)

func (*StaticProvider) GetOnDemandPricing

func (p *StaticProvider) GetOnDemandPricing(_ context.Context) (OnDemandPriceList, error)

func (*StaticProvider) GetSpotPricing

func (p *StaticProvider) GetSpotPricing(_ context.Context) (SpotPriceList, error)

Jump to

Keyboard shortcuts

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