Sha256: 561403421f06428d36214175be783c51f42fea31c348de8d42f52f04a5e1cda1
Contents?: true
Size: 749 Bytes
Versions: 38
Compression:
Stored size: 749 Bytes
Contents
require "net/https" module Recurly class ConnectionPool def initialize @mutex = Mutex.new @pool = [] end def with_connection http = nil @mutex.synchronize do http = @pool.pop end # create connection if the pool was empty http ||= init_http_connection response = yield http if http.started? @mutex.synchronize do @pool.push(http) end end response end def init_http_connection http = Net::HTTP.new(Client::BASE_HOST, Client::BASE_PORT) http.use_ssl = true http.ca_file = Client::CA_FILE http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.keep_alive_timeout = 600 http end end end
Version data entries
38 entries across 38 versions & 1 rubygems