| Class | Mongo::Server::Connection |
| In: |
lib/mongo/server/connection.rb
|
| Parent: | ConnectionBase |
This class models the socket connections for servers and their behavior.
@since 2.0.0
| PING | = | { :ping => 1 }.freeze |
The ping command.
@since 2.1.0 @deprecated No longer necessary with Server Selection specification. |
|
| PING_OP_MSG | = | { :ping => 1, '$db' => Database::ADMIN }.freeze |
The ping command for an OP_MSG
(server versions >= 3.6).
@since 2.5.0 @deprecated No longer necessary with Server Selection specification. |
|
| PING_MESSAGE | = | Protocol::Query.new(Database::ADMIN, Database::COMMAND, PING, :limit => -1) |
Ping message.
@since 2.1.0 @deprecated No longer necessary with Server Selection specification. |
|
| PING_OP_MSG_MESSAGE | = | Protocol::Msg.new([], {}, PING_OP_MSG) |
Ping message as an OP_MSG (server versions >= 3.6).
@since 2.5.0 @deprecated No longer necessary with Server Selection specification. |
|
| PING_BYTES | = | PING_MESSAGE.serialize.to_s.freeze |
The ping message as raw bytes.
@since 2.1.0 @deprecated No longer necessary with Server Selection specification. |
|
| PING_OP_MSG_BYTES | = | PING_OP_MSG_MESSAGE.serialize.to_s.freeze |
The ping OP_MSG message as raw bytes
(server versions >= 3.6).
@since 2.5.0 @deprecated No longer necessary with Server Selection specification. |
| last_checkin | [R] |
The last time the connection was checked back into a pool.
@since 2.5.0 |
Creates a new connection object to the specified target address with the specified options.
The constructor does not perform any I/O (and thus does not create sockets, handshakes nor authenticates); call connect! method on the connection object to create the network connection.
@api private
@example Create the connection.
Connection.new(server)
@note Connection must never be directly instantiated outside of a
Server.
@param [ Mongo::Server ] server The server the connection is for. @param [ Hash ] options The connection options.
@option options [ Integer ] :generation Connection pool‘s generation
for this connection.
@since 2.0.0
Establishes a network connection to the target address.
If the connection is already established, this method does nothing.
@example Connect to the host.
connection.connect!
@note This method mutates the connection class by setting a socket if
one previously did not exist.
@return [ true ] If the connection succeeded.
@since 2.0.0
Disconnect the connection.
@example Disconnect from the host.
connection.disconnect!
@note This method mutates the connection by setting the socket to nil
if the closing succeeded.
@return [ true ] If the disconnect succeeded.
@since 2.0.0
Connection pool generation from which this connection was created. May be nil.
@since 2.7.0 @api private
Ping the connection to see if the server is responding to commands. This is non-blocking on the server side.
@example Ping the connection.
connection.ping
@note This uses a pre-serialized ping message for optimization.
@return [ true, false ] If the server is accepting connections.
@since 2.1.0
@deprecated No longer necessary with Server Selection specification.
Record the last checkin time.
@example Record the checkin time on this connection.
connection.record_checkin!
@return [ self ]
@since 2.5.0