| Class | SSHKit::Backend::ConnectionPool |
| In: |
lib/sshkit/backends/connection_pool.rb
|
| Parent: | Object |
The ConnectionPool caches connections and allows them to be reused, so long as the reuse happens within the `idle_timeout` period. Timed out connections are eventually closed, forcing a new connection to be used in that case.
Additionally, a background thread is started to check for abandoned connections that have timed out without any attempt at being reused. These are eventually closed as well and removed from the cache.
If `idle_timeout` set to `false`, `0`, or `nil`, no caching is performed, and a new connection is created and then immediately closed each time. The default timeout is 30 (seconds).
There is a single public method: `with`. Example usage:
pool = SSHKit::Backend::ConnectionPool.new
pool.with(Net::SSH.method(:start), "host", "username") do |connection|
# do stuff with connection
end