27 lines
551 B
Go
27 lines
551 B
Go
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
|
|
}
|