thrift 0.8.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{README → README.md} +0 -0
- data/ext/binary_protocol_accelerated.c +33 -14
- data/ext/bytes.c +36 -0
- data/ext/bytes.h +31 -0
- data/ext/compact_protocol.c +27 -8
- data/ext/constants.h +8 -5
- data/ext/extconf.rb +5 -1
- data/ext/memory_buffer.c +12 -9
- data/ext/protocol.c +0 -185
- data/ext/protocol.h +0 -20
- data/ext/strlcpy.h +7 -3
- data/ext/struct.c +27 -7
- data/ext/thrift_native.c +16 -11
- data/lib/thrift.rb +10 -4
- data/lib/thrift/bytes.rb +131 -0
- data/lib/thrift/client.rb +13 -4
- data/lib/thrift/exceptions.rb +3 -0
- data/lib/thrift/multiplexed_processor.rb +76 -0
- data/lib/thrift/processor.rb +24 -6
- data/lib/thrift/protocol/base_protocol.rb +109 -12
- data/lib/thrift/protocol/binary_protocol.rb +22 -7
- data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
- data/lib/thrift/protocol/compact_protocol.rb +23 -6
- data/lib/thrift/protocol/json_protocol.rb +786 -0
- data/lib/thrift/protocol/multiplexed_protocol.rb +44 -0
- data/lib/thrift/protocol/protocol_decorator.rb +194 -0
- data/lib/thrift/server/base_server.rb +8 -2
- data/lib/thrift/server/mongrel_http_server.rb +2 -0
- data/lib/thrift/server/simple_server.rb +5 -1
- data/lib/thrift/server/thin_http_server.rb +91 -0
- data/lib/thrift/server/thread_pool_server.rb +5 -1
- data/lib/thrift/server/threaded_server.rb +5 -1
- data/lib/thrift/struct.rb +1 -1
- data/lib/thrift/struct_union.rb +2 -2
- data/lib/thrift/transport/base_server_transport.rb +1 -1
- data/lib/thrift/transport/base_transport.rb +30 -20
- data/lib/thrift/transport/buffered_transport.rb +25 -11
- data/lib/thrift/transport/framed_transport.rb +20 -11
- data/lib/thrift/transport/http_client_transport.rb +16 -6
- data/lib/thrift/transport/io_stream_transport.rb +5 -2
- data/lib/thrift/transport/memory_buffer_transport.rb +10 -6
- data/lib/thrift/transport/server_socket.rb +6 -1
- data/lib/thrift/transport/socket.rb +23 -17
- data/lib/thrift/transport/ssl_server_socket.rb +41 -0
- data/lib/thrift/transport/ssl_socket.rb +51 -0
- data/lib/thrift/transport/unix_server_socket.rb +5 -1
- data/lib/thrift/transport/unix_socket.rb +5 -1
- data/lib/thrift/union.rb +3 -6
- data/spec/BaseService.thrift +27 -0
- data/spec/ExtendedService.thrift +25 -0
- data/spec/Referenced.thrift +44 -0
- data/spec/ThriftNamespacedSpec.thrift +53 -0
- data/spec/ThriftSpec.thrift +52 -1
- data/spec/base_protocol_spec.rb +158 -93
- data/spec/base_transport_spec.rb +194 -157
- data/spec/binary_protocol_accelerated_spec.rb +14 -14
- data/spec/binary_protocol_spec.rb +29 -16
- data/spec/binary_protocol_spec_shared.rb +148 -65
- data/spec/bytes_spec.rb +160 -0
- data/spec/client_spec.rb +45 -47
- data/spec/compact_protocol_spec.rb +36 -22
- data/spec/exception_spec.rb +79 -80
- data/spec/flat_spec.rb +62 -0
- data/spec/http_client_spec.rb +91 -16
- data/spec/json_protocol_spec.rb +552 -0
- data/spec/namespaced_spec.rb +67 -0
- data/spec/nonblocking_server_spec.rb +26 -28
- data/spec/processor_spec.rb +29 -32
- data/spec/serializer_spec.rb +31 -33
- data/spec/server_socket_spec.rb +32 -28
- data/spec/server_spec.rb +112 -84
- data/spec/socket_spec.rb +27 -20
- data/spec/socket_spec_shared.rb +32 -32
- data/spec/spec_helper.rb +17 -11
- data/spec/ssl_server_socket_spec.rb +34 -0
- data/spec/ssl_socket_spec.rb +78 -0
- data/spec/struct_nested_containers_spec.rb +191 -0
- data/spec/struct_spec.rb +159 -161
- data/spec/thin_http_server_spec.rb +141 -0
- data/spec/types_spec.rb +71 -69
- data/spec/union_spec.rb +97 -76
- data/spec/unix_socket_spec.rb +49 -41
- metadata +268 -188
- data/CHANGELOG +0 -1
- data/benchmark/gen-rb/benchmark_constants.rb +0 -10
- data/benchmark/gen-rb/benchmark_service.rb +0 -80
- data/benchmark/gen-rb/benchmark_types.rb +0 -9
- data/spec/gen-rb/nonblocking_service.rb +0 -272
- data/spec/gen-rb/thrift_spec_constants.rb +0 -10
- data/spec/gen-rb/thrift_spec_types.rb +0 -345
- data/spec/mongrel_http_server_spec.rb +0 -117
- data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +0 -273
- data/test/debug_proto/gen-rb/debug_proto_test_types.rb +0 -760
- data/test/debug_proto/gen-rb/empty_service.rb +0 -24
- data/test/debug_proto/gen-rb/inherited.rb +0 -79
- data/test/debug_proto/gen-rb/reverse_order_service.rb +0 -82
- data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +0 -81
- data/test/debug_proto/gen-rb/srv.rb +0 -330
data/CHANGELOG
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
v0.0.1. Initial release
|
@@ -1,80 +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 'thrift'
|
8
|
-
require 'benchmark_types'
|
9
|
-
|
10
|
-
module ThriftBenchmark
|
11
|
-
module BenchmarkService
|
12
|
-
class Client
|
13
|
-
include ::Thrift::Client
|
14
|
-
|
15
|
-
def fibonacci(n)
|
16
|
-
send_fibonacci(n)
|
17
|
-
return recv_fibonacci()
|
18
|
-
end
|
19
|
-
|
20
|
-
def send_fibonacci(n)
|
21
|
-
send_message('fibonacci', Fibonacci_args, :n => n)
|
22
|
-
end
|
23
|
-
|
24
|
-
def recv_fibonacci()
|
25
|
-
result = receive_message(Fibonacci_result)
|
26
|
-
return result.success unless result.success.nil?
|
27
|
-
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'fibonacci failed: unknown result')
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
class Processor
|
33
|
-
include ::Thrift::Processor
|
34
|
-
|
35
|
-
def process_fibonacci(seqid, iprot, oprot)
|
36
|
-
args = read_args(iprot, Fibonacci_args)
|
37
|
-
result = Fibonacci_result.new()
|
38
|
-
result.success = @handler.fibonacci(args.n)
|
39
|
-
write_result(result, oprot, 'fibonacci', seqid)
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
# HELPER FUNCTIONS AND STRUCTURES
|
45
|
-
|
46
|
-
class Fibonacci_args
|
47
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
48
|
-
N = 1
|
49
|
-
|
50
|
-
FIELDS = {
|
51
|
-
N => {:type => ::Thrift::Types::BYTE, :name => 'n'}
|
52
|
-
}
|
53
|
-
|
54
|
-
def struct_fields; FIELDS; end
|
55
|
-
|
56
|
-
def validate
|
57
|
-
end
|
58
|
-
|
59
|
-
::Thrift::Struct.generate_accessors self
|
60
|
-
end
|
61
|
-
|
62
|
-
class Fibonacci_result
|
63
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
64
|
-
SUCCESS = 0
|
65
|
-
|
66
|
-
FIELDS = {
|
67
|
-
SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
|
68
|
-
}
|
69
|
-
|
70
|
-
def struct_fields; FIELDS; end
|
71
|
-
|
72
|
-
def validate
|
73
|
-
end
|
74
|
-
|
75
|
-
::Thrift::Struct.generate_accessors self
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
@@ -1,272 +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 'thrift'
|
8
|
-
require 'thrift_spec_types'
|
9
|
-
|
10
|
-
module SpecNamespace
|
11
|
-
module NonblockingService
|
12
|
-
class Client
|
13
|
-
include ::Thrift::Client
|
14
|
-
|
15
|
-
def greeting(english)
|
16
|
-
send_greeting(english)
|
17
|
-
return recv_greeting()
|
18
|
-
end
|
19
|
-
|
20
|
-
def send_greeting(english)
|
21
|
-
send_message('greeting', Greeting_args, :english => english)
|
22
|
-
end
|
23
|
-
|
24
|
-
def recv_greeting()
|
25
|
-
result = receive_message(Greeting_result)
|
26
|
-
return result.success unless result.success.nil?
|
27
|
-
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'greeting failed: unknown result')
|
28
|
-
end
|
29
|
-
|
30
|
-
def block()
|
31
|
-
send_block()
|
32
|
-
return recv_block()
|
33
|
-
end
|
34
|
-
|
35
|
-
def send_block()
|
36
|
-
send_message('block', Block_args)
|
37
|
-
end
|
38
|
-
|
39
|
-
def recv_block()
|
40
|
-
result = receive_message(Block_result)
|
41
|
-
return result.success unless result.success.nil?
|
42
|
-
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'block failed: unknown result')
|
43
|
-
end
|
44
|
-
|
45
|
-
def unblock(n)
|
46
|
-
send_unblock(n)
|
47
|
-
end
|
48
|
-
|
49
|
-
def send_unblock(n)
|
50
|
-
send_message('unblock', Unblock_args, :n => n)
|
51
|
-
end
|
52
|
-
def shutdown()
|
53
|
-
send_shutdown()
|
54
|
-
end
|
55
|
-
|
56
|
-
def send_shutdown()
|
57
|
-
send_message('shutdown', Shutdown_args)
|
58
|
-
end
|
59
|
-
def sleep(seconds)
|
60
|
-
send_sleep(seconds)
|
61
|
-
recv_sleep()
|
62
|
-
end
|
63
|
-
|
64
|
-
def send_sleep(seconds)
|
65
|
-
send_message('sleep', Sleep_args, :seconds => seconds)
|
66
|
-
end
|
67
|
-
|
68
|
-
def recv_sleep()
|
69
|
-
result = receive_message(Sleep_result)
|
70
|
-
return
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
class Processor
|
76
|
-
include ::Thrift::Processor
|
77
|
-
|
78
|
-
def process_greeting(seqid, iprot, oprot)
|
79
|
-
args = read_args(iprot, Greeting_args)
|
80
|
-
result = Greeting_result.new()
|
81
|
-
result.success = @handler.greeting(args.english)
|
82
|
-
write_result(result, oprot, 'greeting', seqid)
|
83
|
-
end
|
84
|
-
|
85
|
-
def process_block(seqid, iprot, oprot)
|
86
|
-
args = read_args(iprot, Block_args)
|
87
|
-
result = Block_result.new()
|
88
|
-
result.success = @handler.block()
|
89
|
-
write_result(result, oprot, 'block', seqid)
|
90
|
-
end
|
91
|
-
|
92
|
-
def process_unblock(seqid, iprot, oprot)
|
93
|
-
args = read_args(iprot, Unblock_args)
|
94
|
-
@handler.unblock(args.n)
|
95
|
-
return
|
96
|
-
end
|
97
|
-
|
98
|
-
def process_shutdown(seqid, iprot, oprot)
|
99
|
-
args = read_args(iprot, Shutdown_args)
|
100
|
-
@handler.shutdown()
|
101
|
-
return
|
102
|
-
end
|
103
|
-
|
104
|
-
def process_sleep(seqid, iprot, oprot)
|
105
|
-
args = read_args(iprot, Sleep_args)
|
106
|
-
result = Sleep_result.new()
|
107
|
-
@handler.sleep(args.seconds)
|
108
|
-
write_result(result, oprot, 'sleep', seqid)
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
# HELPER FUNCTIONS AND STRUCTURES
|
114
|
-
|
115
|
-
class Greeting_args
|
116
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
117
|
-
ENGLISH = 1
|
118
|
-
|
119
|
-
FIELDS = {
|
120
|
-
ENGLISH => {:type => ::Thrift::Types::BOOL, :name => 'english'}
|
121
|
-
}
|
122
|
-
|
123
|
-
def struct_fields; FIELDS; end
|
124
|
-
|
125
|
-
def validate
|
126
|
-
end
|
127
|
-
|
128
|
-
::Thrift::Struct.generate_accessors self
|
129
|
-
end
|
130
|
-
|
131
|
-
class Greeting_result
|
132
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
133
|
-
SUCCESS = 0
|
134
|
-
|
135
|
-
FIELDS = {
|
136
|
-
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => SpecNamespace::Hello}
|
137
|
-
}
|
138
|
-
|
139
|
-
def struct_fields; FIELDS; end
|
140
|
-
|
141
|
-
def validate
|
142
|
-
end
|
143
|
-
|
144
|
-
::Thrift::Struct.generate_accessors self
|
145
|
-
end
|
146
|
-
|
147
|
-
class Block_args
|
148
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
149
|
-
|
150
|
-
FIELDS = {
|
151
|
-
|
152
|
-
}
|
153
|
-
|
154
|
-
def struct_fields; FIELDS; end
|
155
|
-
|
156
|
-
def validate
|
157
|
-
end
|
158
|
-
|
159
|
-
::Thrift::Struct.generate_accessors self
|
160
|
-
end
|
161
|
-
|
162
|
-
class Block_result
|
163
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
164
|
-
SUCCESS = 0
|
165
|
-
|
166
|
-
FIELDS = {
|
167
|
-
SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
|
168
|
-
}
|
169
|
-
|
170
|
-
def struct_fields; FIELDS; end
|
171
|
-
|
172
|
-
def validate
|
173
|
-
end
|
174
|
-
|
175
|
-
::Thrift::Struct.generate_accessors self
|
176
|
-
end
|
177
|
-
|
178
|
-
class Unblock_args
|
179
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
180
|
-
N = 1
|
181
|
-
|
182
|
-
FIELDS = {
|
183
|
-
N => {:type => ::Thrift::Types::I32, :name => 'n'}
|
184
|
-
}
|
185
|
-
|
186
|
-
def struct_fields; FIELDS; end
|
187
|
-
|
188
|
-
def validate
|
189
|
-
end
|
190
|
-
|
191
|
-
::Thrift::Struct.generate_accessors self
|
192
|
-
end
|
193
|
-
|
194
|
-
class Unblock_result
|
195
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
196
|
-
|
197
|
-
FIELDS = {
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
def struct_fields; FIELDS; end
|
202
|
-
|
203
|
-
def validate
|
204
|
-
end
|
205
|
-
|
206
|
-
::Thrift::Struct.generate_accessors self
|
207
|
-
end
|
208
|
-
|
209
|
-
class Shutdown_args
|
210
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
211
|
-
|
212
|
-
FIELDS = {
|
213
|
-
|
214
|
-
}
|
215
|
-
|
216
|
-
def struct_fields; FIELDS; end
|
217
|
-
|
218
|
-
def validate
|
219
|
-
end
|
220
|
-
|
221
|
-
::Thrift::Struct.generate_accessors self
|
222
|
-
end
|
223
|
-
|
224
|
-
class Shutdown_result
|
225
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
226
|
-
|
227
|
-
FIELDS = {
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
def struct_fields; FIELDS; end
|
232
|
-
|
233
|
-
def validate
|
234
|
-
end
|
235
|
-
|
236
|
-
::Thrift::Struct.generate_accessors self
|
237
|
-
end
|
238
|
-
|
239
|
-
class Sleep_args
|
240
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
241
|
-
SECONDS = 1
|
242
|
-
|
243
|
-
FIELDS = {
|
244
|
-
SECONDS => {:type => ::Thrift::Types::DOUBLE, :name => 'seconds'}
|
245
|
-
}
|
246
|
-
|
247
|
-
def struct_fields; FIELDS; end
|
248
|
-
|
249
|
-
def validate
|
250
|
-
end
|
251
|
-
|
252
|
-
::Thrift::Struct.generate_accessors self
|
253
|
-
end
|
254
|
-
|
255
|
-
class Sleep_result
|
256
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
257
|
-
|
258
|
-
FIELDS = {
|
259
|
-
|
260
|
-
}
|
261
|
-
|
262
|
-
def struct_fields; FIELDS; end
|
263
|
-
|
264
|
-
def validate
|
265
|
-
end
|
266
|
-
|
267
|
-
::Thrift::Struct.generate_accessors self
|
268
|
-
end
|
269
|
-
|
270
|
-
end
|
271
|
-
|
272
|
-
end
|
@@ -1,345 +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 SpecNamespace
|
9
|
-
module SomeEnum
|
10
|
-
ONE = 0
|
11
|
-
TWO = 1
|
12
|
-
VALUE_MAP = {0 => "ONE", 1 => "TWO"}
|
13
|
-
VALID_VALUES = Set.new([ONE, TWO]).freeze
|
14
|
-
end
|
15
|
-
|
16
|
-
class Hello
|
17
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
18
|
-
GREETING = 1
|
19
|
-
|
20
|
-
FIELDS = {
|
21
|
-
GREETING => {:type => ::Thrift::Types::STRING, :name => 'greeting', :default => %q"hello world"}
|
22
|
-
}
|
23
|
-
|
24
|
-
def struct_fields; FIELDS; end
|
25
|
-
|
26
|
-
def validate
|
27
|
-
end
|
28
|
-
|
29
|
-
::Thrift::Struct.generate_accessors self
|
30
|
-
end
|
31
|
-
|
32
|
-
class StructWithSomeEnum
|
33
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
34
|
-
SOME_ENUM = 1
|
35
|
-
|
36
|
-
FIELDS = {
|
37
|
-
SOME_ENUM => {:type => ::Thrift::Types::I32, :name => 'some_enum', :enum_class => SpecNamespace::SomeEnum}
|
38
|
-
}
|
39
|
-
|
40
|
-
def struct_fields; FIELDS; end
|
41
|
-
|
42
|
-
def validate
|
43
|
-
unless @some_enum.nil? || SpecNamespace::SomeEnum::VALID_VALUES.include?(@some_enum)
|
44
|
-
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field some_enum!')
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
::Thrift::Struct.generate_accessors self
|
49
|
-
end
|
50
|
-
|
51
|
-
class TestUnion < ::Thrift::Union
|
52
|
-
include ::Thrift::Struct_Union
|
53
|
-
class << self
|
54
|
-
def string_field(val)
|
55
|
-
TestUnion.new(:string_field, val)
|
56
|
-
end
|
57
|
-
|
58
|
-
def i32_field(val)
|
59
|
-
TestUnion.new(:i32_field, val)
|
60
|
-
end
|
61
|
-
|
62
|
-
def other_i32_field(val)
|
63
|
-
TestUnion.new(:other_i32_field, val)
|
64
|
-
end
|
65
|
-
|
66
|
-
def enum_field(val)
|
67
|
-
TestUnion.new(:enum_field, val)
|
68
|
-
end
|
69
|
-
|
70
|
-
def binary_field(val)
|
71
|
-
TestUnion.new(:binary_field, val)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
STRING_FIELD = 1
|
76
|
-
I32_FIELD = 2
|
77
|
-
OTHER_I32_FIELD = 3
|
78
|
-
ENUM_FIELD = 4
|
79
|
-
BINARY_FIELD = 5
|
80
|
-
|
81
|
-
FIELDS = {
|
82
|
-
# A doc string
|
83
|
-
STRING_FIELD => {:type => ::Thrift::Types::STRING, :name => 'string_field'},
|
84
|
-
I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'i32_field'},
|
85
|
-
OTHER_I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'other_i32_field'},
|
86
|
-
ENUM_FIELD => {:type => ::Thrift::Types::I32, :name => 'enum_field', :enum_class => SpecNamespace::SomeEnum},
|
87
|
-
BINARY_FIELD => {:type => ::Thrift::Types::STRING, :name => 'binary_field', :binary => true}
|
88
|
-
}
|
89
|
-
|
90
|
-
def struct_fields; FIELDS; end
|
91
|
-
|
92
|
-
def validate
|
93
|
-
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
|
94
|
-
if get_set_field == :enum_field
|
95
|
-
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field enum_field!') unless SpecNamespace::SomeEnum::VALID_VALUES.include?(get_value)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
::Thrift::Union.generate_accessors self
|
100
|
-
end
|
101
|
-
|
102
|
-
class Foo
|
103
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
104
|
-
SIMPLE = 1
|
105
|
-
WORDS = 2
|
106
|
-
HELLO = 3
|
107
|
-
INTS = 4
|
108
|
-
COMPLEX = 5
|
109
|
-
SHORTS = 6
|
110
|
-
OPT_STRING = 7
|
111
|
-
MY_BOOL = 8
|
112
|
-
|
113
|
-
FIELDS = {
|
114
|
-
SIMPLE => {:type => ::Thrift::Types::I32, :name => 'simple', :default => 53},
|
115
|
-
WORDS => {:type => ::Thrift::Types::STRING, :name => 'words', :default => %q"words"},
|
116
|
-
HELLO => {:type => ::Thrift::Types::STRUCT, :name => 'hello', :default => SpecNamespace::Hello.new({
|
117
|
-
%q"greeting" => %q"hello, world!",
|
118
|
-
}), :class => SpecNamespace::Hello},
|
119
|
-
INTS => {:type => ::Thrift::Types::LIST, :name => 'ints', :default => [
|
120
|
-
1,
|
121
|
-
2,
|
122
|
-
2,
|
123
|
-
3,
|
124
|
-
], :element => {:type => ::Thrift::Types::I32}},
|
125
|
-
COMPLEX => {:type => ::Thrift::Types::MAP, :name => 'complex', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::DOUBLE}}},
|
126
|
-
SHORTS => {:type => ::Thrift::Types::SET, :name => 'shorts', :default => Set.new([
|
127
|
-
5,
|
128
|
-
17,
|
129
|
-
239,
|
130
|
-
]), :element => {:type => ::Thrift::Types::I16}},
|
131
|
-
OPT_STRING => {:type => ::Thrift::Types::STRING, :name => 'opt_string', :optional => true},
|
132
|
-
MY_BOOL => {:type => ::Thrift::Types::BOOL, :name => 'my_bool'}
|
133
|
-
}
|
134
|
-
|
135
|
-
def struct_fields; FIELDS; end
|
136
|
-
|
137
|
-
def validate
|
138
|
-
end
|
139
|
-
|
140
|
-
::Thrift::Struct.generate_accessors self
|
141
|
-
end
|
142
|
-
|
143
|
-
class Foo2
|
144
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
145
|
-
MY_BINARY = 1
|
146
|
-
|
147
|
-
FIELDS = {
|
148
|
-
MY_BINARY => {:type => ::Thrift::Types::STRING, :name => 'my_binary', :binary => true}
|
149
|
-
}
|
150
|
-
|
151
|
-
def struct_fields; FIELDS; end
|
152
|
-
|
153
|
-
def validate
|
154
|
-
end
|
155
|
-
|
156
|
-
::Thrift::Struct.generate_accessors self
|
157
|
-
end
|
158
|
-
|
159
|
-
class BoolStruct
|
160
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
161
|
-
YESNO = 1
|
162
|
-
|
163
|
-
FIELDS = {
|
164
|
-
YESNO => {:type => ::Thrift::Types::BOOL, :name => 'yesno', :default => true}
|
165
|
-
}
|
166
|
-
|
167
|
-
def struct_fields; FIELDS; end
|
168
|
-
|
169
|
-
def validate
|
170
|
-
end
|
171
|
-
|
172
|
-
::Thrift::Struct.generate_accessors self
|
173
|
-
end
|
174
|
-
|
175
|
-
class SimpleList
|
176
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
177
|
-
BOOLS = 1
|
178
|
-
BYTES = 2
|
179
|
-
I16S = 3
|
180
|
-
I32S = 4
|
181
|
-
I64S = 5
|
182
|
-
DOUBLES = 6
|
183
|
-
STRINGS = 7
|
184
|
-
MAPS = 8
|
185
|
-
LISTS = 9
|
186
|
-
SETS = 10
|
187
|
-
HELLOS = 11
|
188
|
-
|
189
|
-
FIELDS = {
|
190
|
-
BOOLS => {:type => ::Thrift::Types::LIST, :name => 'bools', :element => {:type => ::Thrift::Types::BOOL}},
|
191
|
-
BYTES => {:type => ::Thrift::Types::LIST, :name => 'bytes', :element => {:type => ::Thrift::Types::BYTE}},
|
192
|
-
I16S => {:type => ::Thrift::Types::LIST, :name => 'i16s', :element => {:type => ::Thrift::Types::I16}},
|
193
|
-
I32S => {:type => ::Thrift::Types::LIST, :name => 'i32s', :element => {:type => ::Thrift::Types::I32}},
|
194
|
-
I64S => {:type => ::Thrift::Types::LIST, :name => 'i64s', :element => {:type => ::Thrift::Types::I64}},
|
195
|
-
DOUBLES => {:type => ::Thrift::Types::LIST, :name => 'doubles', :element => {:type => ::Thrift::Types::DOUBLE}},
|
196
|
-
STRINGS => {:type => ::Thrift::Types::LIST, :name => 'strings', :element => {:type => ::Thrift::Types::STRING}},
|
197
|
-
MAPS => {:type => ::Thrift::Types::LIST, :name => 'maps', :element => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::I16}, :value => {:type => ::Thrift::Types::I16}}},
|
198
|
-
LISTS => {:type => ::Thrift::Types::LIST, :name => 'lists', :element => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I16}}},
|
199
|
-
SETS => {:type => ::Thrift::Types::LIST, :name => 'sets', :element => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::I16}}},
|
200
|
-
HELLOS => {:type => ::Thrift::Types::LIST, :name => 'hellos', :element => {:type => ::Thrift::Types::STRUCT, :class => SpecNamespace::Hello}}
|
201
|
-
}
|
202
|
-
|
203
|
-
def struct_fields; FIELDS; end
|
204
|
-
|
205
|
-
def validate
|
206
|
-
end
|
207
|
-
|
208
|
-
::Thrift::Struct.generate_accessors self
|
209
|
-
end
|
210
|
-
|
211
|
-
class Xception < ::Thrift::Exception
|
212
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
213
|
-
MESSAGE = 1
|
214
|
-
CODE = 2
|
215
|
-
|
216
|
-
FIELDS = {
|
217
|
-
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'},
|
218
|
-
CODE => {:type => ::Thrift::Types::I32, :name => 'code', :default => 1}
|
219
|
-
}
|
220
|
-
|
221
|
-
def struct_fields; FIELDS; end
|
222
|
-
|
223
|
-
def validate
|
224
|
-
end
|
225
|
-
|
226
|
-
::Thrift::Struct.generate_accessors self
|
227
|
-
end
|
228
|
-
|
229
|
-
class My_union < ::Thrift::Union
|
230
|
-
include ::Thrift::Struct_Union
|
231
|
-
class << self
|
232
|
-
def im_true(val)
|
233
|
-
My_union.new(:im_true, val)
|
234
|
-
end
|
235
|
-
|
236
|
-
def a_bite(val)
|
237
|
-
My_union.new(:a_bite, val)
|
238
|
-
end
|
239
|
-
|
240
|
-
def integer16(val)
|
241
|
-
My_union.new(:integer16, val)
|
242
|
-
end
|
243
|
-
|
244
|
-
def integer32(val)
|
245
|
-
My_union.new(:integer32, val)
|
246
|
-
end
|
247
|
-
|
248
|
-
def integer64(val)
|
249
|
-
My_union.new(:integer64, val)
|
250
|
-
end
|
251
|
-
|
252
|
-
def double_precision(val)
|
253
|
-
My_union.new(:double_precision, val)
|
254
|
-
end
|
255
|
-
|
256
|
-
def some_characters(val)
|
257
|
-
My_union.new(:some_characters, val)
|
258
|
-
end
|
259
|
-
|
260
|
-
def other_i32(val)
|
261
|
-
My_union.new(:other_i32, val)
|
262
|
-
end
|
263
|
-
|
264
|
-
def some_enum(val)
|
265
|
-
My_union.new(:some_enum, val)
|
266
|
-
end
|
267
|
-
|
268
|
-
def my_map(val)
|
269
|
-
My_union.new(:my_map, val)
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
IM_TRUE = 1
|
274
|
-
A_BITE = 2
|
275
|
-
INTEGER16 = 3
|
276
|
-
INTEGER32 = 4
|
277
|
-
INTEGER64 = 5
|
278
|
-
DOUBLE_PRECISION = 6
|
279
|
-
SOME_CHARACTERS = 7
|
280
|
-
OTHER_I32 = 8
|
281
|
-
SOME_ENUM = 9
|
282
|
-
MY_MAP = 10
|
283
|
-
|
284
|
-
FIELDS = {
|
285
|
-
IM_TRUE => {:type => ::Thrift::Types::BOOL, :name => 'im_true'},
|
286
|
-
A_BITE => {:type => ::Thrift::Types::BYTE, :name => 'a_bite'},
|
287
|
-
INTEGER16 => {:type => ::Thrift::Types::I16, :name => 'integer16'},
|
288
|
-
INTEGER32 => {:type => ::Thrift::Types::I32, :name => 'integer32'},
|
289
|
-
INTEGER64 => {:type => ::Thrift::Types::I64, :name => 'integer64'},
|
290
|
-
DOUBLE_PRECISION => {:type => ::Thrift::Types::DOUBLE, :name => 'double_precision'},
|
291
|
-
SOME_CHARACTERS => {:type => ::Thrift::Types::STRING, :name => 'some_characters'},
|
292
|
-
OTHER_I32 => {:type => ::Thrift::Types::I32, :name => 'other_i32'},
|
293
|
-
SOME_ENUM => {:type => ::Thrift::Types::I32, :name => 'some_enum', :enum_class => SpecNamespace::SomeEnum},
|
294
|
-
MY_MAP => {:type => ::Thrift::Types::MAP, :name => 'my_map', :key => {:type => ::Thrift::Types::I32, :enum_class => SpecNamespace::SomeEnum}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32, :enum_class => SpecNamespace::SomeEnum}}}
|
295
|
-
}
|
296
|
-
|
297
|
-
def struct_fields; FIELDS; end
|
298
|
-
|
299
|
-
def validate
|
300
|
-
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
|
301
|
-
if get_set_field == :some_enum
|
302
|
-
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field some_enum!') unless SpecNamespace::SomeEnum::VALID_VALUES.include?(get_value)
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
::Thrift::Union.generate_accessors self
|
307
|
-
end
|
308
|
-
|
309
|
-
class Struct_with_union
|
310
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
311
|
-
FUN_UNION = 1
|
312
|
-
INTEGER32 = 2
|
313
|
-
SOME_CHARACTERS = 3
|
314
|
-
|
315
|
-
FIELDS = {
|
316
|
-
FUN_UNION => {:type => ::Thrift::Types::STRUCT, :name => 'fun_union', :class => SpecNamespace::My_union},
|
317
|
-
INTEGER32 => {:type => ::Thrift::Types::I32, :name => 'integer32'},
|
318
|
-
SOME_CHARACTERS => {:type => ::Thrift::Types::STRING, :name => 'some_characters'}
|
319
|
-
}
|
320
|
-
|
321
|
-
def struct_fields; FIELDS; end
|
322
|
-
|
323
|
-
def validate
|
324
|
-
end
|
325
|
-
|
326
|
-
::Thrift::Struct.generate_accessors self
|
327
|
-
end
|
328
|
-
|
329
|
-
class StructWithEnumMap
|
330
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
331
|
-
MY_MAP = 1
|
332
|
-
|
333
|
-
FIELDS = {
|
334
|
-
MY_MAP => {:type => ::Thrift::Types::MAP, :name => 'my_map', :key => {:type => ::Thrift::Types::I32, :enum_class => SpecNamespace::SomeEnum}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32, :enum_class => SpecNamespace::SomeEnum}}}
|
335
|
-
}
|
336
|
-
|
337
|
-
def struct_fields; FIELDS; end
|
338
|
-
|
339
|
-
def validate
|
340
|
-
end
|
341
|
-
|
342
|
-
::Thrift::Struct.generate_accessors self
|
343
|
-
end
|
344
|
-
|
345
|
-
end
|