Class: Mongo::Server::AppMetadata Private
- Inherits:
-
Object
- Object
- Mongo::Server::AppMetadata
- Extended by:
- Forwardable
- Defined in:
- build/ruby-driver-v2.17/lib/mongo/server/app_metadata.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
Constant Summary collapse
- MAX_DOCUMENT_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 metadata document byte size.
512.freeze
- 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.freeze
- 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.
[: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
-
#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
-
#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.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'build/ruby-driver-v2.17/lib/mongo/server/app_metadata.rb', line 88 def initialize( = {}) @app_name = [:app_name].to_s if [:app_name] @platform = [:platform] if @purpose = [:purpose] unless PURPOSES.include?(@purpose) raise ArgumentError, "Invalid purpose: #{@purpose}" end end @compressors = [:compressors] || [] @wrapping_libraries = [:wrapping_libraries] @server_api = [:server_api] if [:user] && ![:auth_mech] auth_db = [:auth_source] || 'admin' @request_auth_mech = "#{auth_db}.#{[:user]}" end end |
Instance Attribute Details
#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.
110 111 112 |
# File 'build/ruby-driver-v2.17/lib/mongo/server/app_metadata.rb', line 110 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.
120 121 122 |
# File 'build/ruby-driver-v2.17/lib/mongo/server/app_metadata.rb', line 120 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.
124 125 126 |
# File 'build/ruby-driver-v2.17/lib/mongo/server/app_metadata.rb', line 124 def wrapping_libraries @wrapping_libraries end |
Instance Method Details
#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.
137 138 139 140 |
# File 'build/ruby-driver-v2.17/lib/mongo/server/app_metadata.rb', line 137 def validated_document validate! document end |