
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
faraday_connection_pool
Advanced tools
FaradayConnectionPool provides a persistent Net::HTTP Faraday adapter. Unlike Net::HTTP::Persistent, which has a connection-per-thread, connections are pooled across all threads and you will always get the most recently used connection. This should mean that you are more likely to get an existing connection with a reduced chance of getting a connection reset
Add this line to your application's Gemfile:
gem 'faraday_connection_pool'
And then execute:
$ bundle
Or install it yourself as:
$ gem install faraday_connection_pool
If necessary require 'faraday_connection_pool'
Configure FaradayConnectionPool:
FaradayConnectionPool.configure do |config|
config.size = 5 #The number of connections to held in the pool. There is a separate pool for each host/port.
config.pool_timeout = 5 #If no connection is available from the pool within :pool_timeout seconds the adapter will raise a Timeout::Error.
config.keep_alive_timeout = 30 #Connections which has been unused for :keep_alive_timeout seconds are not reused.
end
:net_http_pooled
adapter provided by the gem:Faraday.new(:url => 'http://klarna.com') do |conn|
conn.adapter :net_http_pooled
end
FaradayConnectionPool will not automatically try and repair broken connections, so you should configure Faraday to retry for you:
Faraday.new do |conn|
conn.request :retry, max: 2, interval: 0.05,
interval_randomness: 0.5, backoff_factor: 2
exceptions: [ Faraday::Error::ConnectionFailed ]
conn.adapter :net_http_pooled
end
The :net_http_pooled adapter
will not complain if you configure it to use a proxy server, but this code is entirely
untested. Use this at your own risk and file an issue to tell us how it goes.
Run tests with script/test
.
The test framework pulls in files from Faraday to save us setting up an integration test framework here.
http://github.com/Ben-M/faraday_connection_pool/fork
)git checkout -b my-new-feature
)script/test
to check that the tests are passing.git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that faraday_connection_pool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.