Class Net::SSH::Multi::PendingConnection
In: lib/net/ssh/multi/pending_connection.rb
Parent: Object

A PendingConnection instance mimics a Net::SSH::Connection::Session instance, without actually being an open connection to a server. It is used by Net::SSH::Multi::Session when a concurrent connection limit is in effect, so that a server can hang on to a "connection" that isn‘t really a connection.

Any requests against this connection (like open_channel or send_global_request) are not actually sent, but are added to a list of recordings. When the real session is opened and replaces this pending connection, all recorded actions will be replayed against that session.

You‘ll never need to initialize one of these directly, and (if all goes well!) should never even notice that one of these is in use. Net::SSH::Multi::Session will instantiate these as needed, and only when there is a concurrent connection limit.

Methods

Attributes

server  [R]  The Net::SSH::Multi::Server object that "owns" this pending connection.

Public Class methods

Instantiates a new pending connection for the given Net::SSH::Multi::Server object.

[Source]

    # File lib/net/ssh/multi/pending_connection.rb, line 52
52:     def initialize(server)
53:       @server = server
54:       @recordings = []
55:     end

Public Instance methods

Always returns true, so that the pending connection looks active until it can be truly opened and replaced with a real connection.

[Source]

    # File lib/net/ssh/multi/pending_connection.rb, line 82
82:     def busy?(include_invisible=false)
83:       true
84:     end

Returns an empty array, since a pending connection cannot have any real channels.

[Source]

    # File lib/net/ssh/multi/pending_connection.rb, line 92
92:     def channels
93:       []
94:     end

Does nothing, except to make a pending connection quack like a real connection.

[Source]

    # File lib/net/ssh/multi/pending_connection.rb, line 87
87:     def close
88:       self
89:     end

Returns an empty hash, since a pending connection has no real listeners.

[Source]

     # File lib/net/ssh/multi/pending_connection.rb, line 107
107:     def listeners
108:       {}
109:     end

Records that a channel open request has been made, and returns a new Net::SSH::Multi::ChannelProxy object to represent the (as yet unopened) channel.

[Source]

    # File lib/net/ssh/multi/pending_connection.rb, line 67
67:     def open_channel(type="session", *extras, &on_confirm)
68:       channel = ChannelProxy.new(&on_confirm)
69:       @recordings << ChannelOpenRecording.new(type, extras, channel)
70:       return channel
71:     end

Returns true, and does nothing else.

[Source]

     # File lib/net/ssh/multi/pending_connection.rb, line 102
102:     def postprocess(readers, writers)
103:       true
104:     end

Returns true, and does nothing else.

[Source]

    # File lib/net/ssh/multi/pending_connection.rb, line 97
97:     def preprocess
98:       true
99:     end

Instructs the pending session to replay all of its recordings against the given session, and to then replace itself with the given session.

[Source]

    # File lib/net/ssh/multi/pending_connection.rb, line 59
59:     def replace_with(session)
60:       @recordings.each { |recording| recording.replay_on(session) }
61:       @server.replace_session(session)
62:     end

Records that a global request has been made. The request is not actually sent, and won‘t be until replace_with is called.

[Source]

    # File lib/net/ssh/multi/pending_connection.rb, line 75
75:     def send_global_request(type, *extra, &callback)
76:       @recordings << SendGlobalRequestRecording.new(type, extra, callback)
77:       self
78:     end

[Validate]