Class: AntiSmoker::MsgpackRpcTest
- Inherits:
-
AbstractSmokeTest
- Object
- AbstractSmokeTest
- AntiSmoker::MsgpackRpcTest
- Includes:
- MsgpackRpcModule
- Defined in:
- lib/antismoker/tests/msgpack-rpc.rb
Constant Summary
Constants included from MsgpackRpcModule
AntiSmoker::MsgpackRpcModule::VERSION
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(host, port, options = {}) ⇒ MsgpackRpcTest
constructor
A new instance of MsgpackRpcTest.
- #response_ok(response) ⇒ Object
- #run_once_with_timeout(options = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(host, port, options = {}) ⇒ MsgpackRpcTest
Returns a new instance of MsgpackRpcTest.
11 12 13 14 |
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 11 def initialize(host, port, ={}) super @message = .fetch(:message, [:ping]) end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
15 16 17 |
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 15 def @message end |
Instance Method Details
#response_ok(response) ⇒ Object
30 31 32 |
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 30 def response_ok(response) response end |
#run_once_with_timeout(options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 17 def run_once_with_timeout(={}) client = MessagePack::RPC::Client.new(host, port) client.timeout = timeout response = client.call(*) response_ok(response) rescue MessagePack::RPC::ConnectionTimeoutError => error logger.debug("timed out: #{self}: #{error}") false rescue => error logger.warn("unknown error: #{self}: #{error}") false end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 34 def to_s "msgpack-rpc://#{host}:#{port}" end |