Skip to content

Commit

Permalink
Continue refactoring wire protocol, moving around responsibility for …
Browse files Browse the repository at this point in the history
…timeouts
  • Loading branch information
mattwynne committed Dec 18, 2009
1 parent e054ea7 commit 17ac33f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/cucumber/wire_support/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ module WireSupport
class Connection
include WireProtocol

attr_reader :default_timeout

def initialize(config)
@host, @port = config['host'], config['port']
@default_timeout = 3
end

def call_remote(request_handler, message, params)
timeout = 3
packet = WirePacket.new(message, params)

begin
send_data_to_socket(packet.to_json, timeout)
response = fetch_data_from_socket(timeout)
send_data_to_socket(packet.to_json, default_timeout)
response = fetch_data_from_socket(request_handler.timeout)
response.handle_with(request_handler)
rescue Timeout::Error
raise "Timed out calling server with message #{message}"
Expand Down
3 changes: 3 additions & 0 deletions lib/cucumber/wire_support/request_handler.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
module Cucumber
module WireSupport
class RequestHandler
attr_reader :timeout

def initialize(connection)
@connection = connection
@message = underscore(self.class.name.split('::').last)
@timeout = connection.default_timeout
end

def execute(request_params = nil)
Expand Down

0 comments on commit 17ac33f

Please sign in to comment.