Sha256: 0bc9a0e4f5f5cb8a9235c1c46cec56ac0637aec13318a14a6d3f32a352a42a25
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module QueueBus # A helper class for executing Rake tasks. class TaskManager attr_reader :logging def initialize(logging) @logging = logging end 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 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 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 def log(message) puts(message) if logging end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
queue-bus-0.9.1 | lib/queue_bus/task_manager.rb |