Sha256: e097a8e03e50a47b9b8dd45fdc75a3fb9a9da57d976c58800371ca52972a3a64

Contents?: true

Size: 697 Bytes

Versions: 7

Compression:

Stored size: 697 Bytes

Contents

module Sprinkle
  module Actors
    class SSHConnectionCache #:nodoc:
      def initialize(options={}) 
        @cache = {}
        @gateway = Net::SSH::Gateway.new(options[:gateway], options[:user]) if options[:gateway]
      end
      def start(host, user, opts={})
        key="#{host}/#{user}#{opts.to_s}"
        if @gateway
          @cache[key] ||= @gateway.ssh(host, user, opts)
        else
          @cache[key] ||= Net::SSH.start(host, user, opts)
        end
      end
      def reconnect(host)
        @cache.delete_if do |k,v| 
          (v.close; true) if k =~ /^#{host}\//
        end
      end
      def shutdown!
        @gateway.shutdown! if @gateway
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sprinkle-0.7.7 lib/sprinkle/actors/ssh/connection_cache.rb
sprinkle-0.7.6.2 lib/sprinkle/actors/ssh/connection_cache.rb
sprinkle-0.7.6.1 lib/sprinkle/actors/ssh/connection_cache.rb
sprinkle-0.7.6 lib/sprinkle/actors/ssh/connection_cache.rb
sprinkle-0.7.5 lib/sprinkle/actors/ssh/connection_cache.rb
sprinkle-0.7.4 lib/sprinkle/actors/ssh/connection_cache.rb
sprinkle-0.7.3 lib/sprinkle/actors/ssh/connection_cache.rb