upfluence-thrift 1.1.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/extconf.rb +1 -4
- data/lib/thrift/client.rb +31 -1
- data/lib/thrift/definition.rb +64 -0
- data/lib/thrift/exceptions.rb +5 -5
- data/lib/thrift/middleware.rb +50 -0
- data/lib/thrift/processor.rb +3 -3
- data/lib/thrift/struct.rb +10 -10
- data/lib/thrift/transport/base_transport.rb +9 -7
- data/lib/thrift/transport/server_socket.rb +6 -6
- data/lib/thrift/types/known/any.rb +179 -0
- data/lib/thrift/types/known/any_constants.rb +17 -0
- data/lib/thrift/types/known/any_types.rb +43 -0
- data/lib/thrift/types/known/duration.rb +27 -0
- data/lib/thrift/types/known/duration_constants.rb +17 -0
- data/lib/thrift/types/known/duration_types.rb +43 -0
- data/lib/thrift/types/known/timestamp.rb +31 -0
- data/lib/thrift/types/known/timestamp_constants.rb +17 -0
- data/lib/thrift/types/known/timestamp_types.rb +43 -0
- data/lib/thrift/types/value.rb +114 -0
- data/lib/thrift/types/value_constants.rb +15 -0
- data/lib/thrift/types/value_types.rb +213 -0
- data/lib/thrift/types.rb +4 -4
- data/lib/thrift.rb +6 -4
- data/spec/binary_protocol_spec_shared.rb +57 -60
- data/spec/client_spec.rb +2 -2
- data/spec/compact_protocol_spec.rb +26 -20
- data/spec/http_client_spec.rb +7 -20
- data/spec/nonblocking_server_spec.rb +1 -1
- data/spec/processor_spec.rb +1 -1
- data/spec/struct_spec.rb +2 -2
- data/spec/types/known/any_spec.rb +44 -0
- data/spec/types/known/duration_spec.rb +20 -0
- data/spec/types/known/timestamp_spec.rb +17 -0
- data/spec/types/value_spec.rb +43 -0
- data/spec/types_spec.rb +2 -2
- metadata +114 -150
- data/benchmark/gen-rb/benchmark_constants.rb +0 -11
- data/benchmark/gen-rb/benchmark_service.rb +0 -91
- data/benchmark/gen-rb/benchmark_types.rb +0 -10
- data/spec/gen-rb/base/base_service.rb +0 -91
- data/spec/gen-rb/base/base_service_constants.rb +0 -11
- data/spec/gen-rb/base/base_service_types.rb +0 -26
- data/spec/gen-rb/extended/extended_service.rb +0 -89
- data/spec/gen-rb/extended/extended_service_constants.rb +0 -11
- data/spec/gen-rb/extended/extended_service_types.rb +0 -12
- data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +0 -299
- data/spec/gen-rb/flat/referenced_constants.rb +0 -11
- data/spec/gen-rb/flat/referenced_types.rb +0 -17
- data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +0 -11
- data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +0 -28
- data/spec/gen-rb/namespaced_spec_namespace/namespaced_nonblocking_service.rb +0 -299
- data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +0 -11
- data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +0 -28
- data/spec/gen-rb/nonblocking_service.rb +0 -299
- data/spec/gen-rb/other_namespace/referenced_constants.rb +0 -11
- data/spec/gen-rb/other_namespace/referenced_types.rb +0 -17
- data/spec/gen-rb/thrift_spec_constants.rb +0 -11
- data/spec/gen-rb/thrift_spec_types.rb +0 -538
- data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +0 -274
- data/test/debug_proto/gen-rb/debug_proto_test_types.rb +0 -761
- data/test/debug_proto/gen-rb/empty_service.rb +0 -31
- data/test/debug_proto/gen-rb/inherited.rb +0 -90
- data/test/debug_proto/gen-rb/reverse_order_service.rb +0 -93
- data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +0 -92
- data/test/debug_proto/gen-rb/srv.rb +0 -361
@@ -0,0 +1,17 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (2.3.0-upfluence)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
require 'duration_types'
|
9
|
+
|
10
|
+
module Thrift
|
11
|
+
module Types
|
12
|
+
module Known
|
13
|
+
module Duration
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (2.3.0-upfluence)
|
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 Types
|
11
|
+
module Known
|
12
|
+
module Duration
|
13
|
+
class Duration; end
|
14
|
+
|
15
|
+
class Duration
|
16
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
17
|
+
|
18
|
+
NAME = 'Duration'.freeze
|
19
|
+
NAMESPACE = 'types.known.duration'.freeze
|
20
|
+
|
21
|
+
THRIFT_FIELD_INDEX_SECONDS = 1
|
22
|
+
THRIFT_FIELD_INDEX_NANOS = 2
|
23
|
+
|
24
|
+
FIELDS = {
|
25
|
+
THRIFT_FIELD_INDEX_SECONDS => {type: ::Thrift::Types::I64, name: 'seconds'},
|
26
|
+
THRIFT_FIELD_INDEX_NANOS => {type: ::Thrift::Types::I32, name: 'nanos'}
|
27
|
+
}
|
28
|
+
|
29
|
+
def struct_fields; FIELDS; end
|
30
|
+
|
31
|
+
def validate
|
32
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field seconds is unset!') unless @seconds
|
33
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field nanos is unset!') unless @nanos
|
34
|
+
end
|
35
|
+
|
36
|
+
::Thrift::Struct.generate_accessors self
|
37
|
+
::Thrift.register_struct_type self
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'thrift/types/known/timestamp_types'
|
2
|
+
|
3
|
+
module Thrift
|
4
|
+
module Types
|
5
|
+
module Known
|
6
|
+
module Timestamp
|
7
|
+
class << self
|
8
|
+
def from_time(v)
|
9
|
+
Timestamp.from_time(v)
|
10
|
+
end
|
11
|
+
|
12
|
+
def now
|
13
|
+
from_time(Time.now)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Timestamp
|
18
|
+
class << self
|
19
|
+
def from_time(v)
|
20
|
+
Timestamp.new(seconds: v.to_i, nanos: v.nsec)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_time
|
25
|
+
Time.at(seconds, nanos, :nsec)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (2.3.0-upfluence)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
require 'timestamp_types'
|
9
|
+
|
10
|
+
module Thrift
|
11
|
+
module Types
|
12
|
+
module Known
|
13
|
+
module Timestamp
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (2.3.0-upfluence)
|
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 Types
|
11
|
+
module Known
|
12
|
+
module Timestamp
|
13
|
+
class Timestamp; end
|
14
|
+
|
15
|
+
class Timestamp
|
16
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
17
|
+
|
18
|
+
NAME = 'Timestamp'.freeze
|
19
|
+
NAMESPACE = 'types.known.timestamp'.freeze
|
20
|
+
|
21
|
+
THRIFT_FIELD_INDEX_SECONDS = 1
|
22
|
+
THRIFT_FIELD_INDEX_NANOS = 2
|
23
|
+
|
24
|
+
FIELDS = {
|
25
|
+
THRIFT_FIELD_INDEX_SECONDS => {type: ::Thrift::Types::I64, name: 'seconds'},
|
26
|
+
THRIFT_FIELD_INDEX_NANOS => {type: ::Thrift::Types::I32, name: 'nanos'}
|
27
|
+
}
|
28
|
+
|
29
|
+
def struct_fields; FIELDS; end
|
30
|
+
|
31
|
+
def validate
|
32
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field seconds is unset!') unless @seconds
|
33
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field nanos is unset!') unless @nanos
|
34
|
+
end
|
35
|
+
|
36
|
+
::Thrift::Struct.generate_accessors self
|
37
|
+
::Thrift.register_struct_type self
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'thrift/types/value_types'
|
2
|
+
|
3
|
+
module Thrift
|
4
|
+
module Types
|
5
|
+
module Value
|
6
|
+
class ListValue
|
7
|
+
def to_array
|
8
|
+
values.map(&:to_object)
|
9
|
+
end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def from_array(v)
|
13
|
+
ListValue.new(values: v.map { |vv| Value.from_object(vv) })
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class MapValue
|
19
|
+
def to_hash
|
20
|
+
entries.reduce({}) do |acc, e|
|
21
|
+
acc.merge(e.key.to_object => e.value.to_object)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class << self
|
26
|
+
def from_hash(v)
|
27
|
+
MapValue.new(
|
28
|
+
entries: v.reduce([]) do |acc, (k, vv)|
|
29
|
+
acc + [
|
30
|
+
MapEntry.new(
|
31
|
+
key: Value.from_object(k),
|
32
|
+
value: Value.from_object(vv)
|
33
|
+
)
|
34
|
+
]
|
35
|
+
end
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class StructValue
|
42
|
+
def to_hash
|
43
|
+
fields.reduce({}) do |acc, (k, v)|
|
44
|
+
acc.merge(k => v.to_object)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class << self
|
49
|
+
def from_object(v)
|
50
|
+
StructValue.new(
|
51
|
+
fields: v.instance_variables.reduce({}) do |acc, k|
|
52
|
+
acc.merge(
|
53
|
+
k.to_s[1..-1] => Value.from_object(v.instance_variable_get(k))
|
54
|
+
)
|
55
|
+
end
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class << self
|
62
|
+
def from_object(v)
|
63
|
+
Value.from_object(v)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class Value
|
68
|
+
def to_object
|
69
|
+
case get_value.class
|
70
|
+
when NullValue
|
71
|
+
nil
|
72
|
+
when ListValue
|
73
|
+
list_value.to_array
|
74
|
+
when MapValue
|
75
|
+
map_value.to_hash
|
76
|
+
when StructValue
|
77
|
+
struct_value.to_hash
|
78
|
+
else
|
79
|
+
get_value
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class << self
|
84
|
+
def from_object(v)
|
85
|
+
case v
|
86
|
+
when NilClass
|
87
|
+
Value.new(null_value: NullValue.new)
|
88
|
+
when Symbol
|
89
|
+
Value.new(string_value: v.to_s)
|
90
|
+
when String
|
91
|
+
if v.encoding.eql?(Encoding::UTF_8) && v.valid_encoding?
|
92
|
+
Value.new(string_value: v)
|
93
|
+
else
|
94
|
+
Value.new(binary_value: v)
|
95
|
+
end
|
96
|
+
when Integer
|
97
|
+
Value.new(integer_value: v)
|
98
|
+
when Float
|
99
|
+
Value.new(double_value: v)
|
100
|
+
when TrueClass, FalseClass
|
101
|
+
Value.new(bool_value: v)
|
102
|
+
when Array
|
103
|
+
Value.new(list_value: ListValue.from_array(v))
|
104
|
+
when Hash
|
105
|
+
Value.new(map_value: MapValue.from_hash(v))
|
106
|
+
else
|
107
|
+
Value.new(struct_value: StructValue.from_object(v))
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (2.3.0-upfluence)
|
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 Types
|
11
|
+
module Value
|
12
|
+
class NullValue; end
|
13
|
+
|
14
|
+
class ListValue; end
|
15
|
+
|
16
|
+
class MapEntry; end
|
17
|
+
|
18
|
+
class MapValue; end
|
19
|
+
|
20
|
+
class StructValue; end
|
21
|
+
|
22
|
+
class Value < ::Thrift::Union; end
|
23
|
+
|
24
|
+
class NullValue
|
25
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
26
|
+
|
27
|
+
NAME = 'NullValue'.freeze
|
28
|
+
NAMESPACE = 'types.value'.freeze
|
29
|
+
|
30
|
+
|
31
|
+
FIELDS = {
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
def struct_fields; FIELDS; end
|
36
|
+
|
37
|
+
def validate
|
38
|
+
end
|
39
|
+
|
40
|
+
::Thrift::Struct.generate_accessors self
|
41
|
+
::Thrift.register_struct_type self
|
42
|
+
end
|
43
|
+
|
44
|
+
class ListValue
|
45
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
46
|
+
|
47
|
+
NAME = 'ListValue'.freeze
|
48
|
+
NAMESPACE = 'types.value'.freeze
|
49
|
+
|
50
|
+
THRIFT_FIELD_INDEX_VALUES = 1
|
51
|
+
|
52
|
+
FIELDS = {
|
53
|
+
THRIFT_FIELD_INDEX_VALUES => {type: ::Thrift::Types::LIST, name: 'values', element: {type: ::Thrift::Types::STRUCT, class: ::Thrift::Types::Value::Value}}
|
54
|
+
}
|
55
|
+
|
56
|
+
def struct_fields; FIELDS; end
|
57
|
+
|
58
|
+
def validate
|
59
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field values is unset!') unless @values
|
60
|
+
end
|
61
|
+
|
62
|
+
::Thrift::Struct.generate_accessors self
|
63
|
+
::Thrift.register_struct_type self
|
64
|
+
end
|
65
|
+
|
66
|
+
class MapEntry
|
67
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
68
|
+
|
69
|
+
NAME = 'MapEntry'.freeze
|
70
|
+
NAMESPACE = 'types.value'.freeze
|
71
|
+
|
72
|
+
THRIFT_FIELD_INDEX_KEY = 1
|
73
|
+
THRIFT_FIELD_INDEX_VALUE = 2
|
74
|
+
|
75
|
+
FIELDS = {
|
76
|
+
THRIFT_FIELD_INDEX_KEY => {type: ::Thrift::Types::STRUCT, name: 'key', class: ::Thrift::Types::Value::Value},
|
77
|
+
THRIFT_FIELD_INDEX_VALUE => {type: ::Thrift::Types::STRUCT, name: 'value', class: ::Thrift::Types::Value::Value}
|
78
|
+
}
|
79
|
+
|
80
|
+
def struct_fields; FIELDS; end
|
81
|
+
|
82
|
+
def validate
|
83
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field key is unset!') unless @key
|
84
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field value is unset!') unless @value
|
85
|
+
end
|
86
|
+
|
87
|
+
::Thrift::Struct.generate_accessors self
|
88
|
+
::Thrift.register_struct_type self
|
89
|
+
end
|
90
|
+
|
91
|
+
class MapValue
|
92
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
93
|
+
|
94
|
+
NAME = 'MapValue'.freeze
|
95
|
+
NAMESPACE = 'types.value'.freeze
|
96
|
+
|
97
|
+
THRIFT_FIELD_INDEX_ENTRIES = 1
|
98
|
+
|
99
|
+
FIELDS = {
|
100
|
+
THRIFT_FIELD_INDEX_ENTRIES => {type: ::Thrift::Types::LIST, name: 'entries', element: {type: ::Thrift::Types::STRUCT, class: ::Thrift::Types::Value::MapEntry}}
|
101
|
+
}
|
102
|
+
|
103
|
+
def struct_fields; FIELDS; end
|
104
|
+
|
105
|
+
def validate
|
106
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field entries is unset!') unless @entries
|
107
|
+
end
|
108
|
+
|
109
|
+
::Thrift::Struct.generate_accessors self
|
110
|
+
::Thrift.register_struct_type self
|
111
|
+
end
|
112
|
+
|
113
|
+
class StructValue
|
114
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
115
|
+
|
116
|
+
NAME = 'StructValue'.freeze
|
117
|
+
NAMESPACE = 'types.value'.freeze
|
118
|
+
|
119
|
+
THRIFT_FIELD_INDEX_FIELDS = 1
|
120
|
+
|
121
|
+
FIELDS = {
|
122
|
+
THRIFT_FIELD_INDEX_FIELDS => {type: ::Thrift::Types::MAP, name: 'fields', key: {type: ::Thrift::Types::STRING}, value: {type: ::Thrift::Types::STRUCT, class: ::Thrift::Types::Value::Value}}
|
123
|
+
}
|
124
|
+
|
125
|
+
def struct_fields; FIELDS; end
|
126
|
+
|
127
|
+
def validate
|
128
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field fields is unset!') unless @fields
|
129
|
+
end
|
130
|
+
|
131
|
+
::Thrift::Struct.generate_accessors self
|
132
|
+
::Thrift.register_struct_type self
|
133
|
+
end
|
134
|
+
|
135
|
+
class Value < ::Thrift::Union
|
136
|
+
include ::Thrift::Struct_Union
|
137
|
+
|
138
|
+
NAME = 'Value'.freeze
|
139
|
+
NAMESPACE = 'types.value'.freeze
|
140
|
+
|
141
|
+
class << self
|
142
|
+
def null_value(val)
|
143
|
+
Value.new(:null_value, val)
|
144
|
+
end
|
145
|
+
|
146
|
+
def string_value(val)
|
147
|
+
Value.new(:string_value, val)
|
148
|
+
end
|
149
|
+
|
150
|
+
def binary_value(val)
|
151
|
+
Value.new(:binary_value, val)
|
152
|
+
end
|
153
|
+
|
154
|
+
def integer_value(val)
|
155
|
+
Value.new(:integer_value, val)
|
156
|
+
end
|
157
|
+
|
158
|
+
def double_value(val)
|
159
|
+
Value.new(:double_value, val)
|
160
|
+
end
|
161
|
+
|
162
|
+
def bool_value(val)
|
163
|
+
Value.new(:bool_value, val)
|
164
|
+
end
|
165
|
+
|
166
|
+
def list_value(val)
|
167
|
+
Value.new(:list_value, val)
|
168
|
+
end
|
169
|
+
|
170
|
+
def map_value(val)
|
171
|
+
Value.new(:map_value, val)
|
172
|
+
end
|
173
|
+
|
174
|
+
def struct_value(val)
|
175
|
+
Value.new(:struct_value, val)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
THRIFT_FIELD_INDEX_NULL_VALUE = 1
|
180
|
+
THRIFT_FIELD_INDEX_STRING_VALUE = 2
|
181
|
+
THRIFT_FIELD_INDEX_BINARY_VALUE = 3
|
182
|
+
THRIFT_FIELD_INDEX_INTEGER_VALUE = 4
|
183
|
+
THRIFT_FIELD_INDEX_DOUBLE_VALUE = 5
|
184
|
+
THRIFT_FIELD_INDEX_BOOL_VALUE = 6
|
185
|
+
THRIFT_FIELD_INDEX_LIST_VALUE = 7
|
186
|
+
THRIFT_FIELD_INDEX_MAP_VALUE = 8
|
187
|
+
THRIFT_FIELD_INDEX_STRUCT_VALUE = 9
|
188
|
+
|
189
|
+
FIELDS = {
|
190
|
+
THRIFT_FIELD_INDEX_NULL_VALUE => {type: ::Thrift::Types::STRUCT, name: 'null_value', class: ::Thrift::Types::Value::NullValue},
|
191
|
+
THRIFT_FIELD_INDEX_STRING_VALUE => {type: ::Thrift::Types::STRING, name: 'string_value'},
|
192
|
+
THRIFT_FIELD_INDEX_BINARY_VALUE => {type: ::Thrift::Types::STRING, name: 'binary_value', binary: true},
|
193
|
+
THRIFT_FIELD_INDEX_INTEGER_VALUE => {type: ::Thrift::Types::I64, name: 'integer_value'},
|
194
|
+
THRIFT_FIELD_INDEX_DOUBLE_VALUE => {type: ::Thrift::Types::DOUBLE, name: 'double_value'},
|
195
|
+
THRIFT_FIELD_INDEX_BOOL_VALUE => {type: ::Thrift::Types::BOOL, name: 'bool_value'},
|
196
|
+
THRIFT_FIELD_INDEX_LIST_VALUE => {type: ::Thrift::Types::STRUCT, name: 'list_value', class: ::Thrift::Types::Value::ListValue},
|
197
|
+
THRIFT_FIELD_INDEX_MAP_VALUE => {type: ::Thrift::Types::STRUCT, name: 'map_value', class: ::Thrift::Types::Value::MapValue},
|
198
|
+
THRIFT_FIELD_INDEX_STRUCT_VALUE => {type: ::Thrift::Types::STRUCT, name: 'struct_value', class: ::Thrift::Types::Value::StructValue}
|
199
|
+
}
|
200
|
+
|
201
|
+
def struct_fields; FIELDS; end
|
202
|
+
|
203
|
+
def validate
|
204
|
+
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
|
205
|
+
end
|
206
|
+
|
207
|
+
::Thrift::Union.generate_accessors self
|
208
|
+
::Thrift.register_struct_type self
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
data/lib/thrift/types.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
#
|
2
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
3
|
# or more contributor license agreements. See the NOTICE file
|
4
4
|
# distributed with this work for additional information
|
@@ -6,16 +6,16 @@
|
|
6
6
|
# to you under the Apache License, Version 2.0 (the
|
7
7
|
# "License"); you may not use this file except in compliance
|
8
8
|
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing,
|
13
13
|
# software distributed under the License is distributed on an
|
14
14
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
15
|
# KIND, either express or implied. See the License for the
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
|
20
20
|
require 'set'
|
21
21
|
|
data/lib/thrift.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
#
|
2
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
3
|
# or more contributor license agreements. See the NOTICE file
|
4
4
|
# distributed with this work for additional information
|
@@ -6,28 +6,30 @@
|
|
6
6
|
# to you under the Apache License, Version 2.0 (the
|
7
7
|
# "License"); you may not use this file except in compliance
|
8
8
|
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing,
|
13
13
|
# software distributed under the License is distributed on an
|
14
14
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
15
|
# KIND, either express or implied. See the License for the
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
# Contains some contributions under the Thrift Software License.
|
20
20
|
# Please see doc/old-thrift-license.txt in the Thrift distribution for
|
21
21
|
# details.
|
22
22
|
|
23
23
|
$:.unshift File.dirname(__FILE__)
|
24
24
|
|
25
|
+
require 'thrift/definition'
|
25
26
|
require 'thrift/bytes'
|
26
27
|
require 'thrift/core_ext'
|
27
28
|
require 'thrift/exceptions'
|
28
29
|
require 'thrift/types'
|
29
30
|
require 'thrift/processor'
|
30
31
|
require 'thrift/multiplexed_processor'
|
32
|
+
require 'thrift/middleware'
|
31
33
|
require 'thrift/client'
|
32
34
|
require 'thrift/struct'
|
33
35
|
require 'thrift/union'
|