-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathendpoint.proto
201 lines (189 loc) · 7.67 KB
/
endpoint.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
syntax = "proto3";
package begonia.org.sdk;
option go_package = "github.com/begonia-org/go-sdk/endpoint/api/v1";
import "google/protobuf/descriptor.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
import "google/protobuf/field_mask.proto";
import "begonia/api/v1/options.proto";
enum EndpointStatus{
ENABLED = 0;
DISABLED = 1;
}
enum EndpointSvrStatus{
ENDPOINT_UNKNOW = 0;
NOT_SUPPORT_BALANCE = 7101[(.begonia.api.v1.msg) = "Not support balance"];
SERVICE_NAME_DUPLICATE = 7102[(.begonia.api.v1.msg) = "Service name duplicate"];
ENDPOINT_NOT_FOUND = 7103[(.begonia.api.v1.msg) = "Endpoint not found"];
}
message EndpointMeta {
// @gotags: json:"addr" gorm:"column:addr;type:varchar(128);comment:服务地址"
string addr =1;
// @gotags: json:"weight" gorm:"column:weight;type:int;comment:服务权重"
int32 weight =2;
}
message Endpoints{
// @gotags: doc:"历史ID" gorm:"primaryKey;autoIncrement;comment:自增id"
int64 id=1;
// @gotags: json:"name" gorm:"column:name;type:varchar(128);unique;comment:服务名称"
string name=2;
// @gotags: json:"uid" primary:"unique_key" gorm:"column:unique_key;type:varchar(128);unique;comment:服务key"
string key=3;
// @gotags: json:"group" owner:"owner" gorm:"column:group;type:varchar(36);comment:group"
string owner = 17;
// @gotags: json:"service_name" gorm:"column:service_name;type:varchar(128);unique;comment:proto服务名称"
string service_name=4 [json_name="service_name"];
// @gotags: json:"description" gorm:"column:description;type:text;comment:proto服务描述"
string description=5;
// @gotags: json:"proto_path" gorm:"column:proto_path;type:varchar(512);comment:proto文件路径"
string proto_path=7 [json_name="proto_path"];
// @gotags: json:"endpoints" gorm:"column:endpoint;type:json;comment:proto服务对应的endpoint 服务地址"
repeated EndpointMeta endpoints=8[json_name="endpoints"];
// @gotags: json:"status" gorm:"column:status;type:tinyint;comment:proto服务状态"
EndpointStatus status=9 [json_name="status"];
// @gotags: json:"is_deleted" gorm:"column:is_deleted;type:tinyint;comment:proto服务是否删除"
bool is_deleted=10 [json_name="is_deleted"];
// @gotags: json:"balance" gorm:"column:balance;type:varchar(32);comment:负载均衡策略"
string balance=11;
// @gotags: json:"version" gorm:"column:version;type:varchar(32);comment:版本号"
string version=12;
// @gotags: json:"descriptor_set" gorm:"-"
bytes descriptor_set=16 [json_name="descriptor_set"];
// @gotags: json:"tags" gorm:"column:tags;type:json;comment:proto服务对应的endpoint tags"
repeated string tags=15;
// @gotags: doc:"完成时间" gorm:"column:completed_at;type:datetime;serializer:timepb;comment:定时任务的最近一次完成时间"
string created_at = 13;
// @gotags: doc:"更新时间" gorm:"column:updated_at;type:datetime;serializer:timepb;comment:定时任务的更新时间"
string updated_at = 14;
// @gotags: gorm:"-" json:"update_mask"
google.protobuf.FieldMask update_mask = 18;
}
message AddEndpointRequest{
// Endpoints endpoints=1;
// @gotags: json:"name" gorm:"column:name;type:varchar(128);unique;comment:服务名称"
string name=1;
// @gotags: json:"service_name" gorm:"column:service_name;type:varchar(128);unique;comment:proto服务名称"
string service_name=2 [json_name="service_name"];
string description=3;
string proto_path=4 [json_name="proto_path"];
repeated EndpointMeta endpoints=5;
string balance=6;
repeated string tags=7;
string proto_version=8 [json_name="proto_version"];
}
message UpdateEndpointRequest{
// Endpoints endpoints=1;
// @gotags: json:"name" gorm:"column:name;type:varchar(128);unique;comment:服务名称"
string name=1;
// @gotags: json:"service_name" gorm:"column:service_name;type:varchar(128);unique;comment:proto服务名称"
string service_name=2 [json_name="service_name"];
string description=3;
string proto_path=4 [json_name="proto_path"];
repeated EndpointMeta endpoint=5;
string balance=6;
string unique_key = 7[json_name="unique_key"];
EndpointStatus status=9 [json_name="status"];
// @gotags: json:"is_deleted" gorm:"column:is_deleted;type:tinyint;comment:proto服务是否删除"
bool is_deleted=10 [json_name="is_deleted"];
repeated string tags=11;
string version=12;
}
// message UpdateEndpointResponse{
// }
message AddEndpointResponse{
string unique_key=1 [json_name="unique_key"];
}
message DeleteEndpointRequest{
// @gotags: json:"unique_key" gorm:"column:unique_key;type:varchar(128);unique;comment:服务key"
string unique_key=1[json_name="unique_key"];
}
message DeleteEndpointResponse{
}
message ListEndpointRequest{
repeated string tags=1;
repeated string unique_keys=2 [json_name="unique_keys"];
}
message ListEndpointResponse{
repeated Endpoints endpoints=1;
}
message DetailsEndpointRequest{
// @gotags: validate:"required" json:"unique_key" gorm:"column:unique_key;type:varchar(128);unique;comment:服务key"
string unique_key=1;
}
message DetailsEndpointResponse{
Endpoints endpoints=1;
}
message EndpointSrvConfig {
bytes descriptor_set=1 [json_name="descriptor_set"];
// @gotags: validate:"required"
string name=2 ;
// @gotags: validate:"required" json:"service_name" gorm:"column:service_name;type:varchar(128);unique;comment:proto服务名称"
string service_name=3 [json_name="service_name"];
string description=4;
repeated EndpointMeta endpoints=6;
// @gotags: validate:"required,oneof=RR WRR LC WLC CH SED NQ"
string balance=7;
repeated string tags=8;
}
message EndpointSrvUpdateRequest{
string unique_key=9[json_name="unique_key",(.begonia.api.v1.un_updatable)=true];
bytes descriptor_set=1 [json_name="descriptor_set"];
string name=2;
string description=4;
repeated EndpointMeta endpoints=6;
// @gotags: validate:"oneof=RR WRR LC WLC CH SED NQ"
string balance=7;
repeated string tags=8;
google.protobuf.FieldMask update_mask = 18[json_name="update_mask"];
}
message UpdateEndpointResponse{
string version=1;
google.protobuf.Timestamp updated_at=2[json_name="updated_at"];
}
message SrvEndpoints{
string unique_key=1[json_name="unique_key"];
repeated EndpointMeta endpoints=2;
}
message SrvDescriptorSet{
string unique_key=1[json_name="unique_key"];
bytes descriptor_set=2;
}
message SvrLoadBalance{
string unique_key=1[json_name="unique_key"];
string balance=2;
}
message SvrStatus{
string unique_key=1[json_name="unique_key"];
EndpointSvrStatus status=2;
}
service EndpointService{
option (.begonia.api.v1.auth_reqiured)=true;
option (.begonia.api.v1.http_response)="begonia.api.v1.HttpResponse";
rpc Post(EndpointSrvConfig) returns (AddEndpointResponse){
option (google.api.http) = {
post: "/api/v1/endpoints"
body: "*"
};
};
rpc Update(EndpointSrvUpdateRequest) returns (UpdateEndpointResponse){
option (google.api.http) = {
put: "/api/v1/endpoints/{unique_key}"
body: "*"
};
};
rpc Delete(DeleteEndpointRequest) returns (DeleteEndpointResponse){
option (google.api.http) = {
delete: "/api/v1/endpoints/{unique_key}"
};
};
rpc List(ListEndpointRequest) returns (ListEndpointResponse){
option (google.api.http) = {
get: "/api/v1/endpoints"
};
};
rpc Get(DetailsEndpointRequest) returns (DetailsEndpointResponse){
option (google.api.http) = {
get: "/api/v1/endpoints/{unique_key}"
};
};
}