From 617e025be4af92bd5bd785066e8b5952b880a01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Thu, 27 Jun 2024 09:09:47 +0200 Subject: [PATCH] Clarified file configuration naming --- config.go | 2 +- main.go | 8 ++++---- nodata.go | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/config.go b/config.go index 6ac26a3..5fe5d4e 100644 --- a/config.go +++ b/config.go @@ -1,6 +1,6 @@ package main -type SmonConfiguration struct { +type FileConfiguration struct { LogFile string NodataInterval int `json:"nodata_interval"` // in seconds } diff --git a/main.go b/main.go index 9c3d5ce..7bccbcf 100644 --- a/main.go +++ b/main.go @@ -39,7 +39,7 @@ var ( parsedTemplates map[string]*template.Template componentFilenames []string notificationManager notification.Manager - smonConf SmonConfiguration + fileConf FileConfiguration //go:embed sql sqlFS embed.FS @@ -91,13 +91,13 @@ func main() { // {{{ } j, _ := json.Marshal(service.Config.Application) - json.Unmarshal(j, &smonConf) - logFile, err = os.OpenFile(smonConf.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) + json.Unmarshal(j, &fileConf) + logFile, err = os.OpenFile(fileConf.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) if err != nil { logger.Error("application", "error", err) return } - if smonConf.NodataInterval < 10 { + if fileConf.NodataInterval < 10 { logger.Error("application → nodata_interval has to be larger or equal to 10.") return } diff --git a/nodata.go b/nodata.go index ea09de9..40244c1 100644 --- a/nodata.go +++ b/nodata.go @@ -24,8 +24,7 @@ func nodataLoop() { var datapoints []Datapoint var err error - // TODO - should be configurable - ticker := time.NewTicker(time.Second * time.Duration(smonConf.NodataInterval)) + ticker := time.NewTicker(time.Second * time.Duration(fileConf.NodataInterval)) for { <-ticker.C datapoints, err = nodataDatapoints()