class Sidekiq::Batching::Actor

Public Class Methods

new() click to toggle source
# File lib/sidekiq/batching/actor.rb, line 7
def initialize
  link_to_sidekiq_manager
end

Private Instance Methods

flush(batches) click to toggle source
# File lib/sidekiq/batching/actor.rb, line 38
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
flush_batches() click to toggle source
# File lib/sidekiq/batching/actor.rb, line 18
def flush_batches
  batches = []

  Sidekiq::Batching::Batch.all.map do |batch|
    if batch.could_flush?
      batches << batch
    end
  end

  flush(batches)
end
start_polling() click to toggle source
# File lib/sidekiq/batching/actor.rb, line 12
def start_polling
  interval = Sidekiq::Batching::Config.poll_interval
  info "Start polling of queue batches every #{interval} seconds"
  every(interval) { flush_batches }
end