thrift_client 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ v0.3.3 Allow for a timeout over all requests in a call.
1
2
 
2
3
  v0.3.2. Fix connection close bug (nkallen, mattknox).
3
4
 
data/lib/thrift_client.rb CHANGED
@@ -8,12 +8,13 @@ else
8
8
  require 'thrift'
9
9
  end
10
10
 
11
+ require 'timeout'
11
12
  require 'rubygems'
12
13
  require 'thrift_client/thrift'
13
14
 
14
15
  class ThriftClient
15
-
16
16
  class NoServersAvailable < StandardError; end
17
+ class GlobalThriftClientTimeout < Timeout::Error; end
17
18
 
18
19
  DEFAULTS = {
19
20
  :protocol => Thrift::BinaryProtocol,
@@ -51,7 +52,8 @@ Valid optional parameters are:
51
52
  <tt>:retries</tt>:: How many times to retry a request. Defaults to the number of servers defined.
52
53
  <tt>:server_retry_period</tt>:: How many seconds to wait before trying to reconnect after marking all servers as down. Defaults to <tt>1</tt>. Set to <tt>nil</tt> to retry endlessly.
53
54
  <tt>:server_max_requests</tt>:: How many requests to perform before moving on to the next server in the pool, regardless of error status. Defaults to <tt>nil</tt> (no limit).
54
- <tt>:timeout</tt>:: Specify the default timeout in seconds. Defaults to <tt>1</tt>.
55
+ <tt>:global_timeout</tt>:: Specify the timeout for all connections made. Defaults to being disabled.
56
+ <tt>:timeout</tt>:: Specify the default timeout in seconds per connection. Defaults to <tt>1</tt>.
55
57
  <tt>:timeout_overrides</tt>:: Specify additional timeouts on a per-method basis, in seconds. Only works with <tt>Thrift::BufferedTransport</tt>.
56
58
  <tt>:defaults</tt>:: Specify default values to return on a per-method basis, if <tt>:raise</tt> is set to false.
57
59
 
@@ -74,6 +76,7 @@ Valid optional parameters are:
74
76
  @request_count = 0
75
77
  @max_requests = @options[:server_max_requests]
76
78
  @retry_period = @options[:server_retry_period]
79
+ @global_timeout = @options[:global_timeout] || 0
77
80
  rebuild_live_server_list!
78
81
 
79
82
  @client_class.instance_methods.each do |method_name|
@@ -117,6 +120,15 @@ Valid optional parameters are:
117
120
  private
118
121
 
119
122
  def proxy(method_name, *args)
123
+ Timeout.timeout(@global_timeout, GlobalThriftClientTimeout) do
124
+ raw_proxy(method_name, *args)
125
+ end
126
+ rescue GlobalThriftClientTimeout => e
127
+ disconnect!(false)
128
+ raise e
129
+ end
130
+
131
+ def raw_proxy(method_name, *args)
120
132
  disconnect! if @max_requests and @request_count >= @max_requests
121
133
  connect! unless @client
122
134
 
@@ -2,12 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{thrift_client}
5
- s.version = "0.3.2"
5
+ s.version = "0.3.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0.8") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Evan Weaver"]
9
- s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
10
- s.date = %q{2009-12-10}
9
+ s.date = %q{2010-01-11}
11
10
  s.description = %q{A Thrift client wrapper that encapsulates some common failover behavior.}
12
11
  s.email = %q{}
13
12
  s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/thrift_client.rb", "lib/thrift_client/thrift.rb"]
@@ -17,7 +16,6 @@ Gem::Specification.new do |s|
17
16
  s.require_paths = ["lib"]
18
17
  s.rubyforge_project = %q{fauna}
19
18
  s.rubygems_version = %q{1.3.5}
20
- s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem}
21
19
  s.summary = %q{A Thrift client wrapper that encapsulates some common failover behavior.}
22
20
  s.test_files = ["test/simple_test.rb", "test/test_helper.rb", "test/thrift_client_test.rb"]
23
21
 
metadata CHANGED
@@ -1,36 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thrift_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Weaver
8
8
  autorequire:
9
9
  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- hIPfLqCyxsn/YgOGvo6iwyQTWyTswamaAC3HRWZxIS1sfn/Ssqa7E7oQMkv5FAXr
29
- x5rKePfXINf8XTJczkl9OBEYdE9aNdJsJpXD0asLgGVwBICS5Bjohp6mizJcDC1+
30
- yZ0=
31
- -----END CERTIFICATE-----
10
+ cert_chain: []
32
11
 
33
- date: 2009-12-10 00:00:00 -08:00
12
+ date: 2010-01-11 00:00:00 -08:00
34
13
  default_executable:
35
14
  dependencies:
36
15
  - !ruby/object:Gem::Dependency
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- �2���G�����(�QrJw�n�^ �48%�NnY�2�vL�X}4b<��n�6UD3�q̜�ퟆg�g3�V��r-�XF�x�zb?�Ŭy�G:�[AnauFK�� �j�Q�I_����b��LZ�8 ����׍q�� ꃁl���۠$���O �BT���M��?�kV���q�(�w�eL��-�y[��.&�
2
- ��؀ᠠ�=�~���ǘ���߉rκ])�wgzl;0b�e��?�2��7DF��s|�
metadata.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- I4�:0�����8��� )���O����G�\���[b���[����K۾�Y�� 8�y�p�ñ�{7<|����+9[������L�#K6ɷ�G����� jԄ�Ei��o���4{���e����q��v��-�>v�e�ё�x� �׏�ʍWʞ/��Z������pp�o�I��{�T�ұ6���'��w��
2
- �����[��