module Sidekiq::Throttled::Web
Provides Sidekiq
tab to monitor and reset throttled stats.
Constants
- QUEUES_TPL
- THROTTLED_TPL
- VIEWS
Public Class Methods
enhance_queues_tab!()
click to toggle source
Replace default Queues tab with enhanced one.
# File lib/sidekiq/throttled/web.rb, line 25 def enhance_queues_tab! SummaryFix.enabled = true Sidekiq::Web::DEFAULT_TABS["Queues"] = "enhanced-queues" Sidekiq::Web.tabs.delete("Enhanced Queues") end
registered(app)
click to toggle source
@api private
# File lib/sidekiq/throttled/web.rb, line 42 def registered(app) SummaryFix.apply! app register_throttled_tab app register_enhanced_queues_tab app end
restore_queues_tab!()
click to toggle source
Restore original Queues tab.
@api There's next to absolutely no value in this method for real
users. The only it's purpose is to restore virgin state in specs.
# File lib/sidekiq/throttled/web.rb, line 35 def restore_queues_tab! SummaryFix.enabled = false Sidekiq::Web::DEFAULT_TABS["Queues"] = "queues" Sidekiq::Web.tabs["Enhanced Queues"] = "enhanced-queues" end
Private Class Methods
register_enhanced_queues_tab(app)
click to toggle source
rubocop:disable Metrics/AbcSize
# File lib/sidekiq/throttled/web.rb, line 60 def register_enhanced_queues_tab(app) pauser = QueuesPauser.instance app.get("/enhanced-queues") do @queues = Sidekiq::Queue.all erb QUEUES_TPL.dup end app.post("/enhanced-queues/:name") do case params[:action] when "delete" then Sidekiq::Queue.new(params[:name]).clear when "pause" then pauser.pause!(params[:name]) else pauser.resume!(params[:name]) end redirect "#{root_path}enhanced-queues" end end
register_throttled_tab(app)
click to toggle source
# File lib/sidekiq/throttled/web.rb, line 50 def register_throttled_tab(app) app.get("/throttled") { erb THROTTLED_TPL.dup } app.post("/throttled/:id/reset") do Registry.get(params[:id], &:reset!) redirect "#{root_path}throttled" end end