Module: Dispatch::Rails::SolidQueueSubscriber
- Defined in:
- lib/dispatch/rails/solid_queue_subscriber.rb
Overview
Bridges SolidQueue’s ActiveSupport::Notifications into Dispatch error capture.
SolidQueue records its infrastructure failures — a worker pruned after a missed heartbeat, claimed jobs orphaned by a dead process, a recurring task that failed to enqueue — straight into its own tables. They are NOT raised through ActiveJob’s perform path, so they never reach Rails.error and never reach the Dispatch::Rails::ErrorSubscriber. The result is an invisible class of failure: jobs that died are only discoverable by opening the queue.
This subscriber listens for those events and turns each into a first-class Dispatch event. Captured events (all gated by config.capture_solid_queue and the usual environment gating):
fail_many_claimed -> SolidQueueJobsLost (pruned / orphaned / dead-worker jobs)
thread_error -> the real exception (a crash in a SolidQueue thread)
enqueue_recurring_task -> SolidQueueEnqueueError (only when enqueue_error is set)
On thread_error: SolidQueue fires this event BEFORE calling on_thread_error (see SolidQueue::AppExecutor#handle_thread_error), and Reporter marks the exception object on capture. So when the default on_thread_error (-> Rails.error.report) runs next, the Dispatch error subscriber dedups it via that marker — no double report. Capturing here means we still see these crashes even when the host app overrides on_thread_error away from Rails.error (a common customization that would otherwise hide them).
Idempotent: install! subscribes once per process; repeat calls no-op. The handlers never raise back into SolidQueue’s instrumentation.
Constant Summary collapse
- EVENTS =
%w[ fail_many_claimed.solid_queue thread_error.solid_queue enqueue_recurring_task.solid_queue ].freeze
- MAX_IDS =
How many job/process ids to inline into tags before truncating. The payload batches are bounded (prune runs in batches of 50), but we keep tag values short regardless.
20
Class Method Summary collapse
- .install! ⇒ Object
- .installed? ⇒ Boolean
-
.uninstall! ⇒ Object
Test/reset seam — unsubscribe so a fresh install! re-registers.
Class Method Details
.install! ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/dispatch/rails/solid_queue_subscriber.rb', line 58 def install! return if @installed @installed = true @subscriptions = EVENTS.map do |event| ActiveSupport::Notifications.subscribe(event) do |name, _start, _finish, _id, payload| handle(name, payload) end end true end |
.installed? ⇒ Boolean
77 78 79 |
# File 'lib/dispatch/rails/solid_queue_subscriber.rb', line 77 def installed? @installed == true end |
.uninstall! ⇒ Object
Test/reset seam — unsubscribe so a fresh install! re-registers.
71 72 73 74 75 |
# File 'lib/dispatch/rails/solid_queue_subscriber.rb', line 71 def uninstall! Array(@subscriptions).each { |sub| ActiveSupport::Notifications.unsubscribe(sub) } @subscriptions = nil @installed = false end |