Skip to content

Instantly share code, notes, and snippets.

/2.rb Secret

Created September 15, 2016 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/076ca83cf691a3a386aa2cf1431b32ad to your computer and use it in GitHub Desktop.
Save anonymous/076ca83cf691a3a386aa2cf1431b32ad to your computer and use it in GitHub Desktop.
class SfdcHTTP
attr_accessor :expiration_date, :client
def initialize
@@client ||= set_client
@@expiration_date = nil
end
class << self
def get_client
if expiration_date == nil
set_client
client
elsif Time.now - expiration_date < 240
client
else
set_client
client
end
end
def set_client
expiration_date = Time.now
client = Manticore::Client.new(
keepalive: true,
pool_max: 50,
pool_max_per_route: 50,
ssl: { verify: :disable }
)
client
end
end # End class methods
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment