Manual mode

Signed-off-by: Thomas Klaehn <tkl@blackfinn.de>
This commit is contained in:
2025-08-14 08:55:02 +02:00
parent 6a9a42adc6
commit 8f0fd525d9
26 changed files with 1283 additions and 384 deletions

View File

@@ -0,0 +1,44 @@
package config
import (
"encoding/json"
"log"
"waterservice/internal/app/storage"
)
type config struct {
Influx struct {
Host string `json:"host"`
Port int `json:"port"`
Token string `json:"token"`
Org string `json:"org"`
Bucket string `json:"bucket"`
} `json:"influx"`
}
var (
logger log.Logger = *log.Default()
store storage.Storage
config_cache config
)
func init() {
logger.SetFlags(log.Llongfile | log.Ltime)
}
func SetConfigFilePath(path string) {
store.Path = path
res, err := store.Read()
if err != nil {
logger.Print("unable to read config")
return
}
err = json.Unmarshal(res, &config_cache)
if err != nil {
logger.Print("unable to unmarshal json to object")
}
}
func GetConfig() config {
return config_cache
}