-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages.proto
124 lines (101 loc) · 2.11 KB
/
messages.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
syntax = "proto3";
// used in production: YES
// messages should not be deleted and
// field numbers should not be changed anymore.
package loon;
import "google/protobuf/timestamp.proto";
option go_package = "/pb";
// Preparation
message Constraints {
uint64 chunk_size = 1;
uint64 max_content_size = 2;
repeated string accepted_content_types = 3;
uint32 cache_duration = 4;
}
// <-
message Hello {
string base_url = 1;
string client_id = 2;
bytes connection_secret = 3;
Constraints constraints = 4;
}
// Requests
// <-
message Request {
uint64 id = 1;
google.protobuf.Timestamp timestamp = 2;
string path = 3;
}
// Responses
// ->
message EmptyResponse {
uint64 request_id = 1;
}
// ->
message ContentHeader {
uint64 request_id = 1;
string content_type = 2;
uint64 content_size = 3;
optional uint32 max_cache_duration = 4;
optional string filename = 5;
}
// ->
message ContentChunk {
uint64 request_id = 1;
uint64 sequence = 2;
bytes data = 3;
}
// Events
// <-
message Success {
uint64 request_id = 1;
}
// <-
message RequestClosed {
uint64 request_id = 1;
string message = 2;
}
// ->
message CloseResponse {
uint64 request_id = 1;
}
// Error handling
// <-
// Close message, which is sent right before the server closes the session.
message Close {
enum Reason {
REASON_UNSPECIFIED = 0;
REASON_CLOSED = 1;
REASON_ERROR = 2;
REASON_INVALID_CLIENT_MESSAGE = 3;
REASON_INVALID_REQUEST_ID = 4;
REASON_FORBIDDEN_CONTENT_TYPE = 5;
REASON_INVALID_CONTENT_SIZE = 6;
REASON_CONTENT_CHUNK_OUT_OF_SEQUENCE = 7;
REASON_INVALID_CHUNK_SIZE = 8;
REASON_INVALID_FILENAME = 9;
REASON_TIMED_OUT = 10;
}
Reason reason = 1;
string message = 2;
}
// Message encapsulation
// ->
message ClientMessage {
oneof data {
EmptyResponse empty_response = 1;
ContentHeader content_header = 2;
ContentChunk content_chunk = 3;
CloseResponse close_response = 4;
}
}
// <-
message ServerMessage {
oneof data {
Hello hello = 1;
Request request = 2;
Success success = 3;
RequestClosed request_closed = 4;
Close close = 5;
}
}