Class: Rack::AMQP::Client::Manager
- Inherits:
-
Object
- Object
- Rack::AMQP::Client::Manager
- Defined in:
- lib/rack/amqp/client/manager.rb
Instance Attribute Summary collapse
-
#amqp_channel ⇒ Object
Returns the value of attribute amqp_channel.
-
#amqp_client ⇒ Object
Returns the value of attribute amqp_client.
-
#connection_options ⇒ Object
Returns the value of attribute connection_options.
Instance Method Summary collapse
-
#initialize(broker_connection_options) ⇒ Manager
constructor
A new instance of Manager.
-
#request(uri, options = {}) ⇒ Object
TODO this method needs to be refactored.
Constructor Details
#initialize(broker_connection_options) ⇒ Manager
Returns a new instance of Manager.
7 8 9 10 11 12 |
# File 'lib/rack/amqp/client/manager.rb', line 7 def initialize() connect!() @correlation_id = 0 @incomplete_requests = [] @mutex = Mutex.new end |
Instance Attribute Details
#amqp_channel ⇒ Object
Returns the value of attribute amqp_channel.
5 6 7 |
# File 'lib/rack/amqp/client/manager.rb', line 5 def amqp_channel @amqp_channel end |
#amqp_client ⇒ Object
Returns the value of attribute amqp_client.
5 6 7 |
# File 'lib/rack/amqp/client/manager.rb', line 5 def amqp_client @amqp_client end |
#connection_options ⇒ Object
Returns the value of attribute connection_options.
5 6 7 |
# File 'lib/rack/amqp/client/manager.rb', line 5 def @connection_options end |
Instance Method Details
#request(uri, options = {}) ⇒ Object
TODO this method needs to be refactored
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rack/amqp/client/manager.rb', line 15 def request(uri, ={}) http_method = [:http_method] timeout = [:timeout] || 5 body = [:body] || "" headers = { 'Content-Type' => 'application/x-www-form-urlencoded', 'Content-Length' => body.length }.merge([:headers]) request = Request.new((@correlation_id += 1).to_s, http_method, uri, body, headers) @mutex.synchronize { @incomplete_requests << request } callback_queue = create_callback_queue request.callback_queue = callback_queue amqp_channel.direct('').publish(request.payload, request.) if [:async] NullResponse.new else request.reply_wait(timeout) end end |