Class: Mongo::Server::ConnectionBase
- Inherits:
-
ConnectionCommon
- Object
- ConnectionCommon
- Mongo::Server::ConnectionBase
- Extended by:
- Forwardable
- Includes:
- Monitoring::Publishable
- Defined in:
- lib/mongo/server/connection_base.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.
This class encapsulates common connection functionality.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_MAX_BSON_OBJECT_SIZE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The maximum allowed size in bytes that a user-supplied document may take up when serialized, if the server’s ismaster response does not include maxBsonObjectSize field.
The commands that are sent to the server may exceed this size by MAX_BSON_COMMAND_OVERHEAD.
16777216- MAX_BSON_COMMAND_OVERHEAD =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The additional overhead allowed for command data (i.e. fields added to the command document by the driver, as opposed to documents provided by the user) when serializing a complete command to BSON.
16384- REDUCED_MAX_BSON_SIZE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
2097152
Constants included from Loggable
Instance Attribute Summary collapse
-
#description ⇒ Server::Description
readonly
private
Returns the server description for this connection, derived from the isMaster response for the handshake performed on this connection.
-
#options ⇒ Hash
readonly
Options The passed in options.
-
#server ⇒ Mongo::Address
readonly
Address The address to connect to.
Attributes included from Monitoring::Publishable
Attributes inherited from ConnectionCommon
Instance Method Summary collapse
- #app_metadata ⇒ Object
-
#dispatch(messages, operation_id = nil, client = nil, options = {}) ⇒ Protocol::Message | nil
Dispatch a single message to the connection.
-
#generation ⇒ Integer | nil
Connection pool generation from which this connection was created.
Methods included from Monitoring::Publishable
#publish_cmap_event, #publish_event, #publish_sdam_event
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Methods inherited from ConnectionCommon
Instance Attribute Details
#description ⇒ Server::Description (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.
A connection object that hasn’t yet connected (handshaken and authenticated, if authentication is required) does not have a description. While handshaking and authenticating the driver must be using global defaults, in particular not assuming that the properties of a particular connection are the same as properties of other connections made to the same address (since the server on the other end could have been shut down and a different server version could have been launched).
Returns the server description for this connection, derived from the isMaster response for the handshake performed on this connection.
79 80 81 |
# File 'lib/mongo/server/connection_base.rb', line 79 def description @description end |
#options ⇒ Hash (readonly)
Returns options The passed in options.
50 51 52 |
# File 'lib/mongo/server/connection_base.rb', line 50 def end |
#server ⇒ Mongo::Address (readonly)
Returns address The address to connect to.
55 56 57 |
# File 'lib/mongo/server/connection_base.rb', line 55 def server @server end |
Instance Method Details
#app_metadata ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/mongo/server/connection_base.rb', line 96 def ||= begin same = true AppMetadata::AUTH_OPTION_KEYS.each do |key| if @server.[key] != [key] same = false break end end if same @server. else AppMetadata.new() end end end |
#dispatch(messages, operation_id = nil, client = nil, options = {}) ⇒ Protocol::Message | nil
This method is named dispatch since ‘send’ is a core Ruby method on all objects.
For backwards compatibility, this method accepts the messages as an array. However, exactly one message must be given per invocation.
Dispatch a single message to the connection. If the message requires a response, a reply will be returned.
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/mongo/server/connection_base.rb', line 137 def dispatch(, operation_id = nil, client = nil, = {}) # The monitoring code does not correctly handle multiple messages, # and the driver internally does not send more than one message at # a time ever. Thus prohibit multiple message use for now. if .length != 1 raise ArgumentError, 'Can only dispatch one message at a time' end = .first deliver(, client, ) end |
#generation ⇒ Integer | nil
Connection pool generation from which this connection was created. May be nil.
92 93 94 |
# File 'lib/mongo/server/connection_base.rb', line 92 def generation [:generation] end |