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. On OSS Sidekiq pause is NOT native (it needs our fetcher), so :native_pause is withheld and the "not enforced" warning applies — but Sidekiq Pro ships its own enforced pause, so there it is advertised and the warning drops away.
%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.)
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 52 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
33 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 33 def dead_set = ::Sidekiq::DeadSet.new |
#fetch_installed? ⇒ Boolean
67 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 67 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
65 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 65 def pause(name) = RoundhouseUi::Pause.pause!(name) |
#paused_queues ⇒ Object
--- pause (via the opt-in Roundhouse fetcher; not native) ---
64 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 64 def paused_queues = RoundhouseUi::Pause.paused_set |
#process_set ⇒ Object
36 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 36 def process_set = ::Sidekiq::ProcessSet.new |
#push(payload) ⇒ Object
48 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 48 def push(payload) = ::Sidekiq::Client.push(payload) |
#queue(name) ⇒ Object
31 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 31 def queue(name) = ::Sidekiq::Queue.new(name) |
#queues ⇒ Object
30 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 30 def queues = ::Sidekiq::Queue.all |
#resume(name) ⇒ Object
66 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 66 def resume(name) = RoundhouseUi::Pause.unpause!(name) |
#retry_set ⇒ Object
32 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 32 def retry_set = ::Sidekiq::RetrySet.new |
#scheduled_set ⇒ Object
34 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 34 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.
40 41 42 43 44 45 46 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 40 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
29 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 29 def stats = ::Sidekiq::Stats.new |
#supports?(capability) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 23 def supports?(capability) return RoundhouseUi::Pause.native? if capability == :native_pause CAPABILITIES.include?(capability) end |
#work_set ⇒ Object
35 |
# File 'lib/roundhouse_ui/backends/sidekiq.rb', line 35 def work_set = ::Sidekiq::WorkSet.new |