Added default interval

This commit is contained in:
Christopher Ramey 2021-01-17 05:24:13 -09:00
parent 5c930cd409
commit f108090967
2 changed files with 8 additions and 1 deletions

View File

@ -10,6 +10,13 @@ type AlrmConfig struct {
Interval time.Duration Interval time.Duration
} }
func NewConfig() *AlrmConfig {
return &AlrmConfig{
// Default check interval, 30 seconds
Interval: time.Second * 30,
}
}
func (ac *AlrmConfig) NewGroup(name string) (*AlrmGroup, error) { func (ac *AlrmConfig) NewGroup(name string) (*AlrmGroup, error) {
if ac.Groups == nil { if ac.Groups == nil {
ac.Groups = make(map[string]*AlrmGroup) ac.Groups = make(map[string]*AlrmGroup)

View File

@ -33,7 +33,7 @@ func (p *Parser) Parse(fn string) (*AlrmConfig, error) {
} }
defer file.Close() defer file.Close()
config := &AlrmConfig{} config := NewConfig()
scan := bufio.NewScanner(file) scan := bufio.NewScanner(file)
scan.Split(p.Split) scan.Split(p.Split)