Class: Kdep::Dashboard

Inherits:
Object
  • Object
show all
Defined in:
lib/kdep/dashboard.rb,
lib/kdep/dashboard/panel.rb,
lib/kdep/dashboard/layout.rb,
lib/kdep/dashboard/screen.rb,
lib/kdep/dashboard/log_panel.rb,
lib/kdep/dashboard/health_panel.rb,
lib/kdep/dashboard/rollout_panel.rb,
lib/kdep/dashboard/resources_panel.rb

Defined Under Namespace

Modules: Screen Classes: HealthPanel, Layout, LogPanel, Panel, Rect, ResourcesPanel, RolloutPanel

Constant Summary collapse

PANEL_ORDER =
[:rollout, :logs, :resources, :health].freeze
PANEL_NAMES =
{ rollout: "Rollout", logs: "Logs", resources: "Resources", health: "Health" }.freeze
REFRESH_INTERVAL =
0.25

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Dashboard

Returns a new instance of Dashboard.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kdep/dashboard.rb', line 17

def initialize(config)
  @config = config
  @name = config["name"]
  @namespace = config["namespace"] || "default"
  @deployment_name = config["deployment_name"] || @name
  @panels = {}
  @active_panel = :rollout
  @quit = false
  @running = false
  @threads = []
  @ios = []
  @mutex = Mutex.new
end

Instance Method Details

#runObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/kdep/dashboard.rb', line 31

def run
  unless $stdout.tty?
    puts "Dashboard skipped: not a TTY"
    return
  end

  rows, cols = IO.console.winsize
  return if init_panels(rows, cols).nil?

  $stdout.print Screen.enter_sequence
  $stdout.flush
  @running = true
  @quit = false

  setup_signal_handlers
  start_log_thread
  start_rollout_thread
  start_metrics_thread

  begin
    $stdin.raw do |raw_stdin|
      until @quit
        if IO.select([raw_stdin], nil, nil, 0)
          key = raw_stdin.getc
          handle_key(key) if key
        end
        break if @quit
        render_all_panels($stdout, rows, cols)
        sleep REFRESH_INTERVAL
      end
    end
  ensure
    stop_data_threads
    $stdout.print Screen.exit_sequence
    $stdout.flush
  end
end