func NewProvider()

in pkg/pricing/pricing.go [56:79]


func NewProvider(ctx context.Context, pricing client.PricingAPI, region string) *Provider {
	// see if we've got region specific pricing data
	staticPricing, ok := initialOnDemandPrices[region]
	if !ok {
		// and if not, fall back to the always available eastus
		staticPricing = initialOnDemandPrices["eastus"]
	}

	p := &Provider{
		region:             region,
		onDemandUpdateTime: initialPriceUpdate,
		onDemandPrices:     staticPricing,
		spotUpdateTime:     initialPriceUpdate,
		// default our spot pricing to the same as the on-demand pricing until a price update
		spotPrices: staticPricing,
		pricing:    pricing,
	}

	go func() {
		// perform an initial price update at startup
		p.updatePricing(ctx)
	}()
	return p
}