Method: Mongo::Server::AppMetadata#initialize

Defined in:
lib/mongo/server/app_metadata.rb

#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.

Examples:

Instantiate the app metadata.

Mongo::Server::.new(options)

Parameters:

  • options (Hash) (defaults to: {})

    Metadata options.

Options Hash (options):

  • :app_name (String, Symbol)

    Application name that is printed to the mongod logs upon establishing a connection in server versions >= 3.4.

  • :auth_mech (Symbol)

    The authentication mechanism to use. One of :mongodb_cr, :mongodb_x509, :plain, :scram, :scram256

  • :auth_source (String)

    The source to authenticate from.

  • :compressors (Array<String>)

    A list of potential compressors to use, in order of preference. The driver chooses the first compressor that is also supported by the server. Currently the driver only supports ‘zstd’, ‘snappy’ and ‘zlib’.

  • :platform (String)

    Platform information to include in the metadata printed to the mongod logs upon establishing a connection in server versions >= 3.4.

  • :purpose (Symbol)

    The purpose of this connection.

  • :server_api (Hash)

    The requested server API version. This hash can have the following items:

    • :version – string

    • :strict – boolean

    • :deprecation_errors – boolean

  • :user (String)

    The user name.

  • :wrapping_libraries (Array<Hash>)

    Information about libraries such as ODMs that are wrapping the driver. Specify the lower level libraries first. Allowed hash keys: :name, :version, :platform.

Since:

  • 2.4.0



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/mongo/server/app_metadata.rb', line 74

def initialize(options = {})
  @app_name = options[:app_name].to_s if options[:app_name]
  @platform = options[:platform]

  @purpose = check_purpose!(options[:purpose])

  @compressors = options[:compressors] || []
  @wrapping_libraries = options[:wrapping_libraries]
  @server_api = options[:server_api]

  return unless options[:user] && !options[:auth_mech]

  auth_db = options[:auth_source] || 'admin'
  @request_auth_mech = "#{auth_db}.#{options[:user]}"
end