generated from liuzhaomax/go-maxms
/
config_type.go
99 lines (86 loc) · 2.04 KB
/
config_type.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
package core
import (
"crypto/rsa"
"github.com/sirupsen/logrus"
"sync"
)
var cfg *Config
var once sync.Once
func init() {
once.Do(func() {
cfg = &Config{}
})
}
func GetConfig() *Config {
return cfg
}
type Config struct {
App
Lib
Server
Downstreams []Downstream
}
type App struct {
Id string
Secret string
Name string `mapstructure:"name"`
Version string `mapstructure:"version"`
Domain string `mapstructure:"domain"`
PublicKey *rsa.PublicKey
PrivateKey *rsa.PrivateKey
PublicKeyStr string
PrivateKeyStr string
Salt string
JWTSecret string
Logger *logrus.Logger
Enabled Enabled `mapstructure:"enabled"`
WhiteList []WhiteList `mapstructure:"white_list"`
}
type Enabled struct {
Vault bool `mapstructure:"vault"`
RSA bool `mapstructure:"rsa"`
Signature bool `mapstructure:"signature"`
RandomPort bool `mapstructure:"random_port"`
ServiceDiscovery bool `mapstructure:"service_discovery"`
}
type WhiteList struct {
Name string `mapstructure:"name"`
Domain string `mapstructure:"domain"`
}
type Lib struct {
Log
Vault
Gin
DB
Redis
ETCD
Consul
Jaeger
Rocketmq
}
type ETCD struct {
DialTimeout int `mapstructure:"dial_timeout"`
DialKeepAliveTime int `mapstructure:"dial_keep_alive_time"`
DialKeepAliveTimeout int `mapstructure:"dial_keep_alive_timeout"`
Endpoint
}
type Endpoint struct {
Host string `mapstructure:"host"`
Port string `mapstructure:"port"`
}
type Server struct {
Protocol string `mapstructure:"protocol"`
Host string `mapstructure:"host"`
Port string `mapstructure:"port"`
BaseUrl string `mapstructure:"base_url"`
ReadTimeout int `mapstructure:"read_timeout"`
WriteTimeout int `mapstructure:"write_timeout"`
IdleTimeout int `mapstructure:"idle_timeout"`
ShutdownTimeout int `mapstructure:"shutdown_timeout"`
}
type Downstream struct {
Id string
Secret string
Name string `mapstructure:"name"`
Endpoint
}