feat(ticker): Add ticker to env
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Matthieu 'JP' DERASSE 2023-07-20 18:28:06 +00:00
parent 0825774d36
commit 437a9eb42f
Signed by: mderasse
GPG Key ID: 55141C777B16A705
2 changed files with 6 additions and 5 deletions

View File

@ -24,16 +24,16 @@ func Init(alertChan chan api.Availability) {
log.Fatalf("Fail to instantiate the HTTP Client. Error: %s", err.Error())
}
priceAlertStr := os.Getenv("PRICE_ALERT")
if priceAlertStr != "" {
PriceAlert, err = strconv.ParseInt(priceAlertStr, 10, 64)
tickerInSecond := os.Getenv("TICKER_ALERT")
if tickerInSecond != "" {
ticker, err = strconv.ParseInt(tickerInSecond, 10, 64)
if err != nil {
log.Fatalf("invalid configuration. PRICE_ALERT environement variable should be an integer.")
log.Fatalf("invalid configuration. TICKER_ALERT environement variable should be an integer.")
}
}
// define an interval and the ticker for this interval
interval := time.Duration(6) * time.Second
interval := time.Duration(ticker) * time.Second
// create a new Ticker
tk := time.NewTicker(interval)

View File

@ -6,6 +6,7 @@ import (
// PriceAlert contain the minimum price that will trigger an alert.
var PriceAlert int64 = 47000
var ticker int64 = 6
var carFilter api.AvailabilityQueryParams = api.AvailabilityQueryParams{
Model: "my",