upfluence-thrift 2.6.1 → 2.7.4
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/benchmark/benchmark_constants.rb +11 -0
- data/benchmark/benchmark_service.rb +152 -0
- data/benchmark/benchmark_types.rb +10 -0
- data/ext/struct.c +5 -1
- data/lib/thrift/base_stream.rb +85 -0
- data/lib/thrift/bidi_stream.rb +183 -0
- data/lib/thrift/client.rb +84 -17
- data/lib/thrift/definition.rb +4 -0
- data/lib/thrift/inbound_stream.rb +72 -0
- data/lib/thrift/middleware.rb +42 -0
- data/lib/thrift/outbound_stream.rb +52 -0
- data/lib/thrift/processor.rb +287 -47
- data/lib/thrift/protocol/base_protocol.rb +35 -33
- data/lib/thrift/protocol/binary_protocol.rb +8 -1
- data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
- data/lib/thrift/protocol/compact_protocol.rb +8 -0
- data/lib/thrift/protocol/json_protocol.rb +21 -4
- data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
- data/lib/thrift/server/base_server.rb +8 -2
- data/lib/thrift/server/nonblocking_server.rb +5 -4
- data/lib/thrift/server/simple_server.rb +5 -1
- data/lib/thrift/server/thread_pool_server.rb +5 -1
- data/lib/thrift/server/threaded_server.rb +5 -1
- data/lib/thrift/transport/base_server_transport.rb +1 -1
- data/lib/thrift/transport/base_transport.rb +8 -0
- data/lib/thrift/transport/buffered_transport.rb +9 -1
- data/lib/thrift/transport/framed_transport.rb +9 -1
- data/lib/thrift/transport/http_client_transport.rb +4 -0
- data/lib/thrift/transport/io_stream_transport.rb +4 -1
- data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
- data/lib/thrift/transport/server_socket.rb +5 -0
- data/lib/thrift/transport/socket.rb +21 -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/types/annotation/deprecation/deprecation_constants.rb +1 -1
- data/lib/thrift/types/annotation/deprecation/deprecation_types.rb +2 -2
- data/lib/thrift/types/annotation/exception/exception_constants.rb +17 -0
- data/lib/thrift/types/annotation/exception/exception_types.rb +44 -0
- data/lib/thrift/types/annotation/naming/naming_constants.rb +1 -1
- data/lib/thrift/types/annotation/naming/naming_types.rb +2 -2
- data/lib/thrift/types/annotation/rpc/rpc_constants.rb +17 -0
- data/lib/thrift/types/annotation/rpc/rpc_types.rb +74 -0
- data/lib/thrift/types/annotation_definition/annotation_definition_constants.rb +15 -0
- data/lib/thrift/types/annotation_definition/annotation_definition_types.rb +116 -0
- data/lib/thrift/types/constant_definition/constant_definition_constants.rb +15 -0
- data/lib/thrift/types/constant_definition/constant_definition_types.rb +292 -0
- data/lib/thrift/types/core/core_constants.rb +15 -0
- data/lib/thrift/types/core/core_types.rb +58 -0
- data/lib/thrift/types/enum_definition/enum_definition_constants.rb +15 -0
- data/lib/thrift/types/enum_definition/enum_definition_types.rb +106 -0
- data/lib/thrift/types/known/any/any_constants.rb +1 -1
- data/lib/thrift/types/known/any/any_types.rb +2 -2
- data/lib/thrift/types/known/duration/duration_constants.rb +1 -1
- data/lib/thrift/types/known/duration/duration_types.rb +2 -2
- data/lib/thrift/types/known/timestamp/timestamp_constants.rb +1 -1
- data/lib/thrift/types/known/timestamp/timestamp_types.rb +2 -2
- data/lib/thrift/types/plugin/plugin.rb +139 -0
- data/lib/thrift/types/plugin/plugin_constants.rb +15 -0
- data/lib/thrift/types/plugin/plugin_types.rb +106 -0
- data/lib/thrift/types/program_definition/program_definition_constants.rb +15 -0
- data/lib/thrift/types/program_definition/program_definition_types.rb +137 -0
- data/lib/thrift/types/service_definition/service_definition_constants.rb +15 -0
- data/lib/thrift/types/service_definition/service_definition_types.rb +160 -0
- data/lib/thrift/types/struct_definition/struct_definition_constants.rb +15 -0
- data/lib/thrift/types/struct_definition/struct_definition_types.rb +157 -0
- data/lib/thrift/types/type_definition/type_definition_constants.rb +15 -0
- data/lib/thrift/types/type_definition/type_definition_types.rb +242 -0
- data/lib/thrift/types/value/value_constants.rb +1 -1
- data/lib/thrift/types/value/value_types.rb +50 -51
- data/lib/thrift/types.rb +11 -3
- data/lib/thrift/union.rb +3 -6
- data/lib/thrift.rb +6 -0
- data/lib/types/annotation/deprecation/deprecation_constants.rb +16 -0
- data/lib/types/annotation/deprecation/deprecation_types.rb +42 -0
- data/lib/types/annotation/naming/naming_constants.rb +16 -0
- data/lib/types/annotation/naming/naming_types.rb +57 -0
- data/lib/types/annotation_definition/annotation_definition_constants.rb +14 -0
- data/lib/types/annotation_definition/annotation_definition_types.rb +114 -0
- data/lib/types/constant_definition/constant_definition_constants.rb +14 -0
- data/lib/types/constant_definition/constant_definition_types.rb +290 -0
- data/lib/types/core/core_constants.rb +14 -0
- data/lib/types/core/core_types.rb +56 -0
- data/lib/types/enum_definition/enum_definition_constants.rb +14 -0
- data/lib/types/enum_definition/enum_definition_types.rb +104 -0
- data/lib/types/known/any/any_constants.rb +16 -0
- data/lib/types/known/any/any_types.rb +59 -0
- data/lib/types/known/duration/duration_constants.rb +16 -0
- data/lib/types/known/duration/duration_types.rb +59 -0
- data/lib/types/known/timestamp/timestamp_constants.rb +16 -0
- data/lib/types/known/timestamp/timestamp_types.rb +59 -0
- data/lib/types/plugin/plugin.rb +137 -0
- data/lib/types/plugin/plugin_constants.rb +14 -0
- data/lib/types/plugin/plugin_types.rb +104 -0
- data/lib/types/program_definition/program_definition_constants.rb +14 -0
- data/lib/types/program_definition/program_definition_types.rb +135 -0
- data/lib/types/service_definition/service_definition_constants.rb +14 -0
- data/lib/types/service_definition/service_definition_types.rb +158 -0
- data/lib/types/struct_definition/struct_definition_constants.rb +14 -0
- data/lib/types/struct_definition/struct_definition_types.rb +155 -0
- data/lib/types/type_definition/type_definition_constants.rb +14 -0
- data/lib/types/type_definition/type_definition_types.rb +240 -0
- data/lib/types/value/value_constants.rb +14 -0
- data/lib/types/value/value_types.rb +330 -0
- data/spec/base/base_service.rb +152 -0
- data/spec/base/base_service_constants.rb +11 -0
- data/spec/base/base_service_types.rb +45 -0
- data/spec/base_protocol_spec.rb +79 -71
- data/spec/base_transport_spec.rb +155 -117
- data/spec/binary_protocol_accelerated_spec.rb +6 -2
- data/spec/binary_protocol_spec.rb +16 -8
- data/spec/binary_protocol_spec_shared.rb +77 -77
- data/spec/bytes_spec.rb +38 -38
- data/spec/client_spec.rb +48 -50
- data/spec/compact_protocol_spec.rb +59 -46
- data/spec/exception_spec.rb +54 -54
- data/spec/extended/extended_service.rb +137 -0
- data/spec/extended/extended_service_constants.rb +11 -0
- data/spec/extended/extended_service_types.rb +12 -0
- data/spec/flat_spec.rb +5 -5
- data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +507 -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 +47 -0
- data/spec/http_client_spec.rb +96 -43
- data/spec/json_protocol_spec.rb +170 -131
- data/spec/namespaced_spec.rb +24 -27
- data/spec/namespaced_spec_namespace/namespaced_nonblocking_service.rb +507 -0
- data/spec/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +11 -0
- data/spec/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +47 -0
- data/spec/nonblocking_server_spec.rb +16 -16
- data/spec/nonblocking_service.rb +507 -0
- data/spec/other_namespace/referenced_constants.rb +11 -0
- data/spec/other_namespace/referenced_types.rb +17 -0
- data/spec/processor_spec.rb +42 -31
- data/spec/rack_application_spec.rb +22 -26
- data/spec/serializer_spec.rb +20 -20
- data/spec/server_socket_spec.rb +27 -22
- data/spec/server_spec.rb +91 -51
- data/spec/socket_spec.rb +23 -16
- data/spec/socket_spec_shared.rb +31 -31
- data/spec/spec_helper.rb +17 -17
- data/spec/ssl_server_socket_spec.rb +34 -0
- data/spec/ssl_socket_spec.rb +78 -0
- data/spec/streaming_spec.rb +442 -0
- data/spec/struct_nested_containers_spec.rb +24 -24
- data/spec/struct_spec.rb +120 -120
- data/spec/thin_http_server_spec.rb +71 -28
- data/spec/thrift_spec_constants.rb +11 -0
- data/spec/thrift_spec_types.rb +1173 -0
- data/spec/types/known/any_spec.rb +2 -2
- data/spec/types/known/duration_spec.rb +1 -1
- data/spec/types/known/timestamp_spec.rb +1 -1
- data/spec/types/value_spec.rb +2 -1
- data/spec/types_spec.rb +56 -53
- data/spec/union_spec.rb +51 -40
- data/spec/unix_socket_spec.rb +43 -34
- data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +281 -0
- data/test/debug_proto/gen-rb/debug_proto_test_types.rb +2033 -0
- data/test/debug_proto/gen-rb/empty_service.rb +52 -0
- data/test/debug_proto/gen-rb/inherited.rb +155 -0
- data/test/debug_proto/gen-rb/reverse_order_service.rb +169 -0
- data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +150 -0
- data/test/debug_proto/gen-rb/srv.rb +718 -0
- metadata +202 -7
data/spec/http_client_spec.rb
CHANGED
|
@@ -20,88 +20,141 @@
|
|
|
20
20
|
require 'spec_helper'
|
|
21
21
|
|
|
22
22
|
describe 'Thrift::HTTPClientTransport' do
|
|
23
|
-
|
|
24
23
|
describe Thrift::HTTPClientTransport do
|
|
25
24
|
before(:each) do
|
|
26
25
|
@client = Thrift::HTTPClientTransport.new(
|
|
27
|
-
|
|
26
|
+
'http://my.domain.com/path/to/service?param=value',
|
|
28
27
|
retries: 0
|
|
29
28
|
)
|
|
30
29
|
end
|
|
31
30
|
|
|
32
|
-
it
|
|
33
|
-
@client.
|
|
31
|
+
it 'should provide a reasonable to_s' do
|
|
32
|
+
@client.to_s == 'http://my.domain.com/path/to/service?param=value'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should always be open' do
|
|
36
|
+
expect(@client).to be_open
|
|
34
37
|
@client.close
|
|
35
|
-
@client.
|
|
38
|
+
expect(@client).to be_open
|
|
36
39
|
end
|
|
37
40
|
|
|
38
|
-
it
|
|
39
|
-
@client.write
|
|
40
|
-
@client.write
|
|
41
|
-
Net::HTTP.
|
|
42
|
-
|
|
43
|
-
http.
|
|
44
|
-
http.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
response.
|
|
41
|
+
it 'should post via HTTP and return the results' do
|
|
42
|
+
@client.write 'a test'
|
|
43
|
+
@client.write ' frame'
|
|
44
|
+
expect(Net::HTTP).to receive(:new).with('my.domain.com', 80) do
|
|
45
|
+
double('Net::HTTP').tap do |http|
|
|
46
|
+
expect(http).to receive(:use_ssl=).with(false)
|
|
47
|
+
expect(http).to receive(:post).with('/path/to/service?param=value', 'a test frame',
|
|
48
|
+
{ 'Content-Type'=>'application/x-thrift' }) do
|
|
49
|
+
double('Net::HTTPOK').tap do |response|
|
|
50
|
+
expect(response).to receive(:body).and_return 'data'
|
|
51
|
+
expect(response).to receive(:value)
|
|
48
52
|
end
|
|
49
53
|
end
|
|
50
54
|
end
|
|
51
55
|
end
|
|
52
56
|
@client.flush
|
|
53
|
-
@client.read(10).
|
|
57
|
+
expect(@client.read(10)).to eq('data')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'should send custom headers if defined' do
|
|
61
|
+
custom_headers = { 'Cookie' => 'Foo' }
|
|
62
|
+
headers = { 'Content-Type'=>'application/x-thrift' }.merge(custom_headers)
|
|
63
|
+
@client = Thrift::HTTPClientTransport.new(
|
|
64
|
+
'http://my.domain.com/path/to/service?param=value',
|
|
65
|
+
retries: 0,
|
|
66
|
+
headers: custom_headers
|
|
67
|
+
)
|
|
68
|
+
@client.write 'test'
|
|
69
|
+
expect(Net::HTTP).to receive(:new).with('my.domain.com', 80) do
|
|
70
|
+
double('Net::HTTP').tap do |http|
|
|
71
|
+
expect(http).to receive(:use_ssl=).with(false)
|
|
72
|
+
expect(http).to receive(:post).with('/path/to/service?param=value', 'test', headers) do
|
|
73
|
+
double('Net::HTTPOK').tap do |response|
|
|
74
|
+
expect(response).to receive(:body).and_return 'data'
|
|
75
|
+
expect(response).to receive(:value)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
@client.flush
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'should reset the outbuf on HTTP failures' do
|
|
84
|
+
@client.write 'test'
|
|
85
|
+
|
|
86
|
+
expect(Net::HTTP).to receive(:new).with('my.domain.com', 80) do
|
|
87
|
+
double('Net::HTTP').tap do |http|
|
|
88
|
+
expect(http).to receive(:use_ssl=).with(false)
|
|
89
|
+
expect(http).to receive(:post).with('/path/to/service?param=value', 'test',
|
|
90
|
+
{ 'Content-Type'=>'application/x-thrift' }) {
|
|
91
|
+
raise Net::ReadTimeout
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
begin
|
|
97
|
+
@client.flush
|
|
98
|
+
rescue StandardError
|
|
99
|
+
expect(@client.instance_variable_get(:@outbuf)).to eq(Thrift::Bytes.empty_byte_buffer)
|
|
100
|
+
end
|
|
54
101
|
end
|
|
55
102
|
end
|
|
56
103
|
|
|
57
104
|
describe 'ssl enabled' do
|
|
58
105
|
before(:each) do
|
|
59
|
-
@service_path =
|
|
60
|
-
@server_uri =
|
|
106
|
+
@service_path = '/path/to/service?param=value'
|
|
107
|
+
@server_uri = 'https://my.domain.com'
|
|
61
108
|
end
|
|
62
109
|
|
|
63
|
-
it
|
|
110
|
+
it 'should use SSL for https' do
|
|
64
111
|
client = Thrift::HTTPClientTransport.new("#{@server_uri}#{@service_path}")
|
|
65
112
|
|
|
66
|
-
client.write
|
|
113
|
+
client.write 'test'
|
|
67
114
|
|
|
68
|
-
Net::HTTP.
|
|
69
|
-
|
|
70
|
-
http.
|
|
71
|
-
http.
|
|
72
|
-
http.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
115
|
+
expect(Net::HTTP).to receive(:new).with('my.domain.com', 443) do
|
|
116
|
+
double('Net::HTTP').tap do |http|
|
|
117
|
+
expect(http).to receive(:use_ssl=).with(true)
|
|
118
|
+
expect(http).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
|
|
119
|
+
expect(http).to receive(:post).with(
|
|
120
|
+
@service_path,
|
|
121
|
+
'test',
|
|
122
|
+
{ 'Content-Type' => 'application/x-thrift' }
|
|
123
|
+
) do
|
|
124
|
+
double('Net::HTTPOK').tap do |response|
|
|
125
|
+
expect(response).to receive(:body).and_return 'data'
|
|
126
|
+
expect(response).to receive(:value)
|
|
77
127
|
end
|
|
78
128
|
end
|
|
79
129
|
end
|
|
80
130
|
end
|
|
81
131
|
client.flush
|
|
82
|
-
client.read(4).
|
|
132
|
+
expect(client.read(4)).to eq('data')
|
|
83
133
|
end
|
|
84
134
|
|
|
85
|
-
it
|
|
135
|
+
it 'should set SSL verify mode when specified' do
|
|
86
136
|
client = Thrift::HTTPClientTransport.new("#{@server_uri}#{@service_path}",
|
|
87
|
-
|
|
137
|
+
ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
|
|
88
138
|
|
|
89
|
-
client.write
|
|
90
|
-
Net::HTTP.
|
|
91
|
-
|
|
92
|
-
http.
|
|
93
|
-
http.
|
|
94
|
-
http.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
139
|
+
client.write 'test'
|
|
140
|
+
expect(Net::HTTP).to receive(:new).with('my.domain.com', 443) do
|
|
141
|
+
double('Net::HTTP').tap do |http|
|
|
142
|
+
expect(http).to receive(:use_ssl=).with(true)
|
|
143
|
+
expect(http).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE)
|
|
144
|
+
expect(http).to receive(:post).with(
|
|
145
|
+
@service_path,
|
|
146
|
+
'test',
|
|
147
|
+
{ 'Content-Type' => 'application/x-thrift' }
|
|
148
|
+
) do
|
|
149
|
+
double('Net::HTTPOK').tap do |response|
|
|
150
|
+
expect(response).to receive(:body).and_return 'data'
|
|
151
|
+
expect(response).to receive(:value)
|
|
99
152
|
end
|
|
100
153
|
end
|
|
101
154
|
end
|
|
102
155
|
end
|
|
103
156
|
client.flush
|
|
104
|
-
client.read(4).
|
|
157
|
+
expect(client.read(4)).to eq('data')
|
|
105
158
|
end
|
|
106
159
|
end
|
|
107
160
|
end
|