Module: CheckerJobs::JobsProcessors::Sidekiq

Defined in:
lib/checker_jobs/jobs_processors/sidekiq.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
# File 'lib/checker_jobs/jobs_processors/sidekiq.rb', line 4

def self.included(base)
  base.include(Sidekiq::Worker)
  base.extend(ClassMethods)
end

Instance Method Details

#perform(check_name = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/checker_jobs/jobs_processors/sidekiq.rb', line 9

def perform(check_name = nil)
  # Run on specific check
  return self.class.perform_check(check_name.to_s) if check_name

  # Enqueue one specific check for each declared check
  self.class.checks.values.each.with_index do |check, index|
    scheduled_in = index * self.class.time_between_checks
    self.class.perform_check_in(check, scheduled_in)
  end
end