/
config-type.go
74 lines (65 loc) · 3.2 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
package config
type GlobalConfig struct {
ServerConfig ControlPlaneAPIServerConfig `json:"serverConfig" yaml:"serverConfig"`
LogConfig LoggerConfig `json:"logConfig" yaml:"logConfig"`
DBConfig DBConfig `json:"dbConfig" yaml:"dbConfig"`
EtcdConfig EtcdConfig `json:"etcdConfig" yaml:"etcdConfig"`
XdsServerConfig XdsServerConfig `json:"xdsServerConfig" yaml:"xdsServerConfig"`
}
type DBConfig struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
Database string `json:"database" yaml:"database"`
ConnectionParameters map[string]string `json:"connectionParameters" yaml:"connectionParameters"`
User string `json:"user" yaml:"user"`
Password string `json:"password" yaml:"password"`
EngineType string `json:"engineType" yaml:"engineType"` // mysql, postgres
TargetDatabase string `json:"targetDatabase" yaml:"targetDatabase"` // dbname
TablesPrefix string `json:"tablesPrefix" yaml:"tablesPrefix"`
MaxPoolSize int `json:"maxPoolSize" yaml:"maxPoolSize"`
MaxIdleSize int `json:"maxIdleSize" yaml:"maxIdleSize"`
}
type EtcdConfig struct {
Endpoints []string `json:"endpoints" yaml:"endpoints"`
AuthType string `json:"authType" yaml:"authType"`
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
KeyNamespace string `json:"keyNamespace" yaml:"keyNamespace"` // Auto prepend key prefix, like: gw-control/xds (without trailing slash, it will be added automatically)
}
const (
EtcdAuthTypeNone = "None"
EtcdAuthTypePassowrd = "Password"
)
type LoggerConfig struct {
Level string `json:"level" yaml:"level"`
LogFormat string `json:"logFormat" yaml:"logFormat"` // text, json
Color bool `json:"color" yaml:"color"` // console log color
FileLog struct {
Enable bool `json:"enable" yaml:"enable"`
LogFileDir string `json:"logFileDir" yaml:"logFileDir"`
} `json:"fileLog" yaml:"fileLog"`
//GrayLog struct {
// Enable bool
// GrayLogServerAddress string
//}
}
const (
LogLevelWarn = "warn"
LogLevelInfo = "info"
LogLevelDebug = "debug"
LogLevelTrace = "trace"
LogFormatText = "text"
LogFormatJson = "json"
)
type ControlPlaneAPIServerConfig struct {
ListenAddr string `json:"listenAddr" yaml:"listenAddr"`
GinMode string `json:"ginMode" yaml:"ginMode"` // debug, release, test
CorsOrigins []string `json:"corsOrigins" yaml:"corsOrigins"`
}
type XdsServerConfig struct {
ListenAddr string `json:"listenAddr" yaml:"listenAddr"`
GrpcKeepaliveSeconds uint64 `json:"grpcKeepaliceSeconds" yaml:"grpcKepaliveSeconds"`
GrpcKeepaliveTimeoutSeconds uint64 `json:"grpcKeepaliveTimeoutSeconds" yaml:"grpcKeepaliveTimeoutSeconds"`
GrpcKeepaliveMinTimeSeconds uint64 `json:"grpcKeepaliveMinTimeSeoncds" yaml:"grpcKeepaliveMinTimeSeoncds"`
GrpcMaxConcurrentStreams uint64 `json:"grpcMaxConcurrentStreams" yaml:"grpcMaxConcurrentStreams"`
}