Class: Newshound::Jobs::Base
- Inherits:
-
Object
- Object
- Newshound::Jobs::Base
- Defined in:
- lib/newshound/jobs/base.rb
Overview
Base class for job source adapters Each adapter is responsible for:
-
Fetching queue statistics from its specific job backend
-
Fetching job counts grouped by type
-
Formatting job data for banner display
Subclasses must implement:
-
#queue_statistics - Returns a hash of queue stats
-
#job_counts_by_type - Returns a hash of job class => counts
Unlike Warnings::Base and Exceptions::Base (which format individual records), #format_for_banner takes no arguments and returns aggregate queue statistics. A default implementation is provided that delegates to #queue_statistics.
Direct Known Subclasses
Instance Method Summary collapse
-
#format_for_banner ⇒ Hash
Returns data formatted for the banner UI.
-
#job_counts_by_type ⇒ Hash
Returns job counts grouped by job class.
-
#queue_statistics ⇒ Hash
Returns queue-level statistics.
Instance Method Details
#format_for_banner ⇒ Hash
Returns data formatted for the banner UI
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/newshound/jobs/base.rb', line 36 def stats = queue_statistics { queue_stats: { ready_to_run: stats[:ready], scheduled: stats[:scheduled], failed: stats[:failed], completed_today: stats[:finished_today] } } end |
#job_counts_by_type ⇒ Hash
Returns job counts grouped by job class
29 30 31 |
# File 'lib/newshound/jobs/base.rb', line 29 def job_counts_by_type raise NotImplementedError, "#{self.class} must implement #job_counts_by_type" end |
#queue_statistics ⇒ Hash
Returns queue-level statistics
22 23 24 |
# File 'lib/newshound/jobs/base.rb', line 22 def queue_statistics raise NotImplementedError, "#{self.class} must implement #queue_statistics" end |