discourse/app/jobs/regular/problem_check.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
797 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Jobs
class RetrySignal < Exception
end
# This job runs a singular scheduled admin check. It is scheduled by
# the ProblemChecks (plural) scheduled job.
class ProblemCheck < ::Jobs::Base
sidekiq_options retry: false
def execute(args)
retry_count = args[:retry_count].to_i
identifier = args[:check_identifier].to_sym
check = AdminDashboardData.problem_scheduled_check_klasses[identifier]
AdminDashboardData.execute_scheduled_check(identifier) do |problems|
raise RetrySignal if retry_count < check.max_retries
end
rescue RetrySignal
Jobs.enqueue_in(
check.retry_wait,
:problem_check,
args.merge(retry_count: retry_count + 1).stringify_keys,
)
end
end
end