package config import ( "io" yamlcodec "go.unistack.org/micro-codec-yaml/v3" mtime "go.unistack.org/micro/v3/util/time" ) type AppConfig struct { ChecksDir string `json:"checks_dir,omitempty" yaml:"checks_dir,omitempty"` Checks []*CheckConfig `json:"checks,omitempty" yaml:"checks,omitempty"` MultiUser bool `json:"multi_user,omitempty" yaml:"multi_user,omitempty"` } type MeterConfig struct { Addr string `json:"addr,omitempty" yaml:"addr,omitempty"` Path string `json:"path,omitempty" yaml:"path,omitempty"` } type Config struct { App *AppConfig `json:"app,omitempty" yaml:"app,omitempty"` Meter *MeterConfig `json:"meter,omitempty" yaml:"meter,omitempty"` } type CheckConfig struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` Tasks []*TaskConfig `json:"tasks,omitempty" yaml:"tasks,omitempty"` Timeout mtime.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"` Interval mtime.Duration `json:"interval,omitempty" yaml:"interval,omitempty"` Active bool `json:"active,omitempty" yaml:"active,omitempty"` User string `json:"user,omitempty" yaml:"user,omitempty"` } type HTTPConfig struct { Metadata map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty"` Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"` Data string `json:"data,omitempty" yaml:"data,omitempty"` Addr string `json:"addr,omitempty" yaml:"addr,omitempty"` OpenAPI string `json:"openapi,omitempty" yaml:"openapi,omitempty"` Method string `json:"method,omitempty" yaml:"method,omitempty"` } type GRPCConfig struct { Metadata map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty"` Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"` Data string `json:"data,omitempty" yaml:"data,omitempty"` Addr string `json:"addr,omitempty" yaml:"addr,omitempty"` Protoset string `json:"protoset,omitempty" yaml:"protoset,omitempty"` } type GraphQLConfig struct { Metadata map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty"` Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"` Data string `json:"data,omitempty" yaml:"data,omitempty"` Addr string `json:"addr,omitempty" yaml:"addr,omitempty"` } type TaskConfig struct { HTTP *HTTPConfig `json:"http,omitempty" yaml:"http,omitempty"` GRPC *GRPCConfig `json:"grpc,omitempty" yaml:"grpc,omitempty"` GraphQL *GraphQLConfig `json:"graphql,omitempty" yaml:"graphql"` TLSVerify *bool `json:"tls_verify,omitempty" yaml:"tls_verify,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Timeout mtime.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"` Active bool `json:"active,omitempty" yaml:"active,omitempty"` } func (cfg *Config) Parse(r io.Reader) error { buf, err := io.ReadAll(r) if err != nil { return err } return yamlcodec.NewCodec().Unmarshal(buf, cfg) }