Skip to content

Commit a88f435

Browse files
committed
add configurable browser timeout
1 parent 7998642 commit a88f435

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

internal/app/browser.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ import (
1111
)
1212

1313
func DownloadCsv(config *Config, startDate string, endDate string) (string, error) {
14+
timeout, err := time.ParseDuration(config.Timeout)
15+
if err != nil {
16+
return "", err
17+
}
1418
ctx, cancel := chromedp.NewContext(context.Background(), chromedp.WithLogf(log.Printf))
1519
defer cancel()
16-
ctx, cancel = context.WithTimeout(ctx, 30*time.Second)
20+
ctx, cancel = context.WithTimeout(ctx, timeout)
1721
defer cancel()
1822

1923
done := make(chan string, 1)
@@ -29,7 +33,7 @@ func DownloadCsv(config *Config, startDate string, endDate string) (string, erro
2933
}
3034
})
3135

32-
err := chromedp.Run(ctx,
36+
err = chromedp.Run(ctx,
3337
chromedp.Navigate(config.LoginUrl),
3438
chromedp.SetValue("#LoginUsernameTextBox", config.Username, chromedp.NodeVisible),
3539
chromedp.SetValue("#LoginPasswordTextBox", config.Password),

internal/app/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Config struct {
2727
LoginUrl string
2828
DownloadDir string
2929
ExtractDays int
30+
Timeout string
3031
InfluxDB InfluxDB
3132
}
3233

0 commit comments

Comments
 (0)