Class: DisqueJockey::Broker
- Inherits:
-
Object
- Object
- DisqueJockey::Broker
- Defined in:
- lib/disque_jockey/broker.rb
Instance Method Summary collapse
- #acknowledge(job_id) ⇒ Object
- #fast_acknowledge(job_id) ⇒ Object
- #fetch_message_from(queue) ⇒ Object
-
#initialize(nodes = ["127.0.0.1:7711"], *args) ⇒ Broker
constructor
A new instance of Broker.
- #publish(*args) ⇒ Object
Constructor Details
#initialize(nodes = ["127.0.0.1:7711"], *args) ⇒ Broker
Returns a new instance of Broker.
5 6 7 |
# File 'lib/disque_jockey/broker.rb', line 5 def initialize(nodes = ["127.0.0.1:7711"], *args) @client = Disque.new(nodes, *args) end |
Instance Method Details
#acknowledge(job_id) ⇒ Object
14 15 16 17 |
# File 'lib/disque_jockey/broker.rb', line 14 def acknowledge(job_id) response = @client.call('ACKJOB', job_id) raise_error_or_return_true(response) end |
#fast_acknowledge(job_id) ⇒ Object
19 20 21 22 |
# File 'lib/disque_jockey/broker.rb', line 19 def fast_acknowledge(job_id) response = @client.call('FASTACK', job_id) raise_error_or_return_true(response) end |
#fetch_message_from(queue) ⇒ Object
9 10 11 12 |
# File 'lib/disque_jockey/broker.rb', line 9 def (queue) # fetch returns an array of jobs, but we just want the first one @client.fetch(from: [queue]).first end |
#publish(*args) ⇒ Object
24 25 26 |
# File 'lib/disque_jockey/broker.rb', line 24 def publish(*args) @client.push(*args) end |