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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/newshound/jobs/base.rb', line 40 def stats = queue_statistics { queue_stats: { ready_to_run: stats[:ready], scheduled: stats[:scheduled], failing: stats[:failing], # Adapters written before the failing/expired split report only :failed. expired: stats.fetch(:expired) { stats[:failed] }, failed: stats[:failed], completed_today: stats[:finished_today] } } end |
#job_counts_by_type ⇒ Hash
Returns job counts grouped by job class
32 33 34 |
# File 'lib/newshound/jobs/base.rb', line 32 def job_counts_by_type raise NotImplementedError, "#{self.class} must implement #job_counts_by_type" end |
#queue_statistics ⇒ Hash
Returns queue-level statistics
25 26 27 |
# File 'lib/newshound/jobs/base.rb', line 25 def queue_statistics raise NotImplementedError, "#{self.class} must implement #queue_statistics" end |