thrift_client 0.8.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -92,20 +92,14 @@ class AbstractThriftClient
92
92
  # Force the client to connect to the server. Not necessary to be
93
93
  # called as the connection will be made on the first RPC method
94
94
  # call.
95
- def connect!(method = nil)
96
- start_time ||= Time.now
95
+ def connect!
97
96
  @current_server = next_live_server
98
97
  @client = @current_server.client
99
98
  @last_client = @client
100
99
  do_callbacks(:post_connect, self)
101
100
  rescue IOError, Thrift::TransportException
102
101
  disconnect!(true)
103
- timeout = timeout(method)
104
- if timeout && Time.now - start_time > timeout
105
- no_servers_available!
106
- else
107
- retry
108
- end
102
+ retry
109
103
  end
110
104
 
111
105
  def disconnect!(error = false)
@@ -138,7 +132,7 @@ class AbstractThriftClient
138
132
  return @server_list[cur]
139
133
  end
140
134
  end
141
- no_servers_available!
135
+ raise ThriftClient::NoServersAvailable, "No live servers in #{@server_list.inspect}."
142
136
  end
143
137
 
144
138
  def ensure_socket_alignment
@@ -156,9 +150,9 @@ class AbstractThriftClient
156
150
 
157
151
  def handled_proxy(method_name, *args)
158
152
  begin
159
- connect!(method_name.to_sym) unless @client
153
+ connect! unless @client
160
154
  if has_timeouts?
161
- @client.timeout = timeout(method_name.to_sym)
155
+ @client.timeout = @options[:timeout_overrides][method_name.to_sym] || @options[:timeout]
162
156
  end
163
157
  @request_count += 1
164
158
  do_callbacks(:before_method, method_name)
@@ -202,10 +196,6 @@ class AbstractThriftClient
202
196
  @has_timeouts ||= @options[:timeout_overrides].any? && transport_can_timeout?
203
197
  end
204
198
 
205
- def timeout(method = nil)
206
- @options[:timeout_overrides][method] || @options[:timeout]
207
- end
208
-
209
199
  def transport_can_timeout?
210
200
  if (@options[:transport_wrapper] || @options[:transport]).method_defined?(:timeout=)
211
201
  true
@@ -214,8 +204,4 @@ class AbstractThriftClient
214
204
  false
215
205
  end
216
206
  end
217
-
218
- def no_servers_available!
219
- raise ThriftClient::NoServersAvailable, "No live servers in #{@server_list.inspect}."
220
- end
221
207
  end
@@ -230,11 +230,6 @@ class ThriftClientTest < Test::Unit::TestCase
230
230
  assert_raises(ThriftClient::NoServersAvailable) { client.greeting("someone") }
231
231
  end
232
232
 
233
- def test_connect_retry_period
234
- client = ThriftClient.new(Greeter::Client, @servers[0], @options.merge(:server_retry_period => 0))
235
- assert_raises(ThriftClient::NoServersAvailable) { client.connect! }
236
- end
237
-
238
233
  def test_client_with_retry_period_drops_servers
239
234
  client = ThriftClient.new(Greeter::Client, @servers[0,2], @options.merge(:server_retry_period => 1, :retries => 2))
240
235
  assert_raises(ThriftClient::NoServersAvailable) { client.greeting("someone") }
metadata CHANGED
@@ -1,81 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: thrift_client
3
- version: !ruby/object:Gem::Version
4
- hash: 55
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 8
9
- - 4
10
- version: 0.8.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Evan Weaver
14
9
  - Ryan King
15
10
  - Jeff Hodges
16
11
  autorequire:
17
12
  bindir: bin
18
13
  cert_chain: []
19
-
20
- date: 2013-02-26 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
14
+ date: 2013-01-11 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
23
17
  name: thrift
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
26
19
  none: false
27
- requirements:
20
+ requirements:
28
21
  - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 63
31
- segments:
32
- - 0
33
- - 8
34
- - 0
35
- version: 0.8.0
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.0
36
24
  type: :runtime
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: rake
40
25
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: 0.9.0
32
+ - !ruby/object:Gem::Dependency
33
+ name: rake
34
+ requirement: !ruby/object:Gem::Requirement
42
35
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- hash: 3
47
- segments:
48
- - 0
49
- version: "0"
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
50
40
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: mongrel
54
41
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
42
+ version_requirements: !ruby/object:Gem::Requirement
56
43
  none: false
57
- requirements:
58
- - - "="
59
- - !ruby/object:Gem::Version
60
- hash: 2328195415
61
- segments:
62
- - 1
63
- - 2
64
- - 0
65
- - pre
66
- - 2
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: mongrel
50
+ requirement: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
67
55
  version: 1.2.0.pre2
68
56
  type: :development
69
- version_requirements: *id003
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - '='
62
+ - !ruby/object:Gem::Version
63
+ version: 1.2.0.pre2
70
64
  description:
71
65
  email:
72
66
  executables: []
73
-
74
67
  extensions: []
75
-
76
68
  extra_rdoc_files: []
77
-
78
- files:
69
+ files:
79
70
  - lib/thrift_client/abstract_thrift_client.rb
80
71
  - lib/thrift_client/connection/base.rb
81
72
  - lib/thrift_client/connection/factory.rb
@@ -96,38 +87,29 @@ files:
96
87
  - test/thrift_client_test.rb
97
88
  homepage: https://github.com/twitter/thrift_client
98
89
  licenses: []
99
-
100
90
  post_install_message:
101
91
  rdoc_options: []
102
-
103
- require_paths:
92
+ require_paths:
104
93
  - lib
105
- required_ruby_version: !ruby/object:Gem::Requirement
94
+ required_ruby_version: !ruby/object:Gem::Requirement
106
95
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- hash: 3
111
- segments:
112
- - 0
113
- version: "0"
114
- required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
101
  none: false
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- hash: 3
120
- segments:
121
- - 0
122
- version: "0"
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
123
106
  requirements: []
124
-
125
107
  rubyforge_project:
126
- rubygems_version: 1.8.15
108
+ rubygems_version: 1.8.23
127
109
  signing_key:
128
110
  specification_version: 3
129
111
  summary: A Thrift client wrapper that encapsulates some common failover behavior.
130
- test_files:
112
+ test_files:
131
113
  - test/greeter/greeter.rb
132
114
  - test/greeter/server.rb
133
115
  - test/multiple_working_servers_test.rb