servicechecker/pkg/config/config.go
Vasiliy Tolstov a2a241cd78 initial import
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-15 19:04:48 +03:00

30 lines
762 B
Go

package config
import "io"
type Config struct {
Services []*Service `json:"services,omitempty" yaml:"services,omitempty"`
}
type Service struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Addr string `json:"addr,omitempty" yaml:"addr,omitempty"`
Checks []Check `json:"checks,omitempty" yaml:"checks,omitempty"`
}
type Check struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Data string `json:"data,omitempty" yaml:"data,omitempty"`
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}
func (cfg *Config) Parse(r io.Reader) error {
buf, err := io.ReadAll(r)
if err != nil {
return err
}
return yaml.Unmarshal(buf, cfg)
}