Class: Sidekiq::TUI::Tabs::Busy
- Defined in:
- lib/sidekiq/tui/tabs/busy.rb
Constant Summary
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
#each_selection, #error, #error=, #filtering?, #format_memory, #initialize, #navigate_row, #next_page, #number_with_delimiter, #prev_page, #refresh_data_for_stats, #render_stats_section, #render_table, #reset_data, #selected?, #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 84 85 86 87 88 |
# 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: @data[:busy].map.with_index { |cells, idx| tui.table_row( cells:, style: idx.even? ? nil : tui.style(bg: :dark_gray) ) } } end end |
#render_status_section(tui, frame, area) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/sidekiq/tui/tabs/busy.rb', line 90 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] keys_line = keys.map { |k| t(k).to_s.ljust(12) }.join(" ") values_line = values.map { |v| v.to_s.ljust(12) }.join(" ") frame.( tui.paragraph( text: [keys_line, values_line], block: tui.block(title: t("Status"), borders: [:all]) ), area ) end |