Sha256: 1beee06169987e6b6ee2a71cc0a025d1173e21abbc8ab4ac4f8facdef2b81366

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8

require 'net/http'
require 'timeout'
require 'openssl'

# Ruby 2.1.x versions don't have OpenSSL::OPENSSL_LIBRARY_VERSION defined
ssl_version_const = OpenSSL.const_defined?(:OPENSSL_LIBRARY_VERSION) ? :OPENSSL_LIBRARY_VERSION : :OPENSSL_VERSION
ssl_version = OpenSSL.const_get(ssl_version_const).scan(/\d+\.\d+\.\d+/)[0]
if ssl_version.nil?
  TuneMyGc.log "!!! could not determine OpenSSL version !!!"
elsif ssl_version < "1.0.1"
  TuneMyGc.log "!!! and openssl version > 1.0.1 is required for syncing data with the configuration service !!!"
end

module TuneMyGc
  NETWORK_TIMEOUT = 30 #seconds
  KAMIZE_SYNC_TIMEOUT = 35 #seconds
  NETWORK_ERRORS = [ Timeout::Error, Errno::ETIMEDOUT, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED,
                     EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, IOError ]

  def self.http_client
    uri = URI("https://#{TuneMyGc::HOST}")
    client = Net::HTTP.new(uri.host, uri.port)
    client.use_ssl = true
    client.read_timeout = NETWORK_TIMEOUT
    client
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tunemygc-1.0.71 lib/tunemygc/network.rb
tunemygc-1.0.69 lib/tunemygc/network.rb
tunemygc-1.0.68 lib/tunemygc/network.rb
tunemygc-1.0.67 lib/tunemygc/network.rb