Module: PgInsights::Integration

Defined in:
lib/pg_insights.rb

Class Method Summary collapse

Class Method Details

.statusObject



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/pg_insights.rb', line 97

def self.status
  {
    background_jobs_available: PgInsights.background_jobs_available?,
    queue_adapter: defined?(ActiveJob::Base) ? ActiveJob::Base.queue_adapter_name : "not_available",
    configuration: {
      enable_background_jobs: PgInsights.enable_background_jobs,
      health_cache_expiry: PgInsights.health_cache_expiry,
      background_job_queue: PgInsights.background_job_queue
    }
  }
end

.test_background_jobsObject



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/pg_insights.rb', line 109

def self.test_background_jobs
  return { success: false, error: "Background jobs disabled" } unless PgInsights.enable_background_jobs
  return { success: false, error: "ActiveJob not available" } unless defined?(ActiveJob::Base)

  begin
    if defined?(PgInsights::HealthCheckJob)
      Rails.logger.info "PgInsights: Testing background job capability..."
      { success: true, message: "Background jobs appear to be working" }
    else
      { success: false, error: "PgInsights job classes not loaded" }
    end
  rescue => e
    { success: false, error: e.message }
  end
end