-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
74 lines (61 loc) · 1.94 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package config
import (
"github.com/alexfalkowski/go-service/cache"
"github.com/alexfalkowski/go-service/cache/redis"
"github.com/alexfalkowski/go-service/cache/ristretto"
"github.com/alexfalkowski/go-service/database/sql"
"github.com/alexfalkowski/go-service/database/sql/pg"
"github.com/alexfalkowski/go-service/security"
"github.com/alexfalkowski/go-service/security/auth0"
"github.com/alexfalkowski/go-service/trace"
"github.com/alexfalkowski/go-service/trace/opentracing"
"github.com/alexfalkowski/go-service/transport"
"github.com/alexfalkowski/go-service/transport/grpc"
"github.com/alexfalkowski/go-service/transport/http"
"github.com/alexfalkowski/go-service/transport/nsq"
)
// Config for the service.
type Config struct {
Runtime string `yaml:"runtime"`
Cache cache.Config `yaml:"cache"`
Security security.Config `yaml:"security"`
SQL sql.Config `yaml:"sql"`
Trace trace.Config `yaml:"trace"`
Transport transport.Config `yaml:"transport"`
}
// GetRuntime of the application. The values can be os or container.
// This is used to determine how we watch the configuration.
func (cfg *Config) GetRuntime() string {
runtime := cfg.Runtime
if runtime == "" {
return "os"
}
return runtime
}
func (cfg *Config) RedisConfig() *redis.Config {
return &cfg.Cache.Redis
}
func (cfg *Config) RistrettoConfig() *ristretto.Config {
return &cfg.Cache.Ristretto
}
func (cfg *Config) Auth0Config() *auth0.Config {
return &cfg.Security.Auth0
}
func (cfg *Config) PGConfig() *pg.Config {
return &cfg.SQL.PG
}
func (cfg *Config) OpentracingConfig() *opentracing.Config {
return &cfg.Trace.Opentracing
}
func (cfg *Config) TransportConfig() *transport.Config {
return &cfg.Transport
}
func (cfg *Config) GRPCConfig() *grpc.Config {
return &cfg.Transport.GRPC
}
func (cfg *Config) HTTPConfig() *http.Config {
return &cfg.Transport.HTTP
}
func (cfg *Config) NSQConfig() *nsq.Config {
return &cfg.Transport.NSQ
}