Class: Mongo::Server::AppMetadata Private
- Inherits:
-
Object
- Object
- Mongo::Server::AppMetadata
- Extended by:
- Forwardable
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/server/app_metadata.rb,
build/ruby-driver-v2.19/lib/mongo/server/app_metadata/platform.rb,
build/ruby-driver-v2.19/lib/mongo/server/app_metadata/truncator.rb,
build/ruby-driver-v2.19/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.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/app_metadata.rb', line 74 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.
96 97 98 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/app_metadata.rb', line 96 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.
92 93 94 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/app_metadata.rb', line 92 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.
Thes hash can have the following items:
-
:version – string
-
:strict – boolean
-
:deprecation_errors – boolean.
104 105 106 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/app_metadata.rb', line 104 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.
108 109 110 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/app_metadata.rb', line 108 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.
128 129 130 131 132 133 134 135 136 137 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/app_metadata.rb', line 128 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 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.
119 120 121 122 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/app_metadata.rb', line 119 def validated_document validate! document end |