Permalink
Browse files

respect connect_timeout on reconnect

Thrift::Socket reuses the timeout value for both connection and
request timeouts.
  • Loading branch information...
1 parent 51a9ada commit c0155507d1fca4915c11800360fe26e59f85f661 @sprsquish sprsquish committed Nov 15, 2012
Showing with 10 additions and 6 deletions.
  1. +10 −6 lib/thrift_client/server.rb
View
16 lib/thrift_client/server.rb
@@ -37,13 +37,17 @@ def connection
@connection_string, @options[:connect_timeout])
end
+ def connect!
+ return if open?
+
+ self.timeout = @options[:connect_timeout]
+ connection.connect!
+ self.timeout = @options[:timeout]
+ end
+
def client
@client ||= begin
- connection.connect! unless open?
-
- if transport.respond_to?(:timeout=)
- transport.timeout = @options[:timeout]
- end
+ connect!
@client_class.new(
@options[:protocol].new(self, *@options[:protocol_extra_params]))
@@ -92,7 +96,7 @@ def flush
end
def timeout=(timeout)
- transport.timeout = timeout
+ transport.timeout = timeout if transport.respond_to?(:timeout=)
end
def timeout

0 comments on commit c015550

Please sign in to comment.