thrift 0.8.0 → 0.13.0

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