Files
nvllama-watchdog/config/config.go
2026-10-11 14:39:54 +02:00

44 lines
991 B
Go

// config/config.go
package config
import (
"os"
"time"
"gopkg.in/yaml.v3"
)
type Config struct {
ScrapeInterval time.Duration `yaml:"scrape_interval"`
Readers []ReaderCfg `yaml:"readers"`
Exporters []ExporterCfg `yaml:"exporters"`
}
type ReaderCfg struct {
Type string `yaml:"type"`
Endpoint string `yaml:"endpoint,omitempty"`
Model string `yaml:"model,omitempty"`
Enabled map[string]bool `yaml:"enabled,omitempty"`
TopProcesses int `yaml:"top_processes,omitempty"`
}
type ExporterCfg struct {
Type string `yaml:"type"`
Addr string `yaml:"addr,omitempty"`
JSONFile string `yaml:"json_file,omitempty"`
}
func Load(path string) (*Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
var c Config
if err := yaml.Unmarshal(data, &c); err != nil {
return nil, err
}
if c.ScrapeInterval == 0 {
c.ScrapeInterval = 5 * time.Second
}
return &c, nil
}