Parent

SSHKit::Backend::ConnectionPool

Constants

Entry

Attributes

idle_timeout[RW]

Public Class Methods

new() click to toggle source
# File lib/sshkit/backends/connection_pool.rb, line 11
def initialize
  self.idle_timeout = 30
  @monitor = Monitor.new
end

Public Instance Methods

create_or_reuse_connection(*new_connection_args, &block) click to toggle source
# File lib/sshkit/backends/connection_pool.rb, line 16
def create_or_reuse_connection(*new_connection_args, &block)
  # Optimization: completely bypass the pool if idle_timeout is zero.
  return yield(*new_connection_args) if idle_timeout == 0

  key = new_connection_args.to_s
  entry = find_and_reject_invalid(key) { |e| e.expired? || e.closed? }

  if entry.nil?
    entry = store_entry(key, yield(*new_connection_args))
  end

  entry.expires_at = Time.now + idle_timeout if idle_timeout
  entry.connection
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.