/
config.go
48 lines (41 loc) · 1.41 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package app
import (
"time"
"code.cloudfoundry.org/go-envstruct"
)
// GRPC stores the configuration for the RLP as a server using a PORT with
// mTLS certs and as a client also using mTSL certs for emitting metrics and
// for connecting to the Router.
type GRPC struct {
Port int `env:"RLP_PORT"`
CertFile string `env:"RLP_CERT_FILE"`
KeyFile string `env:"RLP_KEY_FILE"`
CAFile string `env:"RLP_CA_FILE"`
CipherSuites []string `env:"RLP_CIPHER_SUITES"`
}
// Config stores all configurations options for RLP.
type Config struct {
UseRFC339 bool `env:"USE_RFC339"`
PProfPort uint32 `env:"RLP_PPROF_PORT"`
MetricEmitterInterval time.Duration `env:"RLP_METRIC_EMITTER_INTERVAL"`
MetricSourceID string `env:"RLP_METRIC_SOURCE_ID"`
RouterAddrs []string `env:"ROUTER_ADDRS, required"`
AgentAddr string `env:"AGENT_ADDR"`
MaxEgressStreams int64 `env:"MAX_EGRESS_STREAMS"`
GRPC GRPC
}
// LoadConfig reads from the environment to create a Config.
func LoadConfig() (*Config, error) {
conf := Config{
PProfPort: 6061,
MetricEmitterInterval: time.Minute,
MetricSourceID: "reverse_log_proxy",
AgentAddr: "localhost:3458",
MaxEgressStreams: 500,
}
err := envstruct.Load(&conf)
if err != nil {
return nil, err
}
return &conf, nil
}