Awattar: fetch more than 24h price data (#16338)
This commit is contained in:
parent
d53ead0f36
commit
4af2d19da3
1 changed files with 7 additions and 1 deletions
|
|
@ -62,8 +62,14 @@ func (t *Awattar) run(done chan error) {
|
|||
for ; true; <-tick.C {
|
||||
var res awattar.Prices
|
||||
|
||||
// Awattar publishes prices for next day around 13:00 CET/CEST, so up to 35h of price data are available
|
||||
// To be on the safe side request a window of -2h and +48h, the API doesn't mind requesting more than available
|
||||
start := time.Now().Add(-2 * time.Hour).UnixMilli()
|
||||
end := time.Now().Add(48 * time.Hour).UnixMilli()
|
||||
uri := fmt.Sprintf("%s?start=%d&end=%d", t.uri, start, end)
|
||||
|
||||
if err := backoff.Retry(func() error {
|
||||
return backoffPermanentError(client.GetJSON(t.uri, &res))
|
||||
return backoffPermanentError(client.GetJSON(uri, &res))
|
||||
}, bo()); err != nil {
|
||||
once.Do(func() { done <- err })
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue