我不明白下面的 ruby 代码是做什么的。谁能给我一些解释。谢谢!
map '/healthz' do
run Healthz.new(logger)
end
Healthz 是:
class Healthz
def initialize(logger)
@logger = logger
end
def call(env)
@logger.debug "healthz access"
healthz = Component.updated_healthz
[200, { 'Content-Type' => 'application/json', 'Content-Length' => healthz.length.to_s }, healthz]
rescue => e
@logger.error "healthz error #{e.inspect} #{e.backtrace.join("\n")}"
raise e
end
end
使用的库是:
require "eventmachine"
require 'thin'
require "yajl"
require "nats/client"
require "base64"
require 'set'