Sha256: f4a1a3c4ed64e1e74731b5c53710401b02647dbc85b74de52f896427e5db623c
Contents?: true
Size: 1.08 KB
Versions: 5
Compression:
Stored size: 1.08 KB
Contents
class Net::HTTP::Persistent::Pool < ConnectionPool # :nodoc: attr_reader :available # :nodoc: attr_reader :key # :nodoc: def initialize(options = {}, &block) super @available = Net::HTTP::Persistent::TimedStackMulti.new(@size, &block) @key = "current-#{@available.object_id}" end def checkin net_http_args stack = Thread.current[@key][net_http_args] ||= [] raise ConnectionPool::Error, 'no connections are checked out' if stack.empty? conn = stack.pop if stack.empty? @available.push conn, connection_args: net_http_args Thread.current[@key].delete(net_http_args) Thread.current[@key] = nil if Thread.current[@key].empty? end nil end def checkout net_http_args stacks = Thread.current[@key] ||= {} stack = stacks[net_http_args] ||= [] if stack.empty? then conn = @available.pop connection_args: net_http_args else conn = stack.last end stack.push conn conn end def shutdown Thread.current[@key] = nil super end end require 'net/http/persistent/timed_stack_multi'
Version data entries
5 entries across 5 versions & 2 rubygems