Class: Sidekiq::TUI::Tabs::Busy
- Defined in:
- lib/sidekiq/tui/tabs/busy.rb
Constant Summary
Constants inherited from BaseTab
Constants included from Controls
Controls::GLOBAL, Controls::SHARED
Instance Attribute Summary
Attributes inherited from BaseTab
Instance Method Summary collapse
- #controls ⇒ Object
- #features ⇒ Object
- #quiet! ⇒ Object
- #refresh_data ⇒ Object
- #render(tui, frame, area) ⇒ Object
- #render_status_section(tui, frame, area) ⇒ Object
- #terminate! ⇒ Object
Methods inherited from BaseTab
#chart_y_axis, #each_selection, #error, #error=, #filtering?, #format_memory, #initialize, #navigate_row, #next_page, #number_with_delimiter, #prev_page, #refresh_data_for_stats, #render_kv_section, #render_stats_section, #render_table, #reset_data, #selected?, #stats_content_split, #striped_rows, #t, #toggle_select
Constructor Details
This class inherits a constructor from Sidekiq::TUI::BaseTab
Instance Method Details
#controls ⇒ Object
11 12 13 14 15 16 |
# File 'lib/sidekiq/tui/tabs/busy.rb', line 11 def controls @controls ||= super + [ {code: "T", modifiers: ["shift"], description: "Terminate", action: ->(tui, tab) { tab.terminate! }}, {code: "Q", modifiers: ["shift"], description: "Quiet", action: ->(tui, tab) { tab.quiet! }} ] end |
#features ⇒ Object
7 8 9 |
# File 'lib/sidekiq/tui/tabs/busy.rb', line 7 def features %i[selectable] end |
#quiet! ⇒ Object
18 19 20 21 22 |
# File 'lib/sidekiq/tui/tabs/busy.rb', line 18 def quiet! each_selection do |id| Sidekiq::Process.new("identity" => id).quiet! end end |
#refresh_data ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sidekiq/tui/tabs/busy.rb', line 30 def refresh_data refresh_data_for_stats busy = [] table_row_ids = [] Sidekiq::ProcessSet.new.each do |p| name = "#{p["hostname"]}:#{p["pid"]}" name += " ⭐️" if p.leader? name += " 🛑" if p.stopping? busy << [ selected?(p) ? "✅" : "", name, Time.at(p["started_at"]).utc, format_memory(p["rss"].to_i), number_with_delimiter(p["concurrency"]), number_with_delimiter(p["busy"]) ] table_row_ids << p.identity end @data[:busy] = busy @data[:table] = {row_ids: table_row_ids} end |
#render(tui, frame, area) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/sidekiq/tui/tabs/busy.rb', line 55 def render(tui, frame, area) chunks = tui.layout_split( area, direction: :vertical, constraints: [ tui.constraint_length(4), # Stats tui.constraint_length(4), # Status tui.constraint_fill(1) # Graph ] ) render_stats_section(tui, frame, chunks[0]) render_status_section(tui, frame, chunks[1]) render_table(tui, frame, chunks[2]) do { title: t("Processes"), header: ["☑️", "Name", "Started", "RSS", "Threads", "Busy"].map { |x| t(x) }, widths: [ tui.constraint_length(5), tui.constraint_fill(1), tui.constraint_length(24), tui.constraint_length(10), tui.constraint_length(6), tui.constraint_length(6) ], rows: striped_rows(tui, @data[:busy]) } end end |
#render_status_section(tui, frame, area) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/sidekiq/tui/tabs/busy.rb', line 85 def render_status_section(tui, frame, area) values = [] processes = Sidekiq::ProcessSet.new workset = Sidekiq::WorkSet.new ws = workset.size values << (s = processes.size number_with_delimiter(s)) values << (x = processes.total_concurrency number_with_delimiter(x)) values << number_with_delimiter(ws) values << "#{(x == 0) ? 0 : ((ws / x.to_f) * 100).round(0)}%" values << format_memory(processes.total_rss) keys = %w[Processes Threads Busy Utilization RSS] render_kv_section(tui, frame, area, title: t("Status"), keys:, values:) end |