Class: Qmore::JobReserver
- Inherits:
-
Object
- Object
- Qmore::JobReserver
- Includes:
- Attributes
- Defined in:
- lib/qmore/job_reserver.rb
Instance Attribute Summary collapse
-
#clients ⇒ Object
readonly
Returns the value of attribute clients.
-
#queues ⇒ Object
readonly
define queues for Qless worker to invoke.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(queues) ⇒ JobReserver
constructor
A new instance of JobReserver.
- #prep_for_work! ⇒ Object
- #reserve ⇒ Object
Methods included from Attributes
#decode, #encode, #expand_queues, #get_dynamic_queue, #get_dynamic_queues, #get_priority_buckets, #prioritize_queues, #redis, #set_dynamic_queue, #set_dynamic_queues, #set_priority_buckets
Constructor Details
#initialize(queues) ⇒ JobReserver
Returns a new instance of JobReserver.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/qmore/job_reserver.rb', line 8 def initialize(queues) @queues = queues # Pull the regex off of the Qless::Queue#name, we want to keep the same interface # that Qless reservers use. @regexes = queues.collect(&:name).uniq @clients = {} queues.each do |q| @clients[q.client] ||= [] @clients[q.client] << q.name end end |
Instance Attribute Details
#clients ⇒ Object (readonly)
Returns the value of attribute clients.
6 7 8 |
# File 'lib/qmore/job_reserver.rb', line 6 def clients @clients end |
#queues ⇒ Object (readonly)
define queues for Qless worker to invoke.
5 6 7 |
# File 'lib/qmore/job_reserver.rb', line 5 def queues @queues end |
Instance Method Details
#description ⇒ Object
20 21 22 |
# File 'lib/qmore/job_reserver.rb', line 20 def description @description ||= @regexes.join(', ') + " (qmore)" end |
#prep_for_work! ⇒ Object
24 25 26 |
# File 'lib/qmore/job_reserver.rb', line 24 def prep_for_work! # nothing here on purpose end |
#reserve ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/qmore/job_reserver.rb', line 28 def reserve realize_queues.each do |q| job = q.pop return job if job end nil end |