-
-
Notifications
You must be signed in to change notification settings - Fork 614
/
Copy pathproxy.proto
292 lines (248 loc) · 7.29 KB
/
proxy.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
280
281
282
283
284
285
286
287
288
289
290
291
292
syntax = "proto3";
package centrifugal.centrifugo.proxy;
option go_package = "./;proxyproto";
service CentrifugoProxy {
// Connect to proxy connection authentication and communicate initial state.
rpc Connect(ConnectRequest) returns (ConnectResponse);
// Refresh to proxy decision about connection expiration to the app backend.
rpc Refresh(RefreshRequest) returns (RefreshResponse);
// Subscribe to proxy subscription attempts to channels.
rpc Subscribe(SubscribeRequest) returns (SubscribeResponse);
// Publish to proxy publication attempts to channels.
rpc Publish(PublishRequest) returns (PublishResponse);
// RPC to execute custom logic on the backend over request through the real-time connection.
rpc RPC(RPCRequest) returns (RPCResponse);
// SubRefresh to proxy decision about subscription expiration to the app backend.
rpc SubRefresh(SubRefreshRequest) returns (SubRefreshResponse);
// SubscribeUnidirectional is an EXPERIMENTAL method which allows handling unidirectional
// subscription streams. Stream starts with SubscribeRequest similar to Subscribe rpc,
// then expects StreamSubscribeResponse with SubscribeResponse as first message, and
// StreamSubscribeResponse with Publication afterwards.
rpc SubscribeUnidirectional(SubscribeRequest) returns (stream StreamSubscribeResponse);
// SubscribeBidirectional is an EXPERIMENTAL method which allows handling bidirectional
// subscription streams. Stream receives StreamSubscribeRequest. First StreamSubscribeRequest
// always contains SubscribeRequest, then StreamSubscribeRequest will contain data published
// by client. Reverse direction works the same way as in SubscribeUnidirectional.
rpc SubscribeBidirectional(stream StreamSubscribeRequest) returns (stream StreamSubscribeResponse);
// NotifyCacheEmpty is an EXPERIMENTAL method which allows to load documents from the backend.
rpc NotifyCacheEmpty(NotifyCacheEmptyRequest) returns (NotifyCacheEmptyResponse);
// NotifyChannelState can be used to receive channel events such as channel "occupied" and "vacated".
// This is a feature in a preview state and is only available in Centrifugo PRO.
rpc NotifyChannelState(NotifyChannelStateRequest) returns (NotifyChannelStateResponse);
}
message Disconnect {
reserved 3;
uint32 code = 1;
string reason = 2;
}
message Error {
uint32 code = 1;
string message = 2;
bool temporary = 3;
}
message ConnectRequest {
string client = 1;
string transport = 2;
string protocol = 3;
string encoding = 4;
bytes data = 10;
string b64data = 11;
string name = 12;
string version = 13;
repeated string channels = 14;
}
message SubscribeOptions {
int64 expire_at = 1;
bytes info = 2;
string b64info = 3;
bytes data = 4;
string b64data = 5;
SubscribeOptionOverride override = 6;
}
message ConnectResult {
string user = 1;
int64 expire_at = 2;
bytes info = 3;
string b64info = 4;
bytes data = 5;
string b64data = 6;
repeated string channels = 7;
map<string, SubscribeOptions> subs = 8;
bytes meta = 9;
repeated ChannelsCapability caps = 10;
}
message ChannelsCapability {
repeated string channels = 1;
repeated string allow = 2;
string match = 3;
}
message ConnectResponse {
ConnectResult result = 1;
Error error = 2;
Disconnect disconnect = 3;
}
message RefreshRequest {
string client = 1;
string transport = 2;
string protocol = 3;
string encoding = 4;
string user = 10;
bytes meta = 11;
}
message RefreshResult {
bool expired = 1;
int64 expire_at = 2;
bytes info = 3;
string b64info = 4;
bytes meta = 5;
repeated ChannelsCapability caps = 6;
}
message RefreshResponse {
RefreshResult result = 1;
Error error = 2;
Disconnect disconnect = 3;
}
message SubscribeRequest {
string client = 1;
string transport = 2;
string protocol = 3;
string encoding = 4;
string user = 10;
string channel = 11;
string token = 12;
bytes meta = 13;
bytes data = 14;
string b64data = 15;
}
message BoolValue {
bool value = 1;
}
message Int32Value {
int32 value = 1;
}
message SubscribeOptionOverride {
BoolValue presence = 1;
BoolValue join_leave = 2;
BoolValue force_recovery = 3;
BoolValue force_positioning = 4;
BoolValue force_push_join_leave = 5;
}
message SubscribeResult {
int64 expire_at = 1;
bytes info = 2;
string b64info = 3;
bytes data = 4;
string b64data = 5;
SubscribeOptionOverride override = 6;
repeated string allow = 7;
}
message SubscribeResponse {
SubscribeResult result = 1;
Error error = 2;
Disconnect disconnect = 3;
}
message PublishRequest {
string client = 1;
string transport = 2;
string protocol = 3;
string encoding = 4;
string user = 10;
string channel = 11;
bytes data = 12;
string b64data = 13;
bytes meta = 14;
}
message PublishResult {
bytes data = 1;
string b64data = 2;
bool skip_history = 3;
}
message PublishResponse {
PublishResult result = 1;
Error error = 2;
Disconnect disconnect = 3;
}
message RPCRequest {
string client = 1;
string transport = 2;
string protocol = 3;
string encoding = 4;
string user = 10;
string method = 11;
bytes data = 12;
string b64data = 13;
bytes meta = 14;
}
message RPCResult {
bytes data = 1;
string b64data = 2;
}
message RPCResponse {
RPCResult result = 1;
Error error = 2;
Disconnect disconnect = 3;
}
message SubRefreshRequest {
string client = 1;
string transport = 2;
string protocol = 3;
string encoding = 4;
string user = 10;
string channel = 11;
bytes meta = 12;
}
message SubRefreshResult {
bool expired = 1;
int64 expire_at = 2;
bytes info = 3;
string b64info = 4;
}
message SubRefreshResponse {
SubRefreshResult result = 1;
Error error = 2;
Disconnect disconnect = 3;
}
// Publication is an event to be sent to a client.
// We intentionally make it use the same Protobuf numbers for fields as our client protocol
// Publication - for now only for consistency.
message Publication {
reserved 1, 2, 3, 5, 6;
bytes data = 4;
map<string, string> tags = 7;
}
message StreamSubscribeRequest {
// Centrifugo always sends this within the first message upon user subscription request.
// It's always not set in the following StreamRequest messages from Centrifugo.
SubscribeRequest subscribe_request = 1;
// Publication may be set when client publishes to the on-demand stream. If you are using
// bidirectional stream then Centrifugo assumes publications from client-side are allowed.
Publication publication = 2;
}
message StreamSubscribeResponse {
// SubscribeResponse may optionally be set in the first message from backend to Centrifugo.
SubscribeResponse subscribe_response = 1;
// Publication goes to client. Can't be set in the first message from backend to Centrifugo.
Publication publication = 2;
}
message NotifyCacheEmptyRequest {
string channel = 1;
}
message NotifyCacheEmptyResponse {
NotifyCacheEmptyResult result = 1;
}
message NotifyCacheEmptyResult {
bool populated = 1;
}
message NotifyChannelStateRequest {
repeated ChannelEvent events = 1;
}
message ChannelEvent {
int64 time_ms = 1;
string channel = 2;
string type = 3; // "occupied" | "vacated" | could be more in the future. Not using enums for better JSON interop.
}
message NotifyChannelStateResponse {
NotifyChannelStateResult result = 1;
Error error = 2;
}
message NotifyChannelStateResult {}