-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
117 lines (100 loc) · 2.65 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package test
import (
"time"
"github.com/alexfalkowski/go-service/cache/redis"
"github.com/alexfalkowski/go-service/cache/ristretto"
"github.com/alexfalkowski/go-service/database/sql/config"
"github.com/alexfalkowski/go-service/database/sql/pg"
"github.com/alexfalkowski/go-service/security/auth0"
"github.com/alexfalkowski/go-service/trace/opentracing"
"github.com/alexfalkowski/go-service/transport"
"github.com/alexfalkowski/go-service/transport/grpc"
gretry "github.com/alexfalkowski/go-service/transport/grpc/retry"
"github.com/alexfalkowski/go-service/transport/http"
hretry "github.com/alexfalkowski/go-service/transport/http/retry"
"github.com/alexfalkowski/go-service/transport/nsq"
nretry "github.com/alexfalkowski/go-service/transport/nsq/retry"
)
const timeout = 2 * time.Second
// Config for test.
type Config struct{}
func (cfg *Config) RedisConfig() *redis.Config {
return nil
}
func (cfg *Config) RistrettoConfig() *ristretto.Config {
return nil
}
func (cfg *Config) Auth0Config() *auth0.Config {
return nil
}
func (cfg *Config) PGConfig() *pg.Config {
return nil
}
func (cfg *Config) OpentracingConfig() *opentracing.Config {
return nil
}
func (cfg *Config) TransportConfig() *transport.Config {
return nil
}
func (cfg *Config) GRPCConfig() *grpc.Config {
return nil
}
func (cfg *Config) HTTPConfig() *http.Config {
return nil
}
func (cfg *Config) NSQConfig() *nsq.Config {
return nil
}
// NewTransportConfig for test.
func NewTransportConfig() *transport.Config {
return &transport.Config{
Port: GenerateRandomPort(),
HTTP: http.Config{
UserAgent: "TestHTTP/1.0",
Retry: hretry.Config{
Timeout: timeout,
Attempts: 1,
},
},
GRPC: grpc.Config{
UserAgent: "TestGRPC/1.0",
Retry: gretry.Config{
Timeout: timeout,
Attempts: 1,
},
},
NSQ: nsq.Config{
LookupHost: "localhost:4161",
Host: "localhost:4150",
UserAgent: "TestNSQ/1.0",
Retry: nretry.Config{
Timeout: timeout,
Attempts: 1,
},
},
}
}
// NewJaegerConfig for test.
func NewJaegerConfig() *opentracing.Config {
return &opentracing.Config{
Kind: "jaeger",
Host: "localhost:6831",
}
}
// NewDatadogConfig for test.
func NewDatadogConfig() *opentracing.Config {
return &opentracing.Config{
Kind: "datadog",
Host: "localhost:8126",
}
}
// NewPGConfig for test.
func NewPGConfig() *pg.Config {
return &pg.Config{Config: config.Config{
Masters: []config.DSN{{URL: "postgres://test:test@localhost:5432/test?sslmode=disable"}},
Slaves: []config.DSN{{URL: "postgres://test:test@localhost:5432/test?sslmode=disable"}},
MaxOpenConns: 5,
MaxIdleConns: 5,
ConnMaxLifetime: time.Hour,
}}
}