/
discover.go
186 lines (160 loc) · 5.16 KB
/
discover.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package model
//SDS strcut
type SDS struct {
Hosts []*PieceSDS `json:"hosts"`
}
//PieceSDS struct
type PieceSDS struct {
IPAddress string `json:"ip_address"`
Port int32 `json:"port"`
//Tags sdsTags `json:"tags"`
}
type sdsTags struct {
AZ string `json:"az"`
Canary string `json:"canary"`
LoadBalancingWeight string `json:"load_balancing_weight"`
}
//CDS struct
type CDS struct {
Clusters []*PieceCDS `json:"clusters"`
}
//PieceCDS struct
type PieceCDS struct {
Name string `json:"name"`
Type string `json:"type"`
ConnectTimeoutMS int `json:"connect_timeout_ms"`
LBType string `json:"lb_type"`
ServiceName string `json:"service_name"`
CircuitBreakers *CircuitBreakers `json:"circuit_breakers"`
//HealthCheck cdsHealthCheckt `json:"health_check"`
}
//MaxConnections circuit
type MaxConnections struct {
MaxConnections int `json:"max_connections"`
MaxPendingRequests int `json:"max_pending_requests"`
MaxRequests int `json:"max_requests"`
MaxRetries int `json:"max_retries"`
}
//CircuitBreakers circuit
type CircuitBreakers struct {
Default *MaxConnections `json:"default"`
}
type cdsHealthCheckt struct {
Type string `json:"type"`
TimeoutMS int `json:"timeout_ms"`
IntervalMS int `json:"interval_ms"`
IntervalJitterMS int `json:"interval_jitter_ms"`
UnhealthyThreshold int `json:"unhealthy_threshold"`
HealthyThreshold int `json:"healthy_threshold"`
Path string `json:"path"`
ServiceName string `json:"service_name"`
}
//LDS struct
type LDS struct {
Listeners []*PieceLDS `json:"listeners"`
}
//PieceLDS struct
type PieceLDS struct {
Name string `json:"name"`
Address string `json:"address"`
Filters []*LDSFilters `json:"filters"`
}
//LDSFilters LDSFilters
type LDSFilters struct {
Name string `json:"name"`
Config interface{} `json:"config"`
}
//LDSTCPConfig LDSTCPConfig
type LDSTCPConfig struct {
StatPrefix string `json:"stat_prefix"`
RouteConfig *LDSTCPRoutes `json:"route_config"`
}
//LDSTCPRoutes LDSTCPRoutes
type LDSTCPRoutes struct {
Routes []*PieceTCPRoute `json:"routes"`
}
//PieceTCPRoute PieceTCPRoute
type PieceTCPRoute struct {
Cluster string `json:"cluster"`
}
//LDSHTTPConfig LDSHTTPConfig
type LDSHTTPConfig struct {
CodecType string `json:"codec_type"`
StatPrefix string `json:"stat_prefix"`
RouteConfig *RouteConfig `json:"route_config"`
Filters []*HTTPSingleFileter `json:"filters"`
}
//RouteConfig RouteConfig
type RouteConfig struct {
VirtualHosts []*PieceHTTPVirtualHost `json:"virtual_hosts"`
}
//PieceHTTPVirtualHost PieceHTTPVirtualHost
type PieceHTTPVirtualHost struct {
Name string `json:"name"`
Domains []string `json:"domains"`
//Routes []*PieceHTTPRoutes `json:"routes"`
Routes interface{} `json:"routes"`
}
//WeightedClusters WeightedClusters
type WeightedClusters struct {
Clusters []map[string]interface{} `json:"clusters"`
}
//PieceHTTPRoutes PieceHTTPRoutes
type PieceHTTPRoutes struct {
TimeoutMS int `json:"timeout_ms"`
Prefix string `json:"prefix"`
Cluster string `json:"cluster"`
//Headers []PieceHeader `json:"headers"`
Headers interface{} `json:"headers"`
}
//PieceHeader PieceHeader
type PieceHeader struct {
Name string `json:"name"`
Value string `json:"value"`
}
//HTTPSingleFileter HttpSingleFileter
type HTTPSingleFileter struct {
Type string `json:"type"`
Name string `json:"name"`
Config map[string]string `json:"config"`
}
const (
//PREFIX PREFIX
PREFIX string = "PREFIX"
//HEADERS HEADERS
HEADERS string = "HEADERS"
//DOMAINS DOMAINS
DOMAINS string = "DOMAINS"
//LIMITS LIMITS
LIMITS string = "LIMITS"
//MaxPendingRequests MaxPendingRequests
MaxPendingRequests string = "MaxPendingRequests"
//MaxRequests MaxRequests
MaxRequests string = "MaxRequests"
//MaxRetries MaxRetries
MaxRetries string = "MaxRetries"
//UPSTREAM upStream
UPSTREAM string = "upStream"
//DOWNSTREAM downStream
DOWNSTREAM string = "downStream"
//WEIGHT WEIGHT
WEIGHT string = "WEIGHT"
//MODELWEIGHT MODEL_WEIGHT
MODELWEIGHT string = "weight_model"
//MODELPREFIX MODEL_PREFIX
MODELPREFIX string = "prefix_model"
)