Class: Legion::CLI::Dashboard::DataFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/cli/dashboard/data_fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_url: 'http://localhost:4567') ⇒ DataFetcher

Returns a new instance of DataFetcher.



9
10
11
# File 'lib/legion/cli/dashboard/data_fetcher.rb', line 9

def initialize(base_url: 'http://localhost:4567')
  @base_url = base_url
end

Instance Method Details

#healthObject



17
18
19
# File 'lib/legion/cli/dashboard/data_fetcher.rb', line 17

def health
  fetch('/api/health') || {}
end

#recent_events(limit: 10) ⇒ Object



21
22
23
# File 'lib/legion/cli/dashboard/data_fetcher.rb', line 21

def recent_events(limit: 10)
  fetch("/api/events/recent?limit=#{limit}") || []
end

#summaryObject



25
26
27
28
29
30
31
32
# File 'lib/legion/cli/dashboard/data_fetcher.rb', line 25

def summary
  {
    workers:    workers,
    health:     health,
    events:     recent_events,
    fetched_at: Time.now
  }
end

#workersObject



13
14
15
# File 'lib/legion/cli/dashboard/data_fetcher.rb', line 13

def workers
  fetch('/api/workers') || []
end