forked from aeraki-mesh/meta-protocol-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thrift.h
179 lines (152 loc) · 3.69 KB
/
thrift.h
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
#pragma once
#include "source/common/common/assert.h"
#include "source/common/singleton/const_singleton.h"
namespace Envoy {
namespace Extensions {
namespace NetworkFilters {
namespace ThriftProxy {
enum class TransportType {
Framed,
Header,
Unframed,
Auto,
// ATTENTION: MAKE SURE THIS REMAINS EQUAL TO THE LAST TRANSPORT TYPE
LastTransportType = Auto,
};
/**
* Names of available Transport implementations.
*/
class TransportNameValues {
public:
// Framed transport
const std::string FRAMED = "framed";
// Header transport
const std::string HEADER = "header";
// Unframed transport
const std::string UNFRAMED = "unframed";
// Auto-detection transport
const std::string AUTO = "auto";
const std::string& fromType(TransportType type) const {
switch (type) {
case TransportType::Framed:
return FRAMED;
case TransportType::Header:
return HEADER;
case TransportType::Unframed:
return UNFRAMED;
case TransportType::Auto:
return AUTO;
}
PANIC_DUE_TO_CORRUPT_ENUM;
}
};
using TransportNames = ConstSingleton<TransportNameValues>;
enum class ProtocolType {
Binary,
LaxBinary,
Compact,
Twitter,
Auto,
// ATTENTION: MAKE SURE THIS REMAINS EQUAL TO THE LAST PROTOCOL TYPE
LastProtocolType = Auto,
};
/**
* Names of available Protocol implementations.
*/
class ProtocolNameValues {
public:
// Binary protocol
const std::string BINARY = "binary";
// Lax Binary protocol
const std::string LAX_BINARY = "binary/non-strict";
// Compact protocol
const std::string COMPACT = "compact";
// Twitter protocol
const std::string TWITTER = "twitter";
// Auto-detection protocol
const std::string AUTO = "auto";
const std::string& fromType(ProtocolType type) const {
switch (type) {
case ProtocolType::Binary:
return BINARY;
case ProtocolType::LaxBinary:
return LAX_BINARY;
case ProtocolType::Compact:
return COMPACT;
case ProtocolType::Twitter:
return TWITTER;
case ProtocolType::Auto:
return AUTO;
}
PANIC_DUE_TO_CORRUPT_ENUM;
}
};
using ProtocolNames = ConstSingleton<ProtocolNameValues>;
/**
* Thrift protocol message types.
* See https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/protocol/TProtocol.h
*/
enum class MessageType {
Call = 1,
Reply = 2,
Exception = 3,
Oneway = 4,
// ATTENTION: MAKE SURE THIS REMAINS EQUAL TO THE LAST MESSAGE TYPE
LastMessageType = Oneway,
};
/**
* A Reply message is either a success or an error (IDL exception)
*/
enum class ReplyType {
Success,
Error,
};
/**
* Thrift protocol struct field types.
* See https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/protocol/TProtocol.h
*/
enum class FieldType {
Stop = 0,
Void = 1,
Bool = 2,
Byte = 3,
Double = 4,
I16 = 6,
I32 = 8,
I64 = 10,
String = 11,
Struct = 12,
Map = 13,
Set = 14,
List = 15,
// ATTENTION: MAKE SURE THIS REMAINS EQUAL TO THE LAST FIELD TYPE
LastFieldType = List,
};
/**
* Thrift Application Exception types.
* See https://github.com/apache/thrift/blob/master/doc/specs/thrift-rpc.md
*/
enum class AppExceptionType {
Unknown = 0,
UnknownMethod = 1,
InvalidMessageType = 2,
WrongMethodName = 3,
BadSequenceId = 4,
MissingResult = 5,
InternalError = 6,
ProtocolError = 7,
InvalidTransform = 8,
InvalidProtocol = 9,
// FBThrift values.
// See https://github.com/facebook/fbthrift/blob/master/thrift/lib/cpp/TApplicationException.h#L52
UnsupportedClientType = 10,
LoadShedding = 11,
Timeout = 12,
InjectedFailure = 13,
ChecksumMismatch = 14,
Interruption = 15,
};
} // namespace ThriftProxy
} // namespace NetworkFilters
} // namespace Extensions
} // namespace Envoy