class Tochtli::BaseClient::SyncMessageHandler
Attributes
error[R]
reply[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/tochtli/base_client.rb, line 84 def initialize super # initialize monitor @cv = new_cond end
Public Instance Methods
call(reply)
click to toggle source
# File lib/tochtli/base_client.rb, line 120 def call(reply) synchronize do @reply = reply @cv.signal end end
handled?()
click to toggle source
# File lib/tochtli/base_client.rb, line 102 def handled? @reply || @error end
on_error(error_message)
click to toggle source
# File lib/tochtli/base_client.rb, line 113 def on_error(error_message) synchronize do @error = reconstruct_exception(error_message) @cv.signal end end
on_timeout(original_message=nil)
click to toggle source
# File lib/tochtli/base_client.rb, line 106 def on_timeout(original_message=nil) synchronize do @error = Timeout::Error.new(original_message ? "Unable to send message: #{original_message.inspect}" : "Service is not responding") @cv.signal end end
raise_error()
click to toggle source
# File lib/tochtli/base_client.rb, line 127 def raise_error error = self.error || InternalServiceError.new("Unknwon", "Unknown Error") raise error end
wait(timeout)
click to toggle source
# File lib/tochtli/base_client.rb, line 89 def wait(timeout) synchronize do @cv.wait(timeout) unless handled? end on_timeout unless handled? end
wait!(timeout)
click to toggle source
# File lib/tochtli/base_client.rb, line 96 def wait!(timeout) wait(timeout) raise_error unless @reply @reply end