Skip to content

Commit

Permalink
Refactor based on feedback from Reek/Code Climate
Browse files Browse the repository at this point in the history
  • Loading branch information
francesmcmullin committed Mar 13, 2022
1 parent cb531ac commit ba5acc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .reek.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ detectors:
- SidekiqUniqueJobs::OnConflict::Reject#push_to_deadset
- SidekiqUniqueJobs::Orphans::RubyReaper#active?
- SidekiqUniqueJobs::Orphans::RubyReaper#enqueued?
- SidekiqUniqueJobs::Orphans::RubyReaper#queues_very_full?
- SidekiqUniqueJobs::UpgradeLocks#keys_for_digest
RepeatedConditional:
exclude:
Expand Down
11 changes: 7 additions & 4 deletions lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,16 @@ def queues_very_full?
total_queue_size = 0
Sidekiq.redis do |conn|
queues(conn) do |queue|
queue_size = conn.llen("queue:#{queue}")
total_queue_size += queue_size
total_queue_size += conn.llen("queue:#{queue}")

return true if total_queue_size > MAX_QUEUE_LENGTH
return true if queue_size_larger_than_max(total_queue_size)
end
end
total_queue_size > MAX_QUEUE_LENGTH
queue_size_larger_than_max(total_queue_size)
end

def queue_size_larger_than_max?(queue_size)
queue_size > MAX_QUEUE_LENGTH
end

#
Expand Down

0 comments on commit ba5acc9

Please sign in to comment.