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