thrift 0.10.0.0 → 0.11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/benchmark/gen-rb/benchmark_constants.rb +11 -0
- data/benchmark/gen-rb/benchmark_service.rb +80 -0
- data/benchmark/gen-rb/benchmark_types.rb +10 -0
- data/lib/thrift/processor.rb +10 -1
- data/lib/thrift/protocol/json_protocol.rb +1 -1
- data/spec/gen-rb/base/base_service.rb +80 -0
- data/spec/gen-rb/base/base_service_constants.rb +11 -0
- data/spec/gen-rb/base/base_service_types.rb +26 -0
- data/spec/gen-rb/extended/extended_service.rb +78 -0
- data/spec/gen-rb/extended/extended_service_constants.rb +11 -0
- data/spec/gen-rb/extended/extended_service_types.rb +12 -0
- data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +272 -0
- data/spec/gen-rb/flat/referenced_constants.rb +11 -0
- data/spec/gen-rb/flat/referenced_types.rb +17 -0
- data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +11 -0
- data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +28 -0
- data/spec/gen-rb/namespaced_spec_namespace/namespaced_nonblocking_service.rb +272 -0
- data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +11 -0
- data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +28 -0
- data/spec/gen-rb/nonblocking_service.rb +272 -0
- data/spec/gen-rb/other_namespace/referenced_constants.rb +11 -0
- data/spec/gen-rb/other_namespace/referenced_types.rb +17 -0
- data/spec/gen-rb/thrift_spec_constants.rb +11 -0
- data/spec/gen-rb/thrift_spec_types.rb +538 -0
- data/spec/server_spec.rb +1 -0
- data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +278 -0
- data/test/debug_proto/gen-rb/debug_proto_test_types.rb +781 -0
- data/test/debug_proto/gen-rb/empty_service.rb +28 -0
- data/test/debug_proto/gen-rb/inherited.rb +83 -0
- data/test/debug_proto/gen-rb/reverse_order_service.rb +86 -0
- data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +85 -0
- data/test/debug_proto/gen-rb/srv.rb +395 -0
- metadata +132 -75
data/spec/server_spec.rb
CHANGED
@@ -0,0 +1,278 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (0.11.0)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
require 'debug_proto_test_types'
|
9
|
+
|
10
|
+
module Thrift
|
11
|
+
module Test
|
12
|
+
COMPACT_TEST = ::Thrift::Test::CompactProtoTestStruct.new({
|
13
|
+
%q"a_byte" => 127,
|
14
|
+
%q"a_i16" => 32000,
|
15
|
+
%q"a_i32" => 1000000000,
|
16
|
+
%q"a_i64" => 1099511627775,
|
17
|
+
%q"a_double" => 5.6789,
|
18
|
+
%q"a_string" => %q"my string",
|
19
|
+
%q"true_field" => true,
|
20
|
+
%q"false_field" => false,
|
21
|
+
%q"empty_struct_field" => ::Thrift::Test::Empty.new({
|
22
|
+
}),
|
23
|
+
%q"byte_list" => [
|
24
|
+
-127,
|
25
|
+
-1,
|
26
|
+
0,
|
27
|
+
1,
|
28
|
+
127,
|
29
|
+
],
|
30
|
+
%q"i16_list" => [
|
31
|
+
-1,
|
32
|
+
0,
|
33
|
+
1,
|
34
|
+
32767,
|
35
|
+
],
|
36
|
+
%q"i32_list" => [
|
37
|
+
-1,
|
38
|
+
0,
|
39
|
+
255,
|
40
|
+
65535,
|
41
|
+
16777215,
|
42
|
+
2147483647,
|
43
|
+
],
|
44
|
+
%q"i64_list" => [
|
45
|
+
-1,
|
46
|
+
0,
|
47
|
+
255,
|
48
|
+
65535,
|
49
|
+
16777215,
|
50
|
+
4294967295,
|
51
|
+
1099511627775,
|
52
|
+
281474976710655,
|
53
|
+
72057594037927935,
|
54
|
+
9223372036854775807,
|
55
|
+
],
|
56
|
+
%q"double_list" => [
|
57
|
+
0.1,
|
58
|
+
0.2,
|
59
|
+
0.3,
|
60
|
+
],
|
61
|
+
%q"string_list" => [
|
62
|
+
%q"first",
|
63
|
+
%q"second",
|
64
|
+
%q"third",
|
65
|
+
],
|
66
|
+
%q"boolean_list" => [
|
67
|
+
true,
|
68
|
+
true,
|
69
|
+
true,
|
70
|
+
false,
|
71
|
+
false,
|
72
|
+
false,
|
73
|
+
],
|
74
|
+
%q"struct_list" => [
|
75
|
+
::Thrift::Test::Empty.new({
|
76
|
+
}),
|
77
|
+
::Thrift::Test::Empty.new({
|
78
|
+
}),
|
79
|
+
],
|
80
|
+
%q"byte_set" => Set.new([
|
81
|
+
-127,
|
82
|
+
-1,
|
83
|
+
0,
|
84
|
+
1,
|
85
|
+
127,
|
86
|
+
]),
|
87
|
+
%q"i16_set" => Set.new([
|
88
|
+
-1,
|
89
|
+
0,
|
90
|
+
1,
|
91
|
+
32767,
|
92
|
+
]),
|
93
|
+
%q"i32_set" => Set.new([
|
94
|
+
1,
|
95
|
+
2,
|
96
|
+
3,
|
97
|
+
]),
|
98
|
+
%q"i64_set" => Set.new([
|
99
|
+
-1,
|
100
|
+
0,
|
101
|
+
255,
|
102
|
+
65535,
|
103
|
+
16777215,
|
104
|
+
4294967295,
|
105
|
+
1099511627775,
|
106
|
+
281474976710655,
|
107
|
+
72057594037927935,
|
108
|
+
9223372036854775807,
|
109
|
+
]),
|
110
|
+
%q"double_set" => Set.new([
|
111
|
+
0.1,
|
112
|
+
0.2,
|
113
|
+
0.3,
|
114
|
+
]),
|
115
|
+
%q"string_set" => Set.new([
|
116
|
+
%q"first",
|
117
|
+
%q"second",
|
118
|
+
%q"third",
|
119
|
+
]),
|
120
|
+
%q"boolean_set" => Set.new([
|
121
|
+
true,
|
122
|
+
false,
|
123
|
+
]),
|
124
|
+
%q"struct_set" => Set.new([
|
125
|
+
::Thrift::Test::Empty.new({
|
126
|
+
}),
|
127
|
+
]),
|
128
|
+
%q"byte_byte_map" => {
|
129
|
+
1 => 2,
|
130
|
+
},
|
131
|
+
%q"i16_byte_map" => {
|
132
|
+
1 => 1,
|
133
|
+
-1 => 1,
|
134
|
+
32767 => 1,
|
135
|
+
},
|
136
|
+
%q"i32_byte_map" => {
|
137
|
+
1 => 1,
|
138
|
+
-1 => 1,
|
139
|
+
2147483647 => 1,
|
140
|
+
},
|
141
|
+
%q"i64_byte_map" => {
|
142
|
+
0 => 1,
|
143
|
+
1 => 1,
|
144
|
+
-1 => 1,
|
145
|
+
9223372036854775807 => 1,
|
146
|
+
},
|
147
|
+
%q"double_byte_map" => {
|
148
|
+
-1.1 => 1,
|
149
|
+
1.1 => 1,
|
150
|
+
},
|
151
|
+
%q"string_byte_map" => {
|
152
|
+
%q"first" => 1,
|
153
|
+
%q"second" => 2,
|
154
|
+
%q"third" => 3,
|
155
|
+
%q"" => 0,
|
156
|
+
},
|
157
|
+
%q"boolean_byte_map" => {
|
158
|
+
true => 1,
|
159
|
+
false => 0,
|
160
|
+
},
|
161
|
+
%q"byte_i16_map" => {
|
162
|
+
1 => 1,
|
163
|
+
2 => -1,
|
164
|
+
3 => 32767,
|
165
|
+
},
|
166
|
+
%q"byte_i32_map" => {
|
167
|
+
1 => 1,
|
168
|
+
2 => -1,
|
169
|
+
3 => 2147483647,
|
170
|
+
},
|
171
|
+
%q"byte_i64_map" => {
|
172
|
+
1 => 1,
|
173
|
+
2 => -1,
|
174
|
+
3 => 9223372036854775807,
|
175
|
+
},
|
176
|
+
%q"byte_double_map" => {
|
177
|
+
1 => 0.1,
|
178
|
+
2 => -0.1,
|
179
|
+
3 => 1e+06,
|
180
|
+
},
|
181
|
+
%q"byte_string_map" => {
|
182
|
+
1 => %q"",
|
183
|
+
2 => %q"blah",
|
184
|
+
3 => %q"loooooooooooooong string",
|
185
|
+
},
|
186
|
+
%q"byte_boolean_map" => {
|
187
|
+
1 => true,
|
188
|
+
2 => false,
|
189
|
+
},
|
190
|
+
%q"list_byte_map" => {
|
191
|
+
[
|
192
|
+
1,
|
193
|
+
2,
|
194
|
+
3,
|
195
|
+
] => 1,
|
196
|
+
[
|
197
|
+
0,
|
198
|
+
1,
|
199
|
+
] => 2,
|
200
|
+
[
|
201
|
+
] => 0,
|
202
|
+
},
|
203
|
+
%q"set_byte_map" => {
|
204
|
+
Set.new([
|
205
|
+
1,
|
206
|
+
2,
|
207
|
+
3,
|
208
|
+
]) => 1,
|
209
|
+
Set.new([
|
210
|
+
0,
|
211
|
+
1,
|
212
|
+
]) => 2,
|
213
|
+
Set.new([
|
214
|
+
]) => 0,
|
215
|
+
},
|
216
|
+
%q"map_byte_map" => {
|
217
|
+
{
|
218
|
+
1 => 1,
|
219
|
+
} => 1,
|
220
|
+
{
|
221
|
+
2 => 2,
|
222
|
+
} => 2,
|
223
|
+
{
|
224
|
+
} => 0,
|
225
|
+
},
|
226
|
+
%q"byte_map_map" => {
|
227
|
+
0 => {
|
228
|
+
},
|
229
|
+
1 => {
|
230
|
+
1 => 1,
|
231
|
+
},
|
232
|
+
2 => {
|
233
|
+
1 => 1,
|
234
|
+
2 => 2,
|
235
|
+
},
|
236
|
+
},
|
237
|
+
%q"byte_set_map" => {
|
238
|
+
0 => Set.new([
|
239
|
+
]),
|
240
|
+
1 => Set.new([
|
241
|
+
1,
|
242
|
+
]),
|
243
|
+
2 => Set.new([
|
244
|
+
1,
|
245
|
+
2,
|
246
|
+
]),
|
247
|
+
},
|
248
|
+
%q"byte_list_map" => {
|
249
|
+
0 => [
|
250
|
+
],
|
251
|
+
1 => [
|
252
|
+
1,
|
253
|
+
],
|
254
|
+
2 => [
|
255
|
+
1,
|
256
|
+
2,
|
257
|
+
],
|
258
|
+
},
|
259
|
+
})
|
260
|
+
|
261
|
+
MYCONST = 2
|
262
|
+
|
263
|
+
MY_SOME_ENUM = 1
|
264
|
+
|
265
|
+
MY_SOME_ENUM_1 = 1
|
266
|
+
|
267
|
+
MY_ENUM_MAP = {
|
268
|
+
1 => 2,
|
269
|
+
}
|
270
|
+
|
271
|
+
EXTRA_CRAZY_MAP = {
|
272
|
+
1 => ::Thrift::Test::StructWithSomeEnum.new({
|
273
|
+
%q"blah" => 2,
|
274
|
+
}),
|
275
|
+
}
|
276
|
+
|
277
|
+
end
|
278
|
+
end
|
@@ -0,0 +1,781 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (0.11.0)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
|
9
|
+
module Thrift
|
10
|
+
module Test
|
11
|
+
module SomeEnum
|
12
|
+
ONE = 1
|
13
|
+
TWO = 2
|
14
|
+
VALUE_MAP = {1 => "ONE", 2 => "TWO"}
|
15
|
+
VALID_VALUES = Set.new([ONE, TWO]).freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
class Doubles
|
19
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
20
|
+
NAN = 1
|
21
|
+
INF = 2
|
22
|
+
NEGINF = 3
|
23
|
+
REPEATING = 4
|
24
|
+
BIG = 5
|
25
|
+
TINY = 6
|
26
|
+
ZERO = 7
|
27
|
+
NEGZERO = 8
|
28
|
+
|
29
|
+
FIELDS = {
|
30
|
+
NAN => {:type => ::Thrift::Types::DOUBLE, :name => 'nan'},
|
31
|
+
INF => {:type => ::Thrift::Types::DOUBLE, :name => 'inf'},
|
32
|
+
NEGINF => {:type => ::Thrift::Types::DOUBLE, :name => 'neginf'},
|
33
|
+
REPEATING => {:type => ::Thrift::Types::DOUBLE, :name => 'repeating'},
|
34
|
+
BIG => {:type => ::Thrift::Types::DOUBLE, :name => 'big'},
|
35
|
+
TINY => {:type => ::Thrift::Types::DOUBLE, :name => 'tiny'},
|
36
|
+
ZERO => {:type => ::Thrift::Types::DOUBLE, :name => 'zero'},
|
37
|
+
NEGZERO => {:type => ::Thrift::Types::DOUBLE, :name => 'negzero'}
|
38
|
+
}
|
39
|
+
|
40
|
+
def struct_fields; FIELDS; end
|
41
|
+
|
42
|
+
def validate
|
43
|
+
end
|
44
|
+
|
45
|
+
::Thrift::Struct.generate_accessors self
|
46
|
+
end
|
47
|
+
|
48
|
+
class OneOfEach
|
49
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
50
|
+
IM_TRUE = 1
|
51
|
+
IM_FALSE = 2
|
52
|
+
A_BITE = 3
|
53
|
+
INTEGER16 = 4
|
54
|
+
INTEGER32 = 5
|
55
|
+
INTEGER64 = 6
|
56
|
+
DOUBLE_PRECISION = 7
|
57
|
+
SOME_CHARACTERS = 8
|
58
|
+
ZOMG_UNICODE = 9
|
59
|
+
WHAT_WHO = 10
|
60
|
+
BASE64 = 11
|
61
|
+
BYTE_LIST = 12
|
62
|
+
I16_LIST = 13
|
63
|
+
I64_LIST = 14
|
64
|
+
|
65
|
+
FIELDS = {
|
66
|
+
IM_TRUE => {:type => ::Thrift::Types::BOOL, :name => 'im_true'},
|
67
|
+
IM_FALSE => {:type => ::Thrift::Types::BOOL, :name => 'im_false'},
|
68
|
+
A_BITE => {:type => ::Thrift::Types::BYTE, :name => 'a_bite', :default => 127},
|
69
|
+
INTEGER16 => {:type => ::Thrift::Types::I16, :name => 'integer16', :default => 32767},
|
70
|
+
INTEGER32 => {:type => ::Thrift::Types::I32, :name => 'integer32'},
|
71
|
+
INTEGER64 => {:type => ::Thrift::Types::I64, :name => 'integer64', :default => 10000000000},
|
72
|
+
DOUBLE_PRECISION => {:type => ::Thrift::Types::DOUBLE, :name => 'double_precision'},
|
73
|
+
SOME_CHARACTERS => {:type => ::Thrift::Types::STRING, :name => 'some_characters'},
|
74
|
+
ZOMG_UNICODE => {:type => ::Thrift::Types::STRING, :name => 'zomg_unicode'},
|
75
|
+
WHAT_WHO => {:type => ::Thrift::Types::BOOL, :name => 'what_who'},
|
76
|
+
BASE64 => {:type => ::Thrift::Types::STRING, :name => 'base64', :binary => true},
|
77
|
+
BYTE_LIST => {:type => ::Thrift::Types::LIST, :name => 'byte_list', :default => [
|
78
|
+
1,
|
79
|
+
2,
|
80
|
+
3,
|
81
|
+
], :element => {:type => ::Thrift::Types::BYTE}},
|
82
|
+
I16_LIST => {:type => ::Thrift::Types::LIST, :name => 'i16_list', :default => [
|
83
|
+
1,
|
84
|
+
2,
|
85
|
+
3,
|
86
|
+
], :element => {:type => ::Thrift::Types::I16}},
|
87
|
+
I64_LIST => {:type => ::Thrift::Types::LIST, :name => 'i64_list', :default => [
|
88
|
+
1,
|
89
|
+
2,
|
90
|
+
3,
|
91
|
+
], :element => {:type => ::Thrift::Types::I64}}
|
92
|
+
}
|
93
|
+
|
94
|
+
def struct_fields; FIELDS; end
|
95
|
+
|
96
|
+
def validate
|
97
|
+
end
|
98
|
+
|
99
|
+
::Thrift::Struct.generate_accessors self
|
100
|
+
end
|
101
|
+
|
102
|
+
class Bonk
|
103
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
104
|
+
TYPE = 1
|
105
|
+
MESSAGE = 2
|
106
|
+
|
107
|
+
FIELDS = {
|
108
|
+
TYPE => {:type => ::Thrift::Types::I32, :name => 'type'},
|
109
|
+
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
|
110
|
+
}
|
111
|
+
|
112
|
+
def struct_fields; FIELDS; end
|
113
|
+
|
114
|
+
def validate
|
115
|
+
end
|
116
|
+
|
117
|
+
::Thrift::Struct.generate_accessors self
|
118
|
+
end
|
119
|
+
|
120
|
+
class Nesting
|
121
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
122
|
+
MY_BONK = 1
|
123
|
+
MY_OOE = 2
|
124
|
+
|
125
|
+
FIELDS = {
|
126
|
+
MY_BONK => {:type => ::Thrift::Types::STRUCT, :name => 'my_bonk', :class => ::Thrift::Test::Bonk},
|
127
|
+
MY_OOE => {:type => ::Thrift::Types::STRUCT, :name => 'my_ooe', :class => ::Thrift::Test::OneOfEach}
|
128
|
+
}
|
129
|
+
|
130
|
+
def struct_fields; FIELDS; end
|
131
|
+
|
132
|
+
def validate
|
133
|
+
end
|
134
|
+
|
135
|
+
::Thrift::Struct.generate_accessors self
|
136
|
+
end
|
137
|
+
|
138
|
+
class HolyMoley
|
139
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
140
|
+
BIG = 1
|
141
|
+
CONTAIN = 2
|
142
|
+
BONKS = 3
|
143
|
+
|
144
|
+
FIELDS = {
|
145
|
+
BIG => {:type => ::Thrift::Types::LIST, :name => 'big', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Thrift::Test::OneOfEach}},
|
146
|
+
CONTAIN => {:type => ::Thrift::Types::SET, :name => 'contain', :element => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRING}}},
|
147
|
+
BONKS => {:type => ::Thrift::Types::MAP, :name => 'bonks', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => ::Thrift::Test::Bonk}}}
|
148
|
+
}
|
149
|
+
|
150
|
+
def struct_fields; FIELDS; end
|
151
|
+
|
152
|
+
def validate
|
153
|
+
end
|
154
|
+
|
155
|
+
::Thrift::Struct.generate_accessors self
|
156
|
+
end
|
157
|
+
|
158
|
+
class Backwards
|
159
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
160
|
+
FIRST_TAG2 = 2
|
161
|
+
SECOND_TAG1 = 1
|
162
|
+
|
163
|
+
FIELDS = {
|
164
|
+
FIRST_TAG2 => {:type => ::Thrift::Types::I32, :name => 'first_tag2'},
|
165
|
+
SECOND_TAG1 => {:type => ::Thrift::Types::I32, :name => 'second_tag1'}
|
166
|
+
}
|
167
|
+
|
168
|
+
def struct_fields; FIELDS; end
|
169
|
+
|
170
|
+
def validate
|
171
|
+
end
|
172
|
+
|
173
|
+
::Thrift::Struct.generate_accessors self
|
174
|
+
end
|
175
|
+
|
176
|
+
class Empty
|
177
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
178
|
+
|
179
|
+
FIELDS = {
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
def struct_fields; FIELDS; end
|
184
|
+
|
185
|
+
def validate
|
186
|
+
end
|
187
|
+
|
188
|
+
::Thrift::Struct.generate_accessors self
|
189
|
+
end
|
190
|
+
|
191
|
+
class Wrapper
|
192
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
193
|
+
FOO = 1
|
194
|
+
|
195
|
+
FIELDS = {
|
196
|
+
FOO => {:type => ::Thrift::Types::STRUCT, :name => 'foo', :class => ::Thrift::Test::Empty}
|
197
|
+
}
|
198
|
+
|
199
|
+
def struct_fields; FIELDS; end
|
200
|
+
|
201
|
+
def validate
|
202
|
+
end
|
203
|
+
|
204
|
+
::Thrift::Struct.generate_accessors self
|
205
|
+
end
|
206
|
+
|
207
|
+
class RandomStuff
|
208
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
209
|
+
A = 1
|
210
|
+
B = 2
|
211
|
+
C = 3
|
212
|
+
D = 4
|
213
|
+
MYINTLIST = 5
|
214
|
+
MAPS = 6
|
215
|
+
BIGINT = 7
|
216
|
+
TRIPLE = 8
|
217
|
+
|
218
|
+
FIELDS = {
|
219
|
+
A => {:type => ::Thrift::Types::I32, :name => 'a'},
|
220
|
+
B => {:type => ::Thrift::Types::I32, :name => 'b'},
|
221
|
+
C => {:type => ::Thrift::Types::I32, :name => 'c'},
|
222
|
+
D => {:type => ::Thrift::Types::I32, :name => 'd'},
|
223
|
+
MYINTLIST => {:type => ::Thrift::Types::LIST, :name => 'myintlist', :element => {:type => ::Thrift::Types::I32}},
|
224
|
+
MAPS => {:type => ::Thrift::Types::MAP, :name => 'maps', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRUCT, :class => ::Thrift::Test::Wrapper}},
|
225
|
+
BIGINT => {:type => ::Thrift::Types::I64, :name => 'bigint'},
|
226
|
+
TRIPLE => {:type => ::Thrift::Types::DOUBLE, :name => 'triple'}
|
227
|
+
}
|
228
|
+
|
229
|
+
def struct_fields; FIELDS; end
|
230
|
+
|
231
|
+
def validate
|
232
|
+
end
|
233
|
+
|
234
|
+
::Thrift::Struct.generate_accessors self
|
235
|
+
end
|
236
|
+
|
237
|
+
class Base64
|
238
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
239
|
+
A = 1
|
240
|
+
B1 = 2
|
241
|
+
B2 = 3
|
242
|
+
B3 = 4
|
243
|
+
B4 = 5
|
244
|
+
B5 = 6
|
245
|
+
B6 = 7
|
246
|
+
|
247
|
+
FIELDS = {
|
248
|
+
A => {:type => ::Thrift::Types::I32, :name => 'a'},
|
249
|
+
B1 => {:type => ::Thrift::Types::STRING, :name => 'b1', :binary => true},
|
250
|
+
B2 => {:type => ::Thrift::Types::STRING, :name => 'b2', :binary => true},
|
251
|
+
B3 => {:type => ::Thrift::Types::STRING, :name => 'b3', :binary => true},
|
252
|
+
B4 => {:type => ::Thrift::Types::STRING, :name => 'b4', :binary => true},
|
253
|
+
B5 => {:type => ::Thrift::Types::STRING, :name => 'b5', :binary => true},
|
254
|
+
B6 => {:type => ::Thrift::Types::STRING, :name => 'b6', :binary => true}
|
255
|
+
}
|
256
|
+
|
257
|
+
def struct_fields; FIELDS; end
|
258
|
+
|
259
|
+
def validate
|
260
|
+
end
|
261
|
+
|
262
|
+
::Thrift::Struct.generate_accessors self
|
263
|
+
end
|
264
|
+
|
265
|
+
class CompactProtoTestStruct
|
266
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
267
|
+
A_BYTE = 1
|
268
|
+
A_I16 = 2
|
269
|
+
A_I32 = 3
|
270
|
+
A_I64 = 4
|
271
|
+
A_DOUBLE = 5
|
272
|
+
A_STRING = 6
|
273
|
+
A_BINARY = 7
|
274
|
+
TRUE_FIELD = 8
|
275
|
+
FALSE_FIELD = 9
|
276
|
+
EMPTY_STRUCT_FIELD = 10
|
277
|
+
BYTE_LIST = 11
|
278
|
+
I16_LIST = 12
|
279
|
+
I32_LIST = 13
|
280
|
+
I64_LIST = 14
|
281
|
+
DOUBLE_LIST = 15
|
282
|
+
STRING_LIST = 16
|
283
|
+
BINARY_LIST = 17
|
284
|
+
BOOLEAN_LIST = 18
|
285
|
+
STRUCT_LIST = 19
|
286
|
+
BYTE_SET = 20
|
287
|
+
I16_SET = 21
|
288
|
+
I32_SET = 22
|
289
|
+
I64_SET = 23
|
290
|
+
DOUBLE_SET = 24
|
291
|
+
STRING_SET = 25
|
292
|
+
BINARY_SET = 26
|
293
|
+
BOOLEAN_SET = 27
|
294
|
+
STRUCT_SET = 28
|
295
|
+
BYTE_BYTE_MAP = 29
|
296
|
+
I16_BYTE_MAP = 30
|
297
|
+
I32_BYTE_MAP = 31
|
298
|
+
I64_BYTE_MAP = 32
|
299
|
+
DOUBLE_BYTE_MAP = 33
|
300
|
+
STRING_BYTE_MAP = 34
|
301
|
+
BINARY_BYTE_MAP = 35
|
302
|
+
BOOLEAN_BYTE_MAP = 36
|
303
|
+
BYTE_I16_MAP = 37
|
304
|
+
BYTE_I32_MAP = 38
|
305
|
+
BYTE_I64_MAP = 39
|
306
|
+
BYTE_DOUBLE_MAP = 40
|
307
|
+
BYTE_STRING_MAP = 41
|
308
|
+
BYTE_BINARY_MAP = 42
|
309
|
+
BYTE_BOOLEAN_MAP = 43
|
310
|
+
LIST_BYTE_MAP = 44
|
311
|
+
SET_BYTE_MAP = 45
|
312
|
+
MAP_BYTE_MAP = 46
|
313
|
+
BYTE_MAP_MAP = 47
|
314
|
+
BYTE_SET_MAP = 48
|
315
|
+
BYTE_LIST_MAP = 49
|
316
|
+
|
317
|
+
FIELDS = {
|
318
|
+
A_BYTE => {:type => ::Thrift::Types::BYTE, :name => 'a_byte'},
|
319
|
+
A_I16 => {:type => ::Thrift::Types::I16, :name => 'a_i16'},
|
320
|
+
A_I32 => {:type => ::Thrift::Types::I32, :name => 'a_i32'},
|
321
|
+
A_I64 => {:type => ::Thrift::Types::I64, :name => 'a_i64'},
|
322
|
+
A_DOUBLE => {:type => ::Thrift::Types::DOUBLE, :name => 'a_double'},
|
323
|
+
A_STRING => {:type => ::Thrift::Types::STRING, :name => 'a_string'},
|
324
|
+
A_BINARY => {:type => ::Thrift::Types::STRING, :name => 'a_binary', :binary => true},
|
325
|
+
TRUE_FIELD => {:type => ::Thrift::Types::BOOL, :name => 'true_field'},
|
326
|
+
FALSE_FIELD => {:type => ::Thrift::Types::BOOL, :name => 'false_field'},
|
327
|
+
EMPTY_STRUCT_FIELD => {:type => ::Thrift::Types::STRUCT, :name => 'empty_struct_field', :class => ::Thrift::Test::Empty},
|
328
|
+
BYTE_LIST => {:type => ::Thrift::Types::LIST, :name => 'byte_list', :element => {:type => ::Thrift::Types::BYTE}},
|
329
|
+
I16_LIST => {:type => ::Thrift::Types::LIST, :name => 'i16_list', :element => {:type => ::Thrift::Types::I16}},
|
330
|
+
I32_LIST => {:type => ::Thrift::Types::LIST, :name => 'i32_list', :element => {:type => ::Thrift::Types::I32}},
|
331
|
+
I64_LIST => {:type => ::Thrift::Types::LIST, :name => 'i64_list', :element => {:type => ::Thrift::Types::I64}},
|
332
|
+
DOUBLE_LIST => {:type => ::Thrift::Types::LIST, :name => 'double_list', :element => {:type => ::Thrift::Types::DOUBLE}},
|
333
|
+
STRING_LIST => {:type => ::Thrift::Types::LIST, :name => 'string_list', :element => {:type => ::Thrift::Types::STRING}},
|
334
|
+
BINARY_LIST => {:type => ::Thrift::Types::LIST, :name => 'binary_list', :element => {:type => ::Thrift::Types::STRING, :binary => true}},
|
335
|
+
BOOLEAN_LIST => {:type => ::Thrift::Types::LIST, :name => 'boolean_list', :element => {:type => ::Thrift::Types::BOOL}},
|
336
|
+
STRUCT_LIST => {:type => ::Thrift::Types::LIST, :name => 'struct_list', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Thrift::Test::Empty}},
|
337
|
+
BYTE_SET => {:type => ::Thrift::Types::SET, :name => 'byte_set', :element => {:type => ::Thrift::Types::BYTE}},
|
338
|
+
I16_SET => {:type => ::Thrift::Types::SET, :name => 'i16_set', :element => {:type => ::Thrift::Types::I16}},
|
339
|
+
I32_SET => {:type => ::Thrift::Types::SET, :name => 'i32_set', :element => {:type => ::Thrift::Types::I32}},
|
340
|
+
I64_SET => {:type => ::Thrift::Types::SET, :name => 'i64_set', :element => {:type => ::Thrift::Types::I64}},
|
341
|
+
DOUBLE_SET => {:type => ::Thrift::Types::SET, :name => 'double_set', :element => {:type => ::Thrift::Types::DOUBLE}},
|
342
|
+
STRING_SET => {:type => ::Thrift::Types::SET, :name => 'string_set', :element => {:type => ::Thrift::Types::STRING}},
|
343
|
+
BINARY_SET => {:type => ::Thrift::Types::SET, :name => 'binary_set', :element => {:type => ::Thrift::Types::STRING, :binary => true}},
|
344
|
+
BOOLEAN_SET => {:type => ::Thrift::Types::SET, :name => 'boolean_set', :element => {:type => ::Thrift::Types::BOOL}},
|
345
|
+
STRUCT_SET => {:type => ::Thrift::Types::SET, :name => 'struct_set', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Thrift::Test::Empty}},
|
346
|
+
BYTE_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_byte_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::BYTE}},
|
347
|
+
I16_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'i16_byte_map', :key => {:type => ::Thrift::Types::I16}, :value => {:type => ::Thrift::Types::BYTE}},
|
348
|
+
I32_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'i32_byte_map', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::BYTE}},
|
349
|
+
I64_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'i64_byte_map', :key => {:type => ::Thrift::Types::I64}, :value => {:type => ::Thrift::Types::BYTE}},
|
350
|
+
DOUBLE_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'double_byte_map', :key => {:type => ::Thrift::Types::DOUBLE}, :value => {:type => ::Thrift::Types::BYTE}},
|
351
|
+
STRING_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'string_byte_map', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::BYTE}},
|
352
|
+
BINARY_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'binary_byte_map', :key => {:type => ::Thrift::Types::STRING, :binary => true}, :value => {:type => ::Thrift::Types::BYTE}},
|
353
|
+
BOOLEAN_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'boolean_byte_map', :key => {:type => ::Thrift::Types::BOOL}, :value => {:type => ::Thrift::Types::BYTE}},
|
354
|
+
BYTE_I16_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_i16_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::I16}},
|
355
|
+
BYTE_I32_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_i32_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::I32}},
|
356
|
+
BYTE_I64_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_i64_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::I64}},
|
357
|
+
BYTE_DOUBLE_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_double_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::DOUBLE}},
|
358
|
+
BYTE_STRING_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_string_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::STRING}},
|
359
|
+
BYTE_BINARY_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_binary_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::STRING, :binary => true}},
|
360
|
+
BYTE_BOOLEAN_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_boolean_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::BOOL}},
|
361
|
+
LIST_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'list_byte_map', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::BYTE}}, :value => {:type => ::Thrift::Types::BYTE}},
|
362
|
+
SET_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'set_byte_map', :key => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::BYTE}}, :value => {:type => ::Thrift::Types::BYTE}},
|
363
|
+
MAP_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'map_byte_map', :key => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::BYTE}}, :value => {:type => ::Thrift::Types::BYTE}},
|
364
|
+
BYTE_MAP_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_map_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::BYTE}}},
|
365
|
+
BYTE_SET_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_set_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::BYTE}}},
|
366
|
+
BYTE_LIST_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_list_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::BYTE}}}
|
367
|
+
}
|
368
|
+
|
369
|
+
def struct_fields; FIELDS; end
|
370
|
+
|
371
|
+
def validate
|
372
|
+
end
|
373
|
+
|
374
|
+
::Thrift::Struct.generate_accessors self
|
375
|
+
end
|
376
|
+
|
377
|
+
class SingleMapTestStruct
|
378
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
379
|
+
I32_MAP = 1
|
380
|
+
|
381
|
+
FIELDS = {
|
382
|
+
I32_MAP => {:type => ::Thrift::Types::MAP, :name => 'i32_map', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::I32}}
|
383
|
+
}
|
384
|
+
|
385
|
+
def struct_fields; FIELDS; end
|
386
|
+
|
387
|
+
def validate
|
388
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field i32_map is unset!') unless @i32_map
|
389
|
+
end
|
390
|
+
|
391
|
+
::Thrift::Struct.generate_accessors self
|
392
|
+
end
|
393
|
+
|
394
|
+
class ExceptionWithAMap < ::Thrift::Exception
|
395
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
396
|
+
BLAH = 1
|
397
|
+
MAP_FIELD = 2
|
398
|
+
|
399
|
+
FIELDS = {
|
400
|
+
BLAH => {:type => ::Thrift::Types::STRING, :name => 'blah'},
|
401
|
+
MAP_FIELD => {:type => ::Thrift::Types::MAP, :name => 'map_field', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
|
402
|
+
}
|
403
|
+
|
404
|
+
def struct_fields; FIELDS; end
|
405
|
+
|
406
|
+
def validate
|
407
|
+
end
|
408
|
+
|
409
|
+
::Thrift::Struct.generate_accessors self
|
410
|
+
end
|
411
|
+
|
412
|
+
class BlowUp
|
413
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
414
|
+
B1 = 1
|
415
|
+
B2 = 2
|
416
|
+
B3 = 3
|
417
|
+
B4 = 4
|
418
|
+
|
419
|
+
FIELDS = {
|
420
|
+
B1 => {:type => ::Thrift::Types::MAP, :name => 'b1', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32}}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRING}}}},
|
421
|
+
B2 => {:type => ::Thrift::Types::MAP, :name => 'b2', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32}}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRING}}}},
|
422
|
+
B3 => {:type => ::Thrift::Types::MAP, :name => 'b3', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32}}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRING}}}},
|
423
|
+
B4 => {:type => ::Thrift::Types::MAP, :name => 'b4', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32}}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRING}}}}
|
424
|
+
}
|
425
|
+
|
426
|
+
def struct_fields; FIELDS; end
|
427
|
+
|
428
|
+
def validate
|
429
|
+
end
|
430
|
+
|
431
|
+
::Thrift::Struct.generate_accessors self
|
432
|
+
end
|
433
|
+
|
434
|
+
class ReverseOrderStruct
|
435
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
436
|
+
FIRST = 4
|
437
|
+
SECOND = 3
|
438
|
+
THIRD = 2
|
439
|
+
FOURTH = 1
|
440
|
+
|
441
|
+
FIELDS = {
|
442
|
+
FIRST => {:type => ::Thrift::Types::STRING, :name => 'first'},
|
443
|
+
SECOND => {:type => ::Thrift::Types::I16, :name => 'second'},
|
444
|
+
THIRD => {:type => ::Thrift::Types::I32, :name => 'third'},
|
445
|
+
FOURTH => {:type => ::Thrift::Types::I64, :name => 'fourth'}
|
446
|
+
}
|
447
|
+
|
448
|
+
def struct_fields; FIELDS; end
|
449
|
+
|
450
|
+
def validate
|
451
|
+
end
|
452
|
+
|
453
|
+
::Thrift::Struct.generate_accessors self
|
454
|
+
end
|
455
|
+
|
456
|
+
class StructWithSomeEnum
|
457
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
458
|
+
BLAH = 1
|
459
|
+
|
460
|
+
FIELDS = {
|
461
|
+
BLAH => {:type => ::Thrift::Types::I32, :name => 'blah', :enum_class => ::Thrift::Test::SomeEnum}
|
462
|
+
}
|
463
|
+
|
464
|
+
def struct_fields; FIELDS; end
|
465
|
+
|
466
|
+
def validate
|
467
|
+
unless @blah.nil? || ::Thrift::Test::SomeEnum::VALID_VALUES.include?(@blah)
|
468
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field blah!')
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
::Thrift::Struct.generate_accessors self
|
473
|
+
end
|
474
|
+
|
475
|
+
class TestUnion < ::Thrift::Union
|
476
|
+
include ::Thrift::Struct_Union
|
477
|
+
class << self
|
478
|
+
def string_field(val)
|
479
|
+
TestUnion.new(:string_field, val)
|
480
|
+
end
|
481
|
+
|
482
|
+
def i32_field(val)
|
483
|
+
TestUnion.new(:i32_field, val)
|
484
|
+
end
|
485
|
+
|
486
|
+
def struct_field(val)
|
487
|
+
TestUnion.new(:struct_field, val)
|
488
|
+
end
|
489
|
+
|
490
|
+
def struct_list(val)
|
491
|
+
TestUnion.new(:struct_list, val)
|
492
|
+
end
|
493
|
+
|
494
|
+
def other_i32_field(val)
|
495
|
+
TestUnion.new(:other_i32_field, val)
|
496
|
+
end
|
497
|
+
|
498
|
+
def enum_field(val)
|
499
|
+
TestUnion.new(:enum_field, val)
|
500
|
+
end
|
501
|
+
|
502
|
+
def i32_set(val)
|
503
|
+
TestUnion.new(:i32_set, val)
|
504
|
+
end
|
505
|
+
|
506
|
+
def i32_map(val)
|
507
|
+
TestUnion.new(:i32_map, val)
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
STRING_FIELD = 1
|
512
|
+
I32_FIELD = 2
|
513
|
+
STRUCT_FIELD = 3
|
514
|
+
STRUCT_LIST = 4
|
515
|
+
OTHER_I32_FIELD = 5
|
516
|
+
ENUM_FIELD = 6
|
517
|
+
I32_SET = 7
|
518
|
+
I32_MAP = 8
|
519
|
+
|
520
|
+
FIELDS = {
|
521
|
+
# A doc string
|
522
|
+
STRING_FIELD => {:type => ::Thrift::Types::STRING, :name => 'string_field', :optional => true},
|
523
|
+
I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'i32_field', :optional => true},
|
524
|
+
STRUCT_FIELD => {:type => ::Thrift::Types::STRUCT, :name => 'struct_field', :class => ::Thrift::Test::OneOfEach, :optional => true},
|
525
|
+
STRUCT_LIST => {:type => ::Thrift::Types::LIST, :name => 'struct_list', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Thrift::Test::RandomStuff}, :optional => true},
|
526
|
+
OTHER_I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'other_i32_field', :optional => true},
|
527
|
+
ENUM_FIELD => {:type => ::Thrift::Types::I32, :name => 'enum_field', :optional => true, :enum_class => ::Thrift::Test::SomeEnum},
|
528
|
+
I32_SET => {:type => ::Thrift::Types::SET, :name => 'i32_set', :element => {:type => ::Thrift::Types::I32}, :optional => true},
|
529
|
+
I32_MAP => {:type => ::Thrift::Types::MAP, :name => 'i32_map', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::I32}, :optional => true}
|
530
|
+
}
|
531
|
+
|
532
|
+
def struct_fields; FIELDS; end
|
533
|
+
|
534
|
+
def validate
|
535
|
+
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
|
536
|
+
if get_set_field == :enum_field
|
537
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field enum_field!') unless ::Thrift::Test::SomeEnum::VALID_VALUES.include?(get_value)
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
::Thrift::Union.generate_accessors self
|
542
|
+
end
|
543
|
+
|
544
|
+
class TestUnionMinusStringField < ::Thrift::Union
|
545
|
+
include ::Thrift::Struct_Union
|
546
|
+
class << self
|
547
|
+
def i32_field(val)
|
548
|
+
TestUnionMinusStringField.new(:i32_field, val)
|
549
|
+
end
|
550
|
+
|
551
|
+
def struct_field(val)
|
552
|
+
TestUnionMinusStringField.new(:struct_field, val)
|
553
|
+
end
|
554
|
+
|
555
|
+
def struct_list(val)
|
556
|
+
TestUnionMinusStringField.new(:struct_list, val)
|
557
|
+
end
|
558
|
+
|
559
|
+
def other_i32_field(val)
|
560
|
+
TestUnionMinusStringField.new(:other_i32_field, val)
|
561
|
+
end
|
562
|
+
|
563
|
+
def enum_field(val)
|
564
|
+
TestUnionMinusStringField.new(:enum_field, val)
|
565
|
+
end
|
566
|
+
|
567
|
+
def i32_set(val)
|
568
|
+
TestUnionMinusStringField.new(:i32_set, val)
|
569
|
+
end
|
570
|
+
|
571
|
+
def i32_map(val)
|
572
|
+
TestUnionMinusStringField.new(:i32_map, val)
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
576
|
+
I32_FIELD = 2
|
577
|
+
STRUCT_FIELD = 3
|
578
|
+
STRUCT_LIST = 4
|
579
|
+
OTHER_I32_FIELD = 5
|
580
|
+
ENUM_FIELD = 6
|
581
|
+
I32_SET = 7
|
582
|
+
I32_MAP = 8
|
583
|
+
|
584
|
+
FIELDS = {
|
585
|
+
I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'i32_field', :optional => true},
|
586
|
+
STRUCT_FIELD => {:type => ::Thrift::Types::STRUCT, :name => 'struct_field', :class => ::Thrift::Test::OneOfEach, :optional => true},
|
587
|
+
STRUCT_LIST => {:type => ::Thrift::Types::LIST, :name => 'struct_list', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Thrift::Test::RandomStuff}, :optional => true},
|
588
|
+
OTHER_I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'other_i32_field', :optional => true},
|
589
|
+
ENUM_FIELD => {:type => ::Thrift::Types::I32, :name => 'enum_field', :optional => true, :enum_class => ::Thrift::Test::SomeEnum},
|
590
|
+
I32_SET => {:type => ::Thrift::Types::SET, :name => 'i32_set', :element => {:type => ::Thrift::Types::I32}, :optional => true},
|
591
|
+
I32_MAP => {:type => ::Thrift::Types::MAP, :name => 'i32_map', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::I32}, :optional => true}
|
592
|
+
}
|
593
|
+
|
594
|
+
def struct_fields; FIELDS; end
|
595
|
+
|
596
|
+
def validate
|
597
|
+
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
|
598
|
+
if get_set_field == :enum_field
|
599
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field enum_field!') unless ::Thrift::Test::SomeEnum::VALID_VALUES.include?(get_value)
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
::Thrift::Union.generate_accessors self
|
604
|
+
end
|
605
|
+
|
606
|
+
class ComparableUnion < ::Thrift::Union
|
607
|
+
include ::Thrift::Struct_Union
|
608
|
+
class << self
|
609
|
+
def string_field(val)
|
610
|
+
ComparableUnion.new(:string_field, val)
|
611
|
+
end
|
612
|
+
|
613
|
+
def binary_field(val)
|
614
|
+
ComparableUnion.new(:binary_field, val)
|
615
|
+
end
|
616
|
+
end
|
617
|
+
|
618
|
+
STRING_FIELD = 1
|
619
|
+
BINARY_FIELD = 2
|
620
|
+
|
621
|
+
FIELDS = {
|
622
|
+
STRING_FIELD => {:type => ::Thrift::Types::STRING, :name => 'string_field', :optional => true},
|
623
|
+
BINARY_FIELD => {:type => ::Thrift::Types::STRING, :name => 'binary_field', :binary => true, :optional => true}
|
624
|
+
}
|
625
|
+
|
626
|
+
def struct_fields; FIELDS; end
|
627
|
+
|
628
|
+
def validate
|
629
|
+
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
|
630
|
+
end
|
631
|
+
|
632
|
+
::Thrift::Union.generate_accessors self
|
633
|
+
end
|
634
|
+
|
635
|
+
class StructWithAUnion
|
636
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
637
|
+
TEST_UNION = 1
|
638
|
+
|
639
|
+
FIELDS = {
|
640
|
+
TEST_UNION => {:type => ::Thrift::Types::STRUCT, :name => 'test_union', :class => ::Thrift::Test::TestUnion}
|
641
|
+
}
|
642
|
+
|
643
|
+
def struct_fields; FIELDS; end
|
644
|
+
|
645
|
+
def validate
|
646
|
+
end
|
647
|
+
|
648
|
+
::Thrift::Struct.generate_accessors self
|
649
|
+
end
|
650
|
+
|
651
|
+
class PrimitiveThenStruct
|
652
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
653
|
+
BLAH = 1
|
654
|
+
BLAH2 = 2
|
655
|
+
BW = 3
|
656
|
+
|
657
|
+
FIELDS = {
|
658
|
+
BLAH => {:type => ::Thrift::Types::I32, :name => 'blah'},
|
659
|
+
BLAH2 => {:type => ::Thrift::Types::I32, :name => 'blah2'},
|
660
|
+
BW => {:type => ::Thrift::Types::STRUCT, :name => 'bw', :class => ::Thrift::Test::Backwards}
|
661
|
+
}
|
662
|
+
|
663
|
+
def struct_fields; FIELDS; end
|
664
|
+
|
665
|
+
def validate
|
666
|
+
end
|
667
|
+
|
668
|
+
::Thrift::Struct.generate_accessors self
|
669
|
+
end
|
670
|
+
|
671
|
+
class StructWithASomemap
|
672
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
673
|
+
SOMEMAP_FIELD = 1
|
674
|
+
|
675
|
+
FIELDS = {
|
676
|
+
SOMEMAP_FIELD => {:type => ::Thrift::Types::MAP, :name => 'somemap_field', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::I32}}
|
677
|
+
}
|
678
|
+
|
679
|
+
def struct_fields; FIELDS; end
|
680
|
+
|
681
|
+
def validate
|
682
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field somemap_field is unset!') unless @somemap_field
|
683
|
+
end
|
684
|
+
|
685
|
+
::Thrift::Struct.generate_accessors self
|
686
|
+
end
|
687
|
+
|
688
|
+
class BigFieldIdStruct
|
689
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
690
|
+
FIELD1 = 1
|
691
|
+
FIELD2 = 45
|
692
|
+
|
693
|
+
FIELDS = {
|
694
|
+
FIELD1 => {:type => ::Thrift::Types::STRING, :name => 'field1'},
|
695
|
+
FIELD2 => {:type => ::Thrift::Types::STRING, :name => 'field2'}
|
696
|
+
}
|
697
|
+
|
698
|
+
def struct_fields; FIELDS; end
|
699
|
+
|
700
|
+
def validate
|
701
|
+
end
|
702
|
+
|
703
|
+
::Thrift::Struct.generate_accessors self
|
704
|
+
end
|
705
|
+
|
706
|
+
class BreaksRubyCompactProtocol
|
707
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
708
|
+
FIELD1 = 1
|
709
|
+
FIELD2 = 2
|
710
|
+
FIELD3 = 3
|
711
|
+
|
712
|
+
FIELDS = {
|
713
|
+
FIELD1 => {:type => ::Thrift::Types::STRING, :name => 'field1'},
|
714
|
+
FIELD2 => {:type => ::Thrift::Types::STRUCT, :name => 'field2', :class => ::Thrift::Test::BigFieldIdStruct},
|
715
|
+
FIELD3 => {:type => ::Thrift::Types::I32, :name => 'field3'}
|
716
|
+
}
|
717
|
+
|
718
|
+
def struct_fields; FIELDS; end
|
719
|
+
|
720
|
+
def validate
|
721
|
+
end
|
722
|
+
|
723
|
+
::Thrift::Struct.generate_accessors self
|
724
|
+
end
|
725
|
+
|
726
|
+
class TupleProtocolTestStruct
|
727
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
728
|
+
FIELD1 = -1
|
729
|
+
FIELD2 = -2
|
730
|
+
FIELD3 = -3
|
731
|
+
FIELD4 = -4
|
732
|
+
FIELD5 = -5
|
733
|
+
FIELD6 = -6
|
734
|
+
FIELD7 = -7
|
735
|
+
FIELD8 = -8
|
736
|
+
FIELD9 = -9
|
737
|
+
FIELD10 = -10
|
738
|
+
FIELD11 = -11
|
739
|
+
FIELD12 = -12
|
740
|
+
|
741
|
+
FIELDS = {
|
742
|
+
FIELD1 => {:type => ::Thrift::Types::I32, :name => 'field1', :optional => true},
|
743
|
+
FIELD2 => {:type => ::Thrift::Types::I32, :name => 'field2', :optional => true},
|
744
|
+
FIELD3 => {:type => ::Thrift::Types::I32, :name => 'field3', :optional => true},
|
745
|
+
FIELD4 => {:type => ::Thrift::Types::I32, :name => 'field4', :optional => true},
|
746
|
+
FIELD5 => {:type => ::Thrift::Types::I32, :name => 'field5', :optional => true},
|
747
|
+
FIELD6 => {:type => ::Thrift::Types::I32, :name => 'field6', :optional => true},
|
748
|
+
FIELD7 => {:type => ::Thrift::Types::I32, :name => 'field7', :optional => true},
|
749
|
+
FIELD8 => {:type => ::Thrift::Types::I32, :name => 'field8', :optional => true},
|
750
|
+
FIELD9 => {:type => ::Thrift::Types::I32, :name => 'field9', :optional => true},
|
751
|
+
FIELD10 => {:type => ::Thrift::Types::I32, :name => 'field10', :optional => true},
|
752
|
+
FIELD11 => {:type => ::Thrift::Types::I32, :name => 'field11', :optional => true},
|
753
|
+
FIELD12 => {:type => ::Thrift::Types::I32, :name => 'field12', :optional => true}
|
754
|
+
}
|
755
|
+
|
756
|
+
def struct_fields; FIELDS; end
|
757
|
+
|
758
|
+
def validate
|
759
|
+
end
|
760
|
+
|
761
|
+
::Thrift::Struct.generate_accessors self
|
762
|
+
end
|
763
|
+
|
764
|
+
class ListDoublePerf
|
765
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
766
|
+
FIELD = 1
|
767
|
+
|
768
|
+
FIELDS = {
|
769
|
+
FIELD => {:type => ::Thrift::Types::LIST, :name => 'field', :element => {:type => ::Thrift::Types::DOUBLE}}
|
770
|
+
}
|
771
|
+
|
772
|
+
def struct_fields; FIELDS; end
|
773
|
+
|
774
|
+
def validate
|
775
|
+
end
|
776
|
+
|
777
|
+
::Thrift::Struct.generate_accessors self
|
778
|
+
end
|
779
|
+
|
780
|
+
end
|
781
|
+
end
|