class Rack::AMQP::Client::Request
Constants
- SLEEP_INCREMENT
Public Class Methods
new(request_id, http_method, uri, body, headers={})
click to toggle source
# File lib/rack/amqp/client/request.rb, line 11 def initialize(request_id, http_method, uri, body, headers={}) @callback_queue = callback_queue @request_id = request_id @http_method = http_method @headers = headers @body = body @routing_key, @request_path = split_uri uri @response = nil @mutex = Mutex.new @resource = ConditionVariable.new end
Public Instance Methods
callback(delivery_info, meta, payload)
click to toggle source
# File lib/rack/amqp/client/request.rb, line 32 def callback(delivery_info, meta, payload) @mutex.synchronize do @resource.signal @response = Response.new(meta, payload, delivery_info) end end
headers()
click to toggle source
# File lib/rack/amqp/client/request.rb, line 57 def headers @headers.merge(path: request_path) end
payload()
click to toggle source
# File lib/rack/amqp/client/request.rb, line 53 def payload body end
publishing_options()
click to toggle source
# File lib/rack/amqp/client/request.rb, line 40 def publishing_options { mandatory: true, # receive an error on routing error message_id: request_id, reply_to: callback_queue.name, type: http_method, app_id: user_agent, timestamp: Time.now.to_i, headers: headers, routing_key: routing_key } end
reply_wait(timeout)
click to toggle source
# File lib/rack/amqp/client/request.rb, line 23 def reply_wait(timeout) @mutex.synchronize do @resource.wait(@mutex, timeout) end resp = @response @reponse = nil resp end
split_uri(uri)
click to toggle source
# File lib/rack/amqp/client/request.rb, line 65 def split_uri(uri) # expecting target.queue.name/request/path?params=things&others=stuff parts = uri.split('/', 2) [parts[0].to_s, "/#{parts[1].to_s}"] end
user_agent()
click to toggle source
# File lib/rack/amqp/client/request.rb, line 61 def user_agent "rack-amqp-client-#{VERSION}" end