Class: RoundhouseUi::Backends::Sidekiq
- Inherits:
-
Object
- Object
- RoundhouseUi::Backends::Sidekiq
- Defined in:
- lib/roundhouse_ui/backends/sidekiq.rb
Overview
The Sidekiq implementation of the Roundhouse backend port. It is a thin
seam over Sidekiq's own API objects — controllers ask the backend for a
"set" or "stats" instead of naming Sidekiq::* directly, so a second
backend (Solid Queue) can supply duck-typed equivalents without touching
controllers or views.
Deliberately thin for now: each method returns the same Sidekiq object the controllers used before, so this refactor changes no behavior. The contract (what a "set" / "entry" must respond to) will be firmed up as the Solid Queue backend is built against it.
Constant Summary collapse
- CAPABILITIES =
Capabilities let the UI hide what a backend can't do. Sidekiq supports all the sets/views; pause is NOT native (needs the fetcher), so it does not advertise :native_pause — the "not enforced" warning still applies.
%i[retries dead scheduled busy workers redis capsules].freeze
Instance Method Summary collapse
-
#busy ⇒ Object
Currently-executing jobs, normalized to the Busy view's shape.
- #dead_set ⇒ Object
- #fetch_installed? ⇒ Boolean
- #name ⇒ Object
- #pause(name) ⇒ Object
-
#paused_queues ⇒ Object
--- pause (via the opt-in Roundhouse fetcher; not native) ---.
- #process_set ⇒ Object
- #push(payload) ⇒ Object
- #queue(name) ⇒ Object
- #queues ⇒ Object
- #resume(name) ⇒ Object
- #retry_set ⇒ Object
- #scheduled_set ⇒ Object
-
#set(kind) ⇒ Object
The job set a given UI section maps to (used by the job-detail page).
- #stats ⇒ Object
- #supports?(capability) ⇒ Boolean
- #work_set ⇒ Object
Instance Method Details
#busy ⇒ Object
Currently-executing jobs, normalized to the Busy view's shape. (This normalization used to live in BusyController; it belongs to the backend.)
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 45 def busy ::Sidekiq::WorkSet.new.map do |process_id, tid, work| if work.respond_to?(:queue) # Sidekiq 7+: Sidekiq::Work struct { process: process_id, tid: tid, queue: work.queue, run_at: work.run_at, job: work.job } else # Sidekiq 6.x: a plain Hash { process: process_id, tid: tid, queue: work["queue"], run_at: Time.at(work["run_at"]), job: ::Sidekiq::JobRecord.new(work["payload"]) } end end end |
#dead_set ⇒ Object
26 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 26 def dead_set = ::Sidekiq::DeadSet.new |
#fetch_installed? ⇒ Boolean
60 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 60 def fetch_installed? = RoundhouseUi::Pause.fetch_installed? |
#name ⇒ Object
14 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 14 def name = "Sidekiq" |
#pause(name) ⇒ Object
58 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 58 def pause(name) = RoundhouseUi::Pause.pause!(name) |
#paused_queues ⇒ Object
--- pause (via the opt-in Roundhouse fetcher; not native) ---
57 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 57 def paused_queues = RoundhouseUi::Pause.paused_set |
#process_set ⇒ Object
29 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 29 def process_set = ::Sidekiq::ProcessSet.new |
#push(payload) ⇒ Object
41 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 41 def push(payload) = ::Sidekiq::Client.push(payload) |
#queue(name) ⇒ Object
24 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 24 def queue(name) = ::Sidekiq::Queue.new(name) |
#queues ⇒ Object
23 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 23 def queues = ::Sidekiq::Queue.all |
#resume(name) ⇒ Object
59 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 59 def resume(name) = RoundhouseUi::Pause.unpause!(name) |
#retry_set ⇒ Object
25 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 25 def retry_set = ::Sidekiq::RetrySet.new |
#scheduled_set ⇒ Object
27 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 27 def scheduled_set = ::Sidekiq::ScheduledSet.new |
#set(kind) ⇒ Object
The job set a given UI section maps to (used by the job-detail page). Lazy — only builds the requested set.
33 34 35 36 37 38 39 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 33 def set(kind) case kind.to_s when "dead" then dead_set when "retry" then retry_set when "scheduled" then scheduled_set end end |
#stats ⇒ Object
22 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 22 def stats = ::Sidekiq::Stats.new |
#supports?(capability) ⇒ Boolean
20 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 20 def supports?(capability) = CAPABILITIES.include?(capability) |
#work_set ⇒ Object
28 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 28 def work_set = ::Sidekiq::WorkSet.new |