Class: SolidQueueTui::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_queue_tui/application.rb

Constant Summary collapse

VIEW_DASHBOARD =
0
VIEW_QUEUES =
1
VIEW_FAILED =
2
VIEW_IN_PROGRESS =
3
VIEW_BLOCKED =
4
VIEW_SCHEDULED =
5
VIEW_FINISHED =
6
VIEW_RECURRING =
7
VIEW_WORKERS =
8
VIEW_COUNT =
9
COMMAND_MAP =
{
  "dashboard"   => VIEW_DASHBOARD,
  "queues"      => VIEW_QUEUES,
  "failed"      => VIEW_FAILED,
  "inprogress"  => VIEW_IN_PROGRESS,
  "blocked"     => VIEW_BLOCKED,
  "scheduled"   => VIEW_SCHEDULED,
  "finished"    => VIEW_FINISHED,
  "recurring"   => VIEW_RECURRING,
  "workers"     => VIEW_WORKERS
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(dev: false) ⇒ Application

Returns a new instance of Application.



32
33
34
35
36
37
38
39
40
41
# File 'lib/solid_queue_tui/application.rb', line 32

def initialize(dev: false)
  @current_view = VIEW_DASHBOARD
  @last_refresh = Time.at(0)
  @stats = Data::Stats.empty
  @show_help = false
  @command_mode = false
  @command_input = ""
  @command_error = nil
  @dev = dev
end

Instance Method Details

#runObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/solid_queue_tui/application.rb', line 43

def run
  @refresh_interval = SolidQueueTui.refresh_interval
  setup_dev_reloader! if @dev

  RatatuiRuby.run do |tui|
    @tui = tui
    init_views
    refresh_data!

    loop do
      hot_reload! if @dev
      render
      event = @tui.poll_event
      refresh_data_if_needed
      break if handle_input(event)
    end
  end
end