Sha256: 59e4f8cf088be972d856650aad4c2148f72cf48db8d56edebe302ce2baa3b844
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
module Sidekiq module Batching class Actor include Sidekiq::Batching::Logging def initialize link_to_sidekiq_manager end private def start_polling interval = Sidekiq::Batching::Config.poll_interval info "Start polling of queue batches every #{interval} seconds" every(interval) { flush_batches } end def flush_batches batches = [] Sidekiq::Batching::Batch.all.map do |batch| if batch.could_flush? batches << batch end end flush(batches) end def link_to_sidekiq_manager Sidekiq::CLI.instance.launcher.manager.link(current_actor) start_polling rescue NoMethodError debug "Can't link #{self.class.name}. Sidekiq::Manager not running. Retrying in 5 seconds ..." after(5) { link_to_sidekiq_manager } end def flush(batches) if batches.any? names = batches.map { |batch| "#{batch.worker_class} in #{batch.queue}" } info "Trying to flush batched queues: #{names.join(',')}" batches.each { |batch| batch.flush } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-batching-0.0.4 | lib/sidekiq/batching/actor.rb |