Rewrite camera uptime monitor in Golang

This commit is contained in:
ashish committed 2024-08-19 16:36:01 -05:00
1 parent fd4c30f655
commit 90efd78669
13 files changed
+284 -1

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
package config
import "os"
import "gopkg.in/yaml.v3"
type Config struct {
Cameras map[string]string `yaml:"cameras"`
PingIntervalSeconds int64 `yaml:"ping_interval_s"`
PingTimeoutSeconds int64 `yaml:"ping_timeout_s"`
ConsecutiveDownThreshold int `yaml:"consecutive_down_threshold"`
}
func ReadConfig(configFilename string) Config {
var data, readErr = os.ReadFile(configFilename)
if readErr != nil {
panic(readErr)
}
var config Config
if yamlErr := yaml.Unmarshal(data, &config); yamlErr != nil {
panic(yamlErr)
}
return config
}