Module: TalkToYourApp::Plugins::Jobs::Interface
- Defined in:
- lib/talk_to_your_app/plugins/jobs/interface.rb
Overview
The contract every jobs adapter must satisfy. Adapters duck-type it —there is no abstract base class and no ‘include`. Each method returns a plain Ruby structure with a stable shape across adapters, so a client sees the same response whether the backend is Sidekiq or Solid Queue.
queue_sizes -> { "queue_name" => Integer, ... }
recent_jobs(limit:) -> [ { jid:, class:, queue:, args:, enqueued_at:, error_message: }, ... ]
failed_jobs(limit:) -> [ { jid:, class:, queue:, args:, enqueued_at:, error_message: }, ... ]
rate_metrics(window:) -> { window_seconds:, processed:, failed:, enqueued:, note? }
health -> { adapter:, processes:[...], ... } (adapter-specific)
‘health` is intentionally adapter-specific: it reports worker/process health (running processes, threads/concurrency, pending/claimed counts), whose meaningful fields differ between backends. Every adapter includes an `adapter:` key so clients can branch on it.
Job hashes carry the same keys across adapters and across recent/failed; ‘enqueued_at` is an ISO-8601 string and `error_message` is nil for jobs that have not failed. `window:` is a number of seconds; adapters that cannot honor sub-day granularity include a `note` explaining the resolution they returned.
Constant Summary collapse
- METHODS =
%i[queue_sizes recent_jobs failed_jobs rate_metrics health].freeze
Class Method Summary collapse
-
.satisfied_by?(adapter) ⇒ Boolean
True when the adapter responds to every interface method.
Class Method Details
.satisfied_by?(adapter) ⇒ Boolean
True when the adapter responds to every interface method. Checked at boot so an incomplete adapter fails fast rather than at first call.
32 33 34 |
# File 'lib/talk_to_your_app/plugins/jobs/interface.rb', line 32 def self.satisfied_by?(adapter) METHODS.all? { |method| adapter.respond_to?(method) } end |