diff options
author | JeffB42 <10328858+JeffB42@users.noreply.github.com> | 2021-04-18 19:21:44 +0300 |
---|---|---|
committer | JeffB42 <10328858+JeffB42@users.noreply.github.com> | 2021-04-18 19:21:44 +0300 |
commit | dfc72f314fcf636157760a6f55b31a466dfe0f4d (patch) | |
tree | baa0c954057f64d6e3b31017b62278df714e1d14 | |
parent | ec6eb1e6d42f116a0edb75e5b05eccffe47e994d (diff) |
added EXPERIMENTAL_UPDATE_FREQUENCY
-rwxr-xr-x | ui/ui.go | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -2,6 +2,8 @@ package ui import ( "fmt" + "os" + "strconv" "strings" "sync" "time" @@ -100,7 +102,23 @@ func New(endpoint, key string, width, height int) *UI { } instance.splashPanel = NewSplashPanel(instance) - instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 20, instance.update) + + // Default timeout of 20 seconds. + durration := time.Second * 20 + + // Experimental, set the timeout based on config setting, but only if the config is pressent. + updateFrequency := os.Getenv("EXPERIMENTAL_UPDATE_FREQUENCY") + if updateFrequency != "" { + logger.Infof("Ui.New() - EXPERIMENTAL_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency) + val, err := strconv.Atoi(updateFrequency) + if err == nil { + durration = time.Second * time.Duration(val) + } else { + logger.LogError("Ui.New()", "strconv.Atoi()", err) + } + } + + instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update) instance.initialize() logger.TraceLeave("ui.New()") |