Class: Woods::Console::Adapters::JobAdapter
- Inherits:
-
Object
- Object
- Woods::Console::Adapters::JobAdapter
- Defined in:
- lib/woods/console/adapters/job_adapter.rb
Overview
Base class for job backend adapters.
Subclasses implement ‘self.available?` and a private `prefix` method. The prefix is used to build bridge tool names (e.g., “sidekiq_queue_stats”).
Direct Known Subclasses
Instance Method Summary collapse
-
#find_job(id:) ⇒ Hash
Find a job by its ID.
-
#queue_stats ⇒ Hash
Get queue statistics (sizes, latencies).
-
#recent_failures(limit: 10) ⇒ Hash
List recent job failures.
-
#retry_job(id:) ⇒ Hash
Retry a failed job.
-
#scheduled_jobs(limit: 20) ⇒ Hash
List scheduled jobs.
Instance Method Details
#find_job(id:) ⇒ Hash
Find a job by its ID.
A nil id is dropped from the bridge request so downstream tools see a missing parameter rather than an explicit ‘nil` — symmetric with `CacheAdapter.stats(namespace: nil)`.
43 44 45 |
# File 'lib/woods/console/adapters/job_adapter.rb', line 43 def find_job(id:) { tool: "#{prefix}_find_job", params: { id: id }.compact } end |
#queue_stats ⇒ Hash
Get queue statistics (sizes, latencies).
22 23 24 |
# File 'lib/woods/console/adapters/job_adapter.rb', line 22 def queue_stats { tool: "#{prefix}_queue_stats", params: {} } end |
#recent_failures(limit: 10) ⇒ Hash
List recent job failures.
30 31 32 33 |
# File 'lib/woods/console/adapters/job_adapter.rb', line 30 def recent_failures(limit: 10) limit = [limit, 100].min { tool: "#{prefix}_recent_failures", params: { limit: limit } } end |
#retry_job(id:) ⇒ Hash
Retry a failed job.
A nil id is dropped from the bridge request — see #find_job.
62 63 64 |
# File 'lib/woods/console/adapters/job_adapter.rb', line 62 def retry_job(id:) { tool: "#{prefix}_retry_job", params: { id: id }.compact } end |
#scheduled_jobs(limit: 20) ⇒ Hash
List scheduled jobs.
51 52 53 54 |
# File 'lib/woods/console/adapters/job_adapter.rb', line 51 def scheduled_jobs(limit: 20) limit = [limit, 100].min { tool: "#{prefix}_scheduled_jobs", params: { limit: limit } } end |