-
Notifications
You must be signed in to change notification settings - Fork 21
/
routing.proto
280 lines (244 loc) · 8.63 KB
/
routing.proto
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
syntax = "proto3";
package v1;
import "google/protobuf/wrappers.proto";
import "google/protobuf/any.proto";
import "model.proto";
option go_package = "github.com/polarismesh/specification/source/go/api/v1/traffic_manage";
option java_package = "com.tencent.polaris.specification.api.v1.traffic.manage";
option java_outer_classname = "RoutingProto";
message Routing {
// 规则所属服务以及命名空间
google.protobuf.StringValue service = 1;
google.protobuf.StringValue namespace = 2;
// 每个服务可以配置多条入站或者出站规则
// 对于每个请求,从上到下依次匹配,若命中则终止
repeated Route inbounds = 3;
repeated Route outbounds = 4;
google.protobuf.StringValue ctime = 5;
google.protobuf.StringValue mtime = 6;
google.protobuf.StringValue revision = 7;
google.protobuf.StringValue service_token = 8 [ json_name = "service_token" ];
reserved 9 to 20;
// route rules for current service
repeated RouteRule rules = 21;
}
// deprecated: only for compatible to the old version server
message Route {
// 如果匹配Source规则,按照Destination路由
// 多个Source之间的关系为或
repeated Source sources = 1;
repeated Destination destinations = 2;
// extendInfo 用于承载一些额外信息
// case 1: 升级到 v2 版本时,记录对应到 v2 版本的 id 信息
map<string, string> extendInfo = 3;
}
// deprecated: only for compatible to the old version server
message Source {
// 主调方服务以及命名空间
google.protobuf.StringValue service = 1;
google.protobuf.StringValue namespace = 2;
// 主调方服务实例标签或者请求标签
// value支持正则匹配
map<string, MatchString> metadata = 3;
}
// deprecated: only for compatible to the old version server
message Destination {
// 被调方服务以及命名空间
google.protobuf.StringValue service = 1;
google.protobuf.StringValue namespace = 2;
// 被调方服务实例标签
// value支持正则匹配
map<string, MatchString> metadata = 3;
// 根据服务名和服务实例metadata筛选符合条件的服务实例子集
// 服务实例子集可以设置优先级和权重
// 优先级:整型,范围[0, 9],最高优先级为0
// 权重:整型
// 先按优先级路由,如果存在高优先级,不会使用低优先级
// 如果存在优先级相同的子集,再按权重分配
// 优先级和权重可以都不设置/设置一个/设置两个
// 如果部分设置优先级,部分没有设置,认为没有设置的优先级最低
// 如果部分设置权重,部分没有设置,认为没有设置的权重为0
// 如果全部没有设置权重,认为权重相同
google.protobuf.UInt32Value priority = 4;
google.protobuf.UInt32Value weight = 5;
// 将请求转发到代理服务
google.protobuf.StringValue transfer = 6;
//是否对该set执行隔离,隔离后,不会再分配流量
google.protobuf.BoolValue isolate = 7;
// 实例分组名
google.protobuf.StringValue name = 8;
}
enum RoutingPolicy {
// Route by rule rule => RuleRoutingConfig
RulePolicy = 0;
// Route by destination metadata ==> MetadataRoutingConfig
MetadataPolicy = 1;
// Route by Nearby rule => NearByRoutingConfig
NearbyPolicy = 2;
}
// configuration root for route
message RouteRule {
string id = 1;
// route rule name
string name = 2;
// namespace namingspace of routing rules
string namespace = 3;
// Enable this router
bool enable = 4;
// Router type
RoutingPolicy routing_policy = 5 [ json_name = "routing_policy" ];
// Routing configuration for router
google.protobuf.Any routing_config = 6 [ json_name = "routing_config" ];
// revision routing version
string revision = 7;
// ctime create time of the rules
string ctime = 8;
// mtime modify time of the rules
string mtime = 9;
// etime enable time of the rules
string etime = 10;
// priority rules priority
uint32 priority = 11;
// description simple description rules
string description = 12;
// extendInfo 用于承载一些额外信息
// case 1: 升级到 v2 版本时,记录对应到 v1 版本的 id 信息
// deprecated_filed only for compatible to the old version server
map<string, string> extendInfo = 20;
// 路由规则标签数据
map<string, string> metadata = 21;
// 操作标志位
bool editable = 30 [ json_name = "editable" ];
bool deleteable = 31 [ json_name = "deleteable" ];
}
message MetadataFailover {
enum FailoverRange {
// ALL return all instances
ALL = 0;
// OTHERS retuen without thie labels instances
OTHERS = 1;
// OTHER_KEYS return other instances which match keys
OTHER_KEYS = 2;
}
// failover_range metadata route bottom type
FailoverRange failover_range = 1;
// only use to failover_range == OTHER_KEYS
map<string, string> labels = 2;
}
// MetadataRoutingConfig metadata routing configuration
message MetadataRoutingConfig {
// service
string service = 1;
// namespace
string namespace = 2;
map<string, string> labels = 3;
// When metadata not found, it will fall back to the
MetadataFailover failover = 4;
}
// NearbyRoutingConfig routing configuration
message NearbyRoutingConfig {
enum LocationLevel {
// 未知就近级别,等同于未定义级别
UNKNOWN = 0;
// 机房就近级别
CAMPUS = 1;
// 可用区就近级别
ZONE = 2;
// 地域就近级别
REGION = 3;
// 全局就近级别
ALL = 4;
}
// 被调服务名,支持*,代表全部服务
string service = 1 [ json_name = "service" ];
// 被调命名空间
string namespace = 2 [ json_name = "namespace" ];
// 默认就近级别
LocationLevel match_level = 3 [ json_name = "match_level" ];
// 最大就近级别
LocationLevel max_match_level = 4 [ json_name = "max_match_level" ];
// 是否强制就近
bool strict_nearby = 5 [ json_name = "strict_nearby" ];
}
// RuleRoutingConfig routing configuration
message RuleRoutingConfig {
// source source info
// deprecated_filed only for compatible to the old version server
repeated SourceService sources = 1 [deprecated = true];
// destination destinations info
// deprecated_filed only for compatible to the old version server
repeated DestinationGroup destinations = 2 [deprecated = true];
// rule route chain
repeated SubRuleRouting rules = 3;
}
// SubRuleRouting sub routing configuration
message SubRuleRouting {
// sub routing rule name
string name = 1;
// source source info
repeated SourceService sources = 2;
// destination destinations info
repeated DestinationGroup destinations = 3;
}
message SourceService {
// Main tuning service and namespace
string service = 1;
string namespace = 2;
// Master Control Service Example Tag or Request Label
// Value supports regular matching
repeated SourceMatch arguments = 3;
}
message DestinationGroup {
// Templated service and namespace
string service = 1;
string namespace = 2;
// Templated service example label
// Value supports regular matching
map<string, MatchString> labels = 3;
// According to the service name and service instance Metadata Filter the
// qualified service instance subset Service instance subset can set priority
// and weight Priority: integer, range [0, 9], the highest priority is 0
// Weight: Integer
// Press priority routing, if there is high priority, low priority will not
// use If there is a subset of the same priority, then assign by weight
// Priority and weight can be not set / set up one / set two
// If the section is set priority, some are not set, it is considered that the
// priority is not set. If the part is set, some is not set, it is considered
// that the weight is not set to 0 If you have no weight, you think the weight
// is the same
uint32 priority = 4;
uint32 weight = 5;
// Forward requests to proxy service
string transfer = 6;
// Whether to isolate the SET, after isolation, no traffic will be allocated
bool isolate = 7;
// name desition name
string name = 8;
}
// SourceMatch
message SourceMatch {
// label type for gateway request
enum Type {
// custom arguments
CUSTOM = 0;
// method, match the http post/get/put/delete or grpc method
METHOD = 1;
// header, match the http header, dubbo attachment, grpc header
HEADER = 2;
// query, match the http query, dubbo argument
QUERY = 3;
// caller host ip
CALLER_IP = 4;
// path, math the http url
PATH = 5;
// cookie match http cookie
COOKIE = 6;
// indicate the caller instance metadata
CALLER_METADATA = 7;
}
Type type = 1;
// header key or query key
string key = 2;
// header value or query value
MatchString value = 3;
}