Sha256: 20e198c2fd7f369b9adcdf3d5e7a88c8a6236848ac9739c9310c8dcc7c28c8f5

Contents?: true

Size: 576 Bytes

Versions: 13

Compression:

Stored size: 576 Bytes

Contents

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._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

13 entries across 13 versions & 1 rubygems

Version Path
big_brother-0.6.8 lib/big_brother/health_fetcher.rb
big_brother-0.6.7 lib/big_brother/health_fetcher.rb
big_brother-0.6.6 lib/big_brother/health_fetcher.rb
big_brother-0.6.5 lib/big_brother/health_fetcher.rb
big_brother-0.6.4 lib/big_brother/health_fetcher.rb
big_brother-0.6.3 lib/big_brother/health_fetcher.rb
big_brother-0.6.2 lib/big_brother/health_fetcher.rb
big_brother-0.6.1 lib/big_brother/health_fetcher.rb
big_brother-0.6.0 lib/big_brother/health_fetcher.rb
big_brother-0.5.0 lib/big_brother/health_fetcher.rb
big_brother-0.4.1 lib/big_brother/health_fetcher.rb
big_brother-0.4.0 lib/big_brother/health_fetcher.rb
big_brother-0.3.1 lib/big_brother/health_fetcher.rb