Class: Mongo::Server::ConnectionCommon

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/server/connection_common.rb

Overview

Note:

Although methods of this module are part of the public API, the fact that these methods are defined on this module and not on the classes which include this module is not part of the public API.

Common methods used by both monitoring and non-monitoring connections.

Since:

  • 2.0.0

Direct Known Subclasses

ConnectionBase, Monitor::Connection

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#compressorString | nil (readonly)

The compressor negotiated during the handshake for this connection, if any.

This attribute is nil for connections that haven’t completed the handshake yet, and for connections that negotiated no compression.

Returns:

  • (String | nil)

    The compressor.

Since:

  • 2.0.0



34
35
36
# File 'lib/mongo/server/connection_common.rb', line 34

def compressor
  @compressor
end

#pidInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns pid The process id when the connection was created.

Returns:

  • (Integer)

    pid The process id when the connection was created.

Since:

  • 2.0.0



50
51
52
# File 'lib/mongo/server/connection_common.rb', line 50

def pid
  @pid
end

Instance Method Details

#connected?true, false

Deprecated.

Determine if the connection is currently connected.

Examples:

Is the connection connected?

connection.connected?

Returns:

  • (true, false)

    If connected.

Since:

  • 2.0.0



44
45
46
# File 'lib/mongo/server/connection_common.rb', line 44

def connected?
  !!socket
end