This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sidekiq.redis { |conn| conn.flushdb } # clear everything | |
Sidekiq::Queue.all # get all queues | |
Sidekiq::Queue.new # get the "default" queue | |
Sidekiq::Queue.new("mailer") # get the "mailer" queue | |
Sidekiq::Queue.new.clear # deletes all jobs in a queue, by removing the queue | |
Sidekiq::Queue.all.each(&:clear) # deletes all jobs in all queues | |
ss = Sidekiq::ScheduledSet.new | |
ss.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you want to provide a maximum queue size, you may also consider the fallback_policy which defines what will | |
# happen if work is posted to a pool when the queue of waiting work has reached the maximum size and no new threads | |
# can be created. Available policies: | |
# abort: Raise a Concurrent::RejectedExecutionError exception and discard the task. (default policy) | |
# discard: Silently discard the task and return nil as the task result. | |
# caller_runs: The work will be executed in the thread of the caller, instead of being given to another thread in the pool. | |
pool = Concurrent::ThreadPoolExecutor.new( | |
:min_threads => [2, Concurrent.processor_count].max, |