2022-09-06 21:01:38 +02:00
|
|
|
package frontend
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/michaelquigley/cf"
|
|
|
|
"github.com/pkg/errors"
|
2022-10-18 17:07:18 +02:00
|
|
|
"time"
|
2022-09-06 21:01:38 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2022-10-18 17:07:18 +02:00
|
|
|
Identity string
|
|
|
|
Metrics *MetricsConfig
|
|
|
|
Address string
|
|
|
|
HostMatch string
|
|
|
|
}
|
|
|
|
|
|
|
|
type MetricsConfig struct {
|
2022-10-18 17:57:32 +02:00
|
|
|
Service string
|
|
|
|
SendTimeout time.Duration
|
2022-09-06 21:01:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func DefaultConfig() *Config {
|
|
|
|
return &Config{
|
2022-10-18 17:07:18 +02:00
|
|
|
Identity: "frontend",
|
|
|
|
Metrics: &MetricsConfig{
|
2022-10-18 17:57:32 +02:00
|
|
|
Service: "metrics",
|
|
|
|
SendTimeout: 5 * time.Second,
|
2022-10-18 17:07:18 +02:00
|
|
|
},
|
|
|
|
Address: "0.0.0.0:8080",
|
2022-09-06 21:01:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Config) Load(path string) error {
|
|
|
|
if err := cf.BindYaml(c, path, cf.DefaultOptions()); err != nil {
|
|
|
|
return errors.Wrapf(err, "error loading frontend config '%v'", path)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|