This commit is contained in:
Stephan D
2026-02-12 12:47:39 +01:00
parent f4b43f7218
commit 97395acd8f
8 changed files with 271 additions and 24 deletions

View File

@@ -10,7 +10,10 @@ import (
"gopkg.in/yaml.v3"
)
const defaultMetricsAddress = ":9405"
const (
defaultMetricsAddress = ":9405"
defaultShutdownTimeoutSeconds = 15
)
type config struct {
Runtime *grpcapp.RuntimeConfig `yaml:"runtime"`
@@ -24,24 +27,28 @@ type metricsConfig struct {
}
type registryConfig struct {
KVTTLSeconds *int `yaml:"kv_ttl_seconds"`
KVTTLSeconds *int `yaml:"kv_ttl_seconds"` //nolint:tagliatelle // matches config file format
}
func (i *Imp) loadConfig() (*config, error) {
data, err := os.ReadFile(i.file)
if err != nil {
i.logger.Error("Could not read configuration file", zap.String("config_file", i.file), zap.Error(err))
return nil, err
return nil, err //nolint:wrapcheck
}
cfg := &config{}
if err := yaml.Unmarshal(data, cfg); err != nil {
err = yaml.Unmarshal(data, cfg)
if err != nil {
i.logger.Error("Failed to parse configuration", zap.Error(err))
return nil, err
return nil, err //nolint:wrapcheck
}
if cfg.Runtime == nil {
cfg.Runtime = &grpcapp.RuntimeConfig{ShutdownTimeoutSeconds: 15}
cfg.Runtime = &grpcapp.RuntimeConfig{ShutdownTimeoutSeconds: defaultShutdownTimeoutSeconds}
}
if cfg.Metrics != nil && strings.TrimSpace(cfg.Metrics.Address) == "" {