class HealthTools

Public Class Methods

add_component(data) click to toggle source
# File lib/health_tools.rb, line 9
def self.add_component(data)
  HTTParty.post(ENV['server_host'] + '/api/component', body: data)
end
check(data_content) click to toggle source
# File lib/health_tools.rb, line 13
def self.check(data_content)
  self.reply_health(data_content)
end
component(data) click to toggle source
# File lib/health_tools.rb, line 5
def self.component(data)
  self.add_component(data)
end
convert_type(data) click to toggle source
# File lib/health_tools.rb, line 29
def self.convert_type(data)
  hash = {}
  data.each do |key, value|
    value = value.to_s
    hash.store(key, value)
  end
  hash
end
get_checksum(data) click to toggle source
# File lib/health_tools.rb, line 24
def self.get_checksum(data)
  data = self.convert_type(data)
  Digest::SHA2.hexdigest(data.to_s)
end
reply_health(data) click to toggle source
# File lib/health_tools.rb, line 17
def self.reply_health(data)
  data.store("service_code", ENV['service_code'])
  data.store("start_time", DateTime.now.strftime("%d/%m/%Y %H:%M"))
  data.store("checksum", get_checksum(data))
  HTTParty.post(ENV['server_host'] + '/api/report', body: data)
end