Class: Mist::Client
- Inherits:
-
Object
- Object
- Mist::Client
- Defined in:
- lib/mist/client.rb
Instance Method Summary collapse
- #call(method, args = {}) ⇒ Object
-
#initialize(pool) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(pool) ⇒ Client
Returns a new instance of Client.
19 20 21 |
# File 'lib/mist/client.rb', line 19 def initialize(pool) @pool = pool end |
Instance Method Details
#call(method, args = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mist/client.rb', line 23 def call(method, args = {}) server = args[:server] || @pool.acquire timeout = args[:timeout] || 300 Mist.logger.debug "got server #{server}" server_info = server.split(':') host = server_info[0] port = server_info[1] || '18800' client = MessagePack::RPC::Client.new(host, port) client.timeout = timeout result = client.call(method, args) @pool.release server return result end |