Skip to content

Instantly share code, notes, and snippets.

@flaviokr
Last active August 11, 2020 22:43
Show Gist options
  • Save flaviokr/0bd413a26ade1b9119974d7d66b4422d to your computer and use it in GitHub Desktop.
Save flaviokr/0bd413a26ade1b9119974d7d66b4422d to your computer and use it in GitHub Desktop.
# para mover da fila low para pending
q_from = "low"
q_to = "pending"
count_block = proc{ Sidekiq.redis { |conn| conn.llen("queue:#{q_from}") } }
while count_block.call > 0 do
Sidekiq.redis { |conn| conn.rpoplpush "queue:#{q_from}", "queue:#{q_to}" }
end
# para recuperar os jobs da fila pending
# verificar se todos os jobs são da mesma classe
Redis.new.lrange('playax:queue:pending', 0, -1).each do |job|
job = JSON.parse(job)
<Worker>.perform_async(job['args'].first)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment