MongoConnectionString

public struct MongoConnectionString : Codable, LosslessStringConvertible

Represents a MongoDB connection string.

  • Represents a connection string scheme.

    See more

    Declaration

    Swift

    public struct Scheme : LosslessStringConvertible, Equatable
  • A struct representing a host identifier, consisting of a host and an optional port. In standard connection strings, this describes the address of a mongod or mongos to connect to. In mongodb+srv connection strings, this describes a DNS name to be queried for SRV and TXT records.

    See more

    Declaration

    Swift

    public struct HostIdentifier : Equatable, CustomStringConvertible
  • Parses a new MongoConnectionString instance from the provided string.

    Throws

    Declaration

    Swift

    public init(string input: String) throws
  • Updates this MongoConnectionString to incorporate options specified in the provided MongoClientOptions. If the same option is specified in both, the option in the MongoClientOptions takes precedence.

    Throws

    Declaration

    Swift

    public mutating func applyOptions(_ options: MongoClientOptions) throws
  • Codable conformance

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws
  • Declaration

    Swift

    public init(from decoder: Decoder) throws
  • LosslessStringConvertible protocol requirements

    Declaration

    Swift

    public init?(_ description: String)
  • Declaration

    Swift

    public var description: String { get }
  • Specifies the format this connection string is in.

    Declaration

    Swift

    public var scheme: Scheme
  • Specifies one or more host/ports to connect to.

    Declaration

    Swift

    public var hosts: [HostIdentifier]
  • The default database to use for authentication if an authSource is unspecified in the connection string. Defaults to “admin” if unspecified.

    Declaration

    Swift

    public var defaultAuthDB: String?
  • Specifies a custom app name. This value is used in MongoDB logs and profiling data.

    Declaration

    Swift

    public var appName: String?
  • Specifies one or more compressors to use for network compression for communication between this client and mongod/mongos instances. Currently, the driver only supports compression via zlib.

    Declaration

    Swift

    public var compressors: [Compressor]?
  • Specifies the maximum time, in milliseconds, for an individual connection to establish a TCP connection to a MongoDB server before timing out.

    Declaration

    Swift

    public var connectTimeoutMS: Int?
  • Specifies the authentication credentials.

    Declaration

    Swift

    public var credential: MongoCredential?
  • Specifies whether the client should connect directly to a single host. When false, the client will attempt to automatically discover all replica set members if a replica set name is provided. Defaults to false. It is an error to set this option to true when used with a mongodb+srv connection string or when multiple hosts are specified in the connection string.

    Declaration

    Swift

    public var directConnection: Bool?
  • Specifies how often the driver checks the state of the MongoDB deployment. Specifies the interval (in milliseconds) between checks, counted from the end of the previous check until the beginning of the next one. Defaults to 10 seconds (10,000 ms). Must be at least 500ms.

    Declaration

    Swift

    public var heartbeatFrequencyMS: Int?
  • Specifies whether the driver is connecting to a load balancer.

    Declaration

    Swift

    public var loadBalanced: Bool?
  • The size (in milliseconds) of the permitted latency window beyond the fastest round-trip time amongst all servers. By default, only servers within 15ms of the fastest round-trip time receive queries.

    Declaration

    Swift

    public var localThresholdMS: Int?
  • The maximum number of connections that may be associated with a connection pool created by this client at a given time. This includes in-use and available connections. Defaults to 100.

    Declaration

    Swift

    public var maxPoolSize: Int?
  • Specifies a ReadConcern to use for the client.

    Declaration

    Swift

    public var readConcern: ReadConcern?
  • Specifies a ReadPreference to use for the client.

    Declaration

    Swift

    public var readPreference: ReadPreference?
  • Specifies the name of the replica set the driver should connect to.

    Declaration

    Swift

    public var replicaSet: String?
  • Specifies whether the client should retry supported read operations (on by default).

    Declaration

    Swift

    public var retryReads: Bool?
  • Specifies whether the client should retry supported write operations (on by default).

    Declaration

    Swift

    public var retryWrites: Bool?
  • Specifies how long the driver should attempt to select a server for before throwing an error. Defaults to 30 seconds (30000 ms).

    Declaration

    Swift

    public var serverSelectionTimeoutMS: Int?
  • Specifies how long the driver to attempt to send or receive on a socket before timing out.

    Note

    This option only applies to application operations, not server monitoring checks.

    Declaration

    Swift

    public var socketTimeoutMS: Int?
  • Specifies the maximum number of SRV results to select randomly when initially populating the seedlist, or, during SRV polling, adding new hosts to the topology.

    Declaration

    Swift

    public var srvMaxHosts: Int?
  • Specifies the service name to use for SRV lookup during initial DNS seedlist discovery and SRV polling.

    Declaration

    Swift

    public var srvServiceName: String?
  • tls

    Specifies whether or not to require TLS for connections to the server. By default this is set to false.

    Note

    Specifying any other “tls”-prefixed option will require TLS for connections to the server.

    Declaration

    Swift

    public var tls: Bool?
  • Specifies whether to bypass validation of the certificate presented by the mongod/mongos instance. By default this is set to false.

    Declaration

    Swift

    public var tlsAllowInvalidCertificates: Bool?
  • Specifies whether to disable hostname validation for the certificate presented by the mongod/mongos instance. By default this is set to false.

    Declaration

    Swift

    public var tlsAllowInvalidHostnames: Bool?
  • Specifies the location of a local .pem file that contains the root certificate chain from the Certificate Authority. This file is used to validate the certificate presented by the mongod/mongos instance.

    Declaration

    Swift

    public var tlsCAFile: URL?
  • Specifies the location of a local .pem file that contains either the client’s TLS certificate or the client’s TLS certificate and key. The client presents this file to the mongod/mongos instance.

    Declaration

    Swift

    public var tlsCertificateKeyFile: URL?
  • Specifies the password to de-crypt the tlsCertificateKeyFile.

    Declaration

    Swift

    public var tlsCertificateKeyFilePassword: String?
  • Specifies whether revocation checking (CRL / OCSP) should be disabled. On macOS, this setting has no effect. By default this is set to false. It is an error to specify both this option and tlsDisableOCSPEndpointCheck.

    Declaration

    Swift

    public var tlsDisableCertificateRevocationCheck: Bool?
  • Specifies whether OCSP responder endpoints should not be requested when an OCSP response is not stapled. On macOS, this setting has no effect. By default this is set to false.

    Declaration

    Swift

    public var tlsDisableOCSPEndpointCheck: Bool?
  • Specifies whether TLS constraints will be relaxed as much as possible. Currently, setting this option to true is equivalent to setting tlsAllowInvalidCertificates, tlsAllowInvalidHostnames, and tlsDisableCertificateRevocationCheck to true. It is an error to specify both this option and any of the options enabled by it.

    Declaration

    Swift

    public var tlsInsecure: Bool?
  • Specifies a WriteConcern to use for the client.

    Declaration

    Swift

    public var writeConcern: WriteConcern?