Module: Mongo::Server::Connectable

Included in:
Connection, Monitor::Connection
Defined in:
lib/mongo/server/connectable.rb

Overview

This provides common behavior for connection objects.

Since:

  • 2.0.0

Constant Summary collapse

SSL =

The ssl option prefix.

Since:

  • 2.1.0

'ssl'.freeze
TIMEOUT =
Deprecated.

Timeouts on Ruby sockets aren't effective so this default option is no longer used. Will be removed in driver version 3.0.

The default time in seconds to timeout an operation executed on a socket.

Since:

  • 2.0.0

5.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pidInteger (readonly)

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



38
39
40
# File 'lib/mongo/server/connectable.rb', line 38

def pid
  @pid
end

Instance Method Details

#connectable?true, false

Deprecated.

No longer necessary with Server Selection specification.

Determine if the server is connectable. This will check not only if the connection exists, but if messages can send to it successfully.

Examples:

Is the server connectable?

connection.connectable?

Returns:

  • (true, false)

    If the connection is connectable.

Since:

  • 2.1.0



51
# File 'lib/mongo/server/connectable.rb', line 51

def connectable?; end

#connected?true, false

Deprecated.

Use #connectable? instead

Determine if the connection is currently connected.

Examples:

Is the connection connected?

connection.connected?

Returns:

  • (true, false)

    If connected.

Since:

  • 2.0.0



61
62
63
# File 'lib/mongo/server/connectable.rb', line 61

def connected?
  !!@socket && @socket.alive?
end