Class: Mongo::Server::ConnectionCommon
- Inherits:
-
Object
- Object
- Mongo::Server::ConnectionCommon
- Defined in:
- lib/mongo/server/connection_common.rb
Overview
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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#compressor ⇒ String | nil
readonly
The compressor negotiated during the handshake for this connection, if any.
-
#pid ⇒ Integer
readonly
private
Pid The process id when the connection was created.
Instance Method Summary collapse
- #connected? ⇒ true, false deprecated Deprecated.
-
#handshake_command(handshake_document) ⇒ Protocol::Message
private
Build a command that should be used for connection handshake.
-
#handshake_document(app_metadata, speculative_auth_doc: nil, load_balancer: false, server_api: nil) ⇒ BSON::Document
private
Build a document that should be used for connection handshake.
Instance Attribute Details
#compressor ⇒ String | 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.
34 35 36 |
# File 'lib/mongo/server/connection_common.rb', line 34 def compressor @compressor end |
#pid ⇒ Integer (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.
50 51 52 |
# File 'lib/mongo/server/connection_common.rb', line 50 def pid @pid end |
Instance Method Details
#connected? ⇒ true, false
Determine if the connection is currently connected.
44 45 46 |
# File 'lib/mongo/server/connection_common.rb', line 44 def connected? !!socket end |
#handshake_command(handshake_document) ⇒ Protocol::Message
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.
Build a command that should be used for connection handshake.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/mongo/server/connection_common.rb', line 87 def handshake_command(handshake_document) if handshake_document['apiVersion'] || handshake_document['loadBalanced'] Protocol::Msg.new( [], {}, handshake_document.merge({ '$db' => Database::ADMIN }) ) else Protocol::Query.new( Database::ADMIN, Database::COMMAND, handshake_document, limit: -1 ) end end |
#handshake_document(app_metadata, speculative_auth_doc: nil, load_balancer: false, server_api: nil) ⇒ BSON::Document
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.
Build a document that should be used for connection handshake.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mongo/server/connection_common.rb', line 65 def handshake_document(, speculative_auth_doc: nil, load_balancer: false, server_api: nil) serv_api = .server_api || server_api document = if serv_api HELLO_DOC.merge(Utils.transform_server_api(serv_api)) else LEGACY_HELLO_DOC end document.merge(.validated_document).tap do |doc| doc.update(speculativeAuthenticate: speculative_auth_doc) if speculative_auth_doc doc.update(loadBalanced: true) if load_balancer end end |