initial import

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-11-15 19:04:48 +03:00
parent 374f34fd60
commit a2a241cd78
6 changed files with 64 additions and 0 deletions

29
pkg/config/config.go Normal file
View File

@@ -0,0 +1,29 @@
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)
}