Class: SSHKit::Backend::ConnectionPool

### Home Classes Methods

### In Files

- lib/sshkit/backends/connection_pool.rb

### Parent

Object

### Methods

- ::new
- #checkin
- #checkout
- #flush_connections

### Class/Module Index

Quicksearch

- SSHKit
- SSHKit::Backend
- SSHKit::Backend::Abstract
- SSHKit::Backend::ConnectionPool
- SSHKit::Backend::Local
- SSHKit::Backend::Netssh
- SSHKit::Backend::Netssh::Configuration
- SSHKit::Backend::Printer
- SSHKit::Backend::Skipper
- SSHKit::CommandMap
- SSHKit::CommandMap::CommandHash
- SSHKit::CommandMap::PrefixProvider
- SSHKit::Configuration
- SSHKit::Coordinator
- SSHKit::DSL
- SSHKit::Formatter
- SSHKit::Formatter::Abstract
- SSHKit::Formatter::BlackHole
- SSHKit::Formatter::Dot
- SSHKit::Formatter::Pretty
- SSHKit::Formatter::SimpleText
- SSHKit::Host
- SSHKit::HostWithPortParser
- SSHKit::HostWithUsernameAndPortParser
- SSHKit::HostWithUsernameParser
- SSHKit::IPv6HostWithPortParser
- SSHKit::LogMessage
- SSHKit::Logger
- SSHKit::Logger::SSHKit
- SSHKit::Logger::SSHKit::Logger
- SSHKit::Logger::SSHKit::Logger::Net
- SSHKit::Logger::SSHKit::Logger::Net::SSH
- SSHKit::Logger::SSHKit::Logger::Net::SSH::LogLevelShim
- SSHKit::Runner
- SSHKit::Runner::Abstract
- SSHKit::Runner::ExecuteError
- SSHKit::Runner::Group
- SSHKit::Runner::Null
- SSHKit::Runner::Parallel
- SSHKit::Runner::Sequential
- SSHKit::SimpleHostParser
- SSHKit::Utils
- SSHKit::Utils::CaptureOutputMethods
- Net
- Net::SSH
- Net::SSH::Config
- Array
- Color
- Hash
- Object

No matching classes.

# 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
      @mutex = Mutex.new
      @pool = {}
    end

### Public Instance Methods

checkin(entry) click to toggle source

    # File lib/sshkit/backends/connection_pool.rb, line 25
    def checkin(entry)
      entry.expires_at = Time.now + idle_timeout if idle_timeout
      @mutex.synchronize do
        @pool[entry.key] ||= []
        @pool[entry.key] << entry
      end
    end

checkout(*new_connection_args, &block) click to toggle source

    # File lib/sshkit/backends/connection_pool.rb, line 17
    def checkout(*new_connection_args, &block)
      # Optimization: completely bypass the pool if idle_timeout is zero.
      key = new_connection_args.to_s
      return create_new_entry(new_connection_args, key, &block) if idle_timeout == 0

      find_live_entry(key) || create_new_entry(new_connection_args, key, &block)
    end

flush_connections() click to toggle source

    # File lib/sshkit/backends/connection_pool.rb, line 33
    def flush_connections
      @mutex.synchronize { @pool.clear }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.