Sha256: a4eb0a8d89cf03d6a34de9b306a34d97db25bdf6299ea30036bf4ed4457a6592
Contents?: true
Size: 976 Bytes
Versions: 3
Compression:
Stored size: 976 Bytes
Contents
require 'json' module BigBrother class HealthFetcher def self.current_health(address, port, path) url = "http://#{address}:#{port}#{path}" BigBrother.logger.debug("Fetching health from #{url}") response = EventMachine::HttpRequest.new(url).get response.response_header.status == 200 ? _parse_health(response) : 0 end def self.interpol_status(interpol_node, fwmark) url = "http://#{interpol_node.address}:#{interpol_node.port}/fwmark/#{fwmark}" BigBrother.logger.debug("Fetching health from #{url}") response = EventMachine::HttpRequest.new(url).get response.response_header.status == 200 ? JSON.parse(response.response) : [] rescue JSON::ParserError [] end def self._parse_health(response) if response.response_header.has_key?('X_HEALTH') response.response_header['X_HEALTH'].to_i else response.response.slice(/Health: (\d+)/, 1).to_i end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
big_brother-0.8.8.1 | lib/big_brother/health_fetcher.rb |
big_brother-0.8.8 | lib/big_brother/health_fetcher.rb |
big_brother-0.8.7 | lib/big_brother/health_fetcher.rb |