Class: Zhong::Web

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/zhong/web.rb

Overview

Most of the following helpers are copied from a previous version of the Sidekiq project available here: github.com/mperham/sidekiq/blob/2c9f7662fcdcb52d59b72ba0fe7dc5f963de4904/lib/sidekiq/web.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



59
60
61
62
63
64
# File 'lib/zhong/web.rb', line 59

def index
  @jobs = Zhong.jobs.values
  @last_runs = zhong_mget(@jobs, "last_ran")
  @disabled = zhong_mget(@jobs, "disabled")
  @hosts = Zhong.all_heartbeats
end

#zhong_mget(jobs, key) ⇒ Object



66
67
68
69
70
# File 'lib/zhong/web.rb', line 66

def zhong_mget(jobs, key)
  keys = jobs.map(&:to_s)
  ret = Zhong::Util.safe_mget(keys.map { |j| "zhong:#{key}:#{j}" })
  Hash[keys.map { |j| [j, ret["zhong:#{key}:#{j}"]] }]
end