From 5f1f1fdf6f1fa56a531cf4ebbcc5f82d1fa0e43f Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Fri, 18 Nov 2022 23:58:40 +0100 Subject: [PATCH] switched timeout to config flag --- config.sample.yaml | 4 +++- main.go | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config.sample.yaml b/config.sample.yaml index beb28e1..8a73d92 100644 --- a/config.sample.yaml +++ b/config.sample.yaml @@ -2,4 +2,6 @@ logging: level: DEBUG station_ip: "ip here" -password: "password here" \ No newline at end of file +password: "password here" + +timeout: "100s" \ No newline at end of file diff --git a/main.go b/main.go index a0edc3e..8c596f6 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ type Conf struct { } StationIP string `yaml:"station_ip"` Password string `yaml:"password"` + Timeout string `yaml:"timeout"` } var ( @@ -184,8 +185,13 @@ func main() { log.Fatalf("error creating jar") } + timeout, err := time.ParseDuration(conf.Timeout) + if err != nil { + log.Fatalf("unable to parse duration %s: %v", conf.Timeout, err) + } + httpClient = &http.Client{ - Timeout: time.Second * 30, + Timeout: timeout, Jar: cj, }