You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I needed a pool of proxies to cycle through and didn't see any direct support in this library. I've made a patch to supply this and thought others might benefit from it as well. If you'd like to include it in the library, I'll be happy to prepare a PR.
# An array of proxies to cycle through
class ProxyPool < Array
def self.instance
@instance ||= new
end
def initialize
@lock = Mutex.new
@pos = 0
end
def checkout
if any?
@lock.synchronize do
next_item = self[@pos % length]
@pos += 1
next_item
end
end
end
module Hook
def self.included(klass)
klass.class_eval do
def self.environment_proxy
ProxyPool.instance.checkout || super
end
end
end
end
end # class ProxyPool
class TCPSocket
include ProxyPool::Hook
end
Hi,
I needed a pool of proxies to cycle through and didn't see any direct support in this library. I've made a patch to supply this and thought others might benefit from it as well. If you'd like to include it in the library, I'll be happy to prepare a PR.
Usage:
The text was updated successfully, but these errors were encountered: