in pkg/pricing/pricing.go [223:251]
func (p *Provider) UpdateSpotPricing(ctx context.Context) *Err {
// standard on-demand instances
var wg sync.WaitGroup
var spotPrices = map[string]float64{}
var spotErr error
wg.Add(1)
go func() {
defer wg.Done()
spotErr = p.fetchPricing(ctx, spotPage(spotPrices))
}()
wg.Wait()
p.mu.Lock()
defer p.mu.Unlock()
err := spotErr
if err != nil {
return &Err{error: err, lastUpdateTime: p.spotUpdateTime}
}
if len(spotPrices) == 0 {
return &Err{error: errors.New("no spot pricing found"), lastUpdateTime: p.spotUpdateTime}
}
p.spotPrices = lo.Assign(spotPrices)
p.spotUpdateTime = time.Now()
return nil
}