Class: PgInsights::HealthCheckJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/pg_insights/health_check_job.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.perform_check(check_type, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'app/jobs/pg_insights/health_check_job.rb', line 27

def self.perform_check(check_type, options = {})
  return false unless PgInsights.background_jobs_available?

  begin
    perform_later(check_type, options)
    true
  rescue => e
    Rails.logger.warn "PgInsights: Failed to enqueue health check job for #{check_type}: #{e.message}"
    false
  end
end

Instance Method Details

#perform(check_type, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/jobs/pg_insights/health_check_job.rb', line 9

def perform(check_type, options = {})
  unless PgInsights.background_jobs_available?
    Rails.logger.warn "PgInsights: Background jobs not available, skipping #{check_type} check"
    return
  end

  limit = options.fetch("limit", 10)

  Rails.logger.debug "PgInsights: Starting background health check for #{check_type}"

  begin
    HealthCheckService.execute_and_cache_check(check_type, limit)
    Rails.logger.debug "PgInsights: Completed background health check for #{check_type}"
  rescue => e
    Rails.logger.error "PgInsights: Background health check failed for #{check_type}: #{e.message}"
  end
end