Class: AttentiveSidekiq::Manager
- Inherits:
-
Object
- Object
- AttentiveSidekiq::Manager
- Defined in:
- lib/attentive_sidekiq/manager.rb
Constant Summary collapse
- @@instance =
AttentiveSidekiq::Manager.new
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.instance ⇒ Object
5 6 7 |
# File 'lib/attentive_sidekiq/manager.rb', line 5 def self.instance @@instance end |
Instance Method Details
#start! ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/attentive_sidekiq/manager.rb', line 9 def start! task = Concurrent::TimerTask.new() do AttentiveSidekiq::Manager.instance.update_disappeared_jobs end task.add_observer(AttentiveSidekiq::UpdaterObserver.new) task.execute end |
#update_disappeared_jobs ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/attentive_sidekiq/manager.rb', line 17 def update_disappeared_jobs suspicious = AttentiveSidekiq::Suspicious.jobs active_ids = AttentiveSidekiq::Active.job_ids those_lost = suspicious.delete_if{|i| active_ids.include?(i["jid"])} # Sidekiq might have been too fast finishing up a job that appeared in the suspicious list # but didn't make it to the active list, so that's a false-positive. # We need to get the new suspicious list again, and remove any lost jobs that are no longer there. # Those jobs that appeared in the first suspicious list, but not the second one were simply finished # quickly by Sidekiq before showing up as active by a worker. suspicious = AttentiveSidekiq::Suspicious.jobs those_lost.delete_if{|i| !suspicious.any?{|j| i['jid'] == j['jid']} } those_lost.each do |job| Disappeared.add(job) Suspicious.remove(job['jid']) end end |