Sha256: b49d69e64644d49a783add535f98e905ac4a5d9c43b3fe4aac549c70595104d4

Contents?: true

Size: 498 Bytes

Versions: 1

Compression:

Stored size: 498 Bytes

Contents

module BigBrother
  class HealthFetcher
    def self.current_health(address, port, path)
      response = EventMachine::HttpRequest.new("http://#{address}:#{port}#{path}").get
      response.response_header.status == 200 ? _parse_health(response) : 0
    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

1 entries across 1 versions & 1 rubygems

Version Path
big_brother-0.3.0 lib/big_brother/health_fetcher.rb