Class: Mongo::Server::AppMetadata Private
- Inherits:
-
Object
- Object
- Mongo::Server::AppMetadata
- Extended by:
- Forwardable
- Defined in:
- lib/mongo/server/app_metadata.rb,
lib/mongo/server/app_metadata/platform.rb,
lib/mongo/server/app_metadata/truncator.rb,
lib/mongo/server/app_metadata/environment.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Application metadata that is sent to the server during a handshake,
when a new connection is established.
Direct Known Subclasses
Defined Under Namespace
Classes: Environment, Platform, Truncator
Constant Summary collapse
- MAX_APP_NAME_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 max application name byte size.
128- DRIVER_NAME =
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 driver name.
'mongo-ruby-driver'- AUTH_OPTION_KEYS =
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.
Option keys that affect auth mechanism negotiation.
%i[ user auth_source auth_mech].freeze
- PURPOSES =
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.
Possible connection purposes.
%i[ application monitor push_monitor ].freeze
Instance Attribute Summary collapse
-
#platform ⇒ String
readonly
private
The platform information given when the object was instantiated.
-
#purpose ⇒ Symbol
readonly
private
The purpose of the connection for which this app metadata is created.
-
#server_api ⇒ Hash | nil
readonly
private
The requested server API version.
-
#wrapping_libraries ⇒ Array<Hash> | nil
readonly
private
Information about libraries wrapping the driver.
Instance Method Summary collapse
-
#client_document ⇒ BSON::Document
private
Get BSON::Document to be used as value for ‘client` key in handshake document.
-
#initialize(options = {}) ⇒ AppMetadata
constructor
private
Instantiate the new AppMetadata object.
-
#validated_document ⇒ BSON::Document
private
Get the metadata as BSON::Document to be sent to as part of the handshake.
Constructor Details
#initialize(options = {}) ⇒ AppMetadata
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.
Instantiate the new AppMetadata object.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/mongo/server/app_metadata.rb', line 72 def initialize( = {}) @app_name = [:app_name].to_s if [:app_name] @platform = [:platform] @purpose = check_purpose!([:purpose]) @compressors = [:compressors] || [] @wrapping_libraries = [:wrapping_libraries] @server_api = [:server_api] return unless [:user] && ![:auth_mech] auth_db = [:auth_source] || 'admin' @request_auth_mech = "#{auth_db}.#{[:user]}" end |
Instance Attribute Details
#platform ⇒ String (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 The platform information given when the object was instantiated.
94 95 96 |
# File 'lib/mongo/server/app_metadata.rb', line 94 def platform @platform end |
#purpose ⇒ Symbol (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 The purpose of the connection for which this app metadata is created.
90 91 92 |
# File 'lib/mongo/server/app_metadata.rb', line 90 def purpose @purpose end |
#server_api ⇒ Hash | nil (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 The requested server API version.
This hash can have the following items:
-
:version – string
-
:strict – boolean
-
:deprecation_errors – boolean.
102 103 104 |
# File 'lib/mongo/server/app_metadata.rb', line 102 def server_api @server_api end |
#wrapping_libraries ⇒ Array<Hash> | nil (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 Information about libraries wrapping the driver.
106 107 108 |
# File 'lib/mongo/server/app_metadata.rb', line 106 def wrapping_libraries @wrapping_libraries end |
Instance Method Details
#client_document ⇒ 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.
Get BSON::Document to be used as value for ‘client` key in handshake document.
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/mongo/server/app_metadata.rb', line 126 def client_document @client_document ||= BSON::Document.new.tap do |doc| doc[:application] = { name: @app_name } if @app_name doc[:driver] = driver_doc doc[:os] = os_doc doc[:platform] = platform_string doc[:backpressure] = true env_doc.tap { |env| doc[:env] = env if env } end end |
#validated_document ⇒ 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.
Get the metadata as BSON::Document to be sent to as part of the handshake. The document should be appended to a suitable handshake command.
This method ensures that the metadata are valid.
117 118 119 120 |
# File 'lib/mongo/server/app_metadata.rb', line 117 def validated_document validate! document end |