Class: Sidekiq::TUI::Tabs::Queues
- Inherits:
-
BaseTab
- Object
- BaseTab
- Sidekiq::TUI::Tabs::Queues
show all
- Defined in:
- lib/sidekiq/tui/tabs/queues.rb
Constant Summary
Constants included
from Controls
Controls::GLOBAL, Controls::SHARED
Instance Attribute Summary
Attributes inherited from BaseTab
#data, #name
Instance Method Summary
collapse
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
Instance Method Details
#controls ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/sidekiq/tui/tabs/queues.rb', line 11
def controls
@controls ||= super + [
{code: "D", modifiers: ["shift"], display: "D", description: "Delete",
action: ->(tui, tab) { tab.delete_queue! }, refresh: true},
{code: "p", description: "Pause/Unpause Queue",
action: ->(tui, tab) { tab.toggle_pause_queue! }}
]
end
|
#delete_queue! ⇒ Object
20
21
22
23
24
|
# File 'lib/sidekiq/tui/tabs/queues.rb', line 20
def delete_queue!
each_selection do |qname|
Sidekiq::Queue.new(qname).clear
end
end
|
#features ⇒ Object
7
8
9
|
# File 'lib/sidekiq/tui/tabs/queues.rb', line 7
def features
%i[selectable]
end
|
#refresh_data ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/sidekiq/tui/tabs/queues.rb', line 39
def refresh_data
refresh_data_for_stats
queue_summaries = Sidekiq::Stats.new.queue_summaries.sort_by(&:name)
selected = Array(@data[:selected])
queues = queue_summaries.map { |queue_summary|
row_cells = [
selected.index(queue_summary.name) ? "✅" : "",
queue_summary.name,
queue_summary.size.to_s,
number_with_delimiter(queue_summary.latency, {precision: 2})
]
row_cells << (queue_summary.paused? ? "✅" : "") if Sidekiq.pro?
row_cells
}
table_row_ids = queue_summaries.map(&:name)
@data[:queues] = queues
@data[:table] = {row_ids: table_row_ids}
end
|
#render(tui, frame, area) ⇒ Object
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
89
90
91
|
# File 'lib/sidekiq/tui/tabs/queues.rb', line 62
def render(tui, frame, area)
= ["☑️", "Queue", "Size", "Latency"].map { |x| t(x) }
<< "Paused?" if Sidekiq.pro?
chunks = tui.layout_split(
area,
direction: :vertical,
constraints: [
tui.constraint_length(4), tui.constraint_fill(1) ]
)
render_stats_section(tui, frame, chunks[0])
render_table(tui, frame, chunks[1]) do
{
title: t(name),
header:,
widths: .map.with_index { |_, idx|
tui.constraint_length((idx == 1) ? 60 : 10)
},
rows: @data[:queues].map.with_index { |cells, idx|
tui.table_row(
cells:,
style: idx.even? ? nil : tui.style(bg: :dark_gray)
)
}
}
end
end
|
#toggle_pause_queue! ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/sidekiq/tui/tabs/queues.rb', line 26
def toggle_pause_queue!
return unless Sidekiq.pro?
each_selection do |qname|
queue = Sidekiq::Queue.new(qname)
if queue.paused?
queue.unpause!
else
queue.pause!
end
end
end
|