Class: Requeus::Adapter::Rabbit
- Inherits:
-
Object
- Object
- Requeus::Adapter::Rabbit
- Defined in:
- lib/requeus/adapter/rabbit.rb
Instance Method Summary collapse
- #confirm(queue, handle) ⇒ Object
- #get(queue, limit = 1) ⇒ Object
-
#initialize(opts) ⇒ Rabbit
constructor
A new instance of Rabbit.
- #put(queue, request) ⇒ Object
Constructor Details
#initialize(opts) ⇒ Rabbit
Returns a new instance of Rabbit.
8 9 10 |
# File 'lib/requeus/adapter/rabbit.rb', line 8 def initialize opts @opts = opts end |
Instance Method Details
#confirm(queue, handle) ⇒ Object
29 30 31 32 33 |
# File 'lib/requeus/adapter/rabbit.rb', line 29 def confirm queue, handle cq(queue).delivery_tag = handle cmd cq(queue), :ack true end |
#get(queue, limit = 1) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/requeus/adapter/rabbit.rb', line 17 def get queue, limit = 1 result = [] requests = 0 while requests <= limit && r = pop_request(cq(queue)) result << r requests += 1 end result end |
#put(queue, request) ⇒ Object
12 13 14 15 |
# File 'lib/requeus/adapter/rabbit.rb', line 12 def put queue, request cmd cq(queue), :publish, request, :persistent => true true end |