Class: QueueBus::TaskManager
- Inherits:
-
Object
- Object
- QueueBus::TaskManager
- Defined in:
- lib/queue_bus/task_manager.rb
Overview
A helper class for executing Rake tasks.
Instance Attribute Summary collapse
-
#logging ⇒ Object
readonly
Returns the value of attribute logging.
Instance Method Summary collapse
-
#initialize(logging) ⇒ TaskManager
constructor
A new instance of TaskManager.
- #log(message) ⇒ Object
- #queue_names ⇒ Object
- #subscribe! ⇒ Object
- #unsubscribe! ⇒ Object
- #unsubscribe_queue!(app_key, queue) ⇒ Object
Constructor Details
#initialize(logging) ⇒ TaskManager
Returns a new instance of TaskManager.
8 9 10 |
# File 'lib/queue_bus/task_manager.rb', line 8 def initialize(logging) @logging = logging end |
Instance Attribute Details
#logging ⇒ Object (readonly)
Returns the value of attribute logging.
6 7 8 |
# File 'lib/queue_bus/task_manager.rb', line 6 def logging @logging end |
Instance Method Details
#log(message) ⇒ Object
57 58 59 |
# File 'lib/queue_bus/task_manager.rb', line 57 def log() puts() if logging end |
#queue_names ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/queue_bus/task_manager.rb', line 45 def queue_names # let's not talk to redis in here. Seems to screw things up queues = [] ::QueueBus.dispatchers.each do |dispatcher| dispatcher.subscriptions.all.each do |sub| queues << sub.queue_name end end queues.uniq end |
#subscribe! ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/queue_bus/task_manager.rb', line 12 def subscribe! count = 0 ::QueueBus.dispatchers.each do |dispatcher| subscriptions = dispatcher.subscriptions next if subscriptions.empty? count += subscriptions.size log "Subscribing #{dispatcher.app_key} to #{subscriptions.size} subscriptions" app = ::QueueBus::Application.new(dispatcher.app_key) app.subscribe(subscriptions, logging) log ' ...done' end count end |
#unsubscribe! ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/queue_bus/task_manager.rb', line 34 def unsubscribe! count = 0 ::QueueBus.dispatchers.each do |dispatcher| log "Unsubcribing from #{dispatcher.app_key}" app = ::QueueBus::Application.new(dispatcher.app_key) app.unsubscribe count += 1 log ' ...done' end end |
#unsubscribe_queue!(app_key, queue) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/queue_bus/task_manager.rb', line 27 def unsubscribe_queue!(app_key, queue) log "Unsubcribing #{queue} from #{app_key}" app = ::QueueBus::Application.new(app_key) app.unsubscribe_queue(queue) log " ...done" end |