MongoClientOptions
public struct MongoClientOptions : CodingStrategyProvider
Options to use when creating a MongoClient
.
-
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 authentication options for use with the client.
Declaration
Swift
public var credential: MongoCredential?
-
Specifies the
DataCodingStrategy
to use for BSON encoding/decoding operations performed by this client and any databases or collections that derive from it.Declaration
Swift
public var dataCodingStrategy: DataCodingStrategy?
-
Specifies the
DateCodingStrategy
to use for BSON encoding/decoding operations performed by this client and any databases or collections that derive from it.Declaration
Swift
public var dateCodingStrategy: DateCodingStrategy?
-
When true, the client will 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?
-
Controls 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?
-
Indicates 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?
-
Determines whether the client should retry supported read operations (on by default).
Declaration
Swift
public var retryReads: Bool?
-
Determines whether the client should retry supported write operations (on by default).
Declaration
Swift
public var retryWrites: Bool?
-
Specifies a MongoDB server API version and related options.
Declaration
Swift
public var serverAPI: MongoServerAPI?
-
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?
-
MongoSwift.MongoClient
provides an asynchronous API by running all blocking operations off of their originating threads in a thread pool.MongoSwiftSync.MongoClient
is implemented as a wrapper of the async client which waits for each corresponding asynchronous operation to complete and then returns the result. This option specifies the size of the thread pool used by the asynchronous client, and determines the max number of concurrent operations that may be performed using a single client. Defaults to 5.Declaration
Swift
public var threadPoolSize: Int?
-
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?
-
Indicates 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?
-
Indicates 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?
-
Indicates if 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
, either via this options struct, connection string, or a combination of both.Declaration
Swift
public var tlsDisableCertificateRevocationCheck: Bool?
-
Indicates if 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?
-
When specified, TLS constraints will be relaxed as much as possible. Currently, setting this option to
true
is equivalent to settingtlsAllowInvalidCertificates
,tlsAllowInvalidHostnames
, andtlsDisableCertificateRevocationCheck
totrue
. It is an error to specify both this option and any of the options enabled by it, either via this options struct, connection string, or a combination of both.Declaration
Swift
public var tlsInsecure: Bool?
-
Specifies the
UUIDCodingStrategy
to use for BSON encoding/decoding operations performed by this client and any databases or collections that derive from it.Declaration
Swift
public var uuidCodingStrategy: UUIDCodingStrategy?
-
Specifies a WriteConcern to use for the client.
Declaration
Swift
public var writeConcern: WriteConcern?
-
init(appName:
compressors: connectTimeoutMS: credential: dataCodingStrategy: dateCodingStrategy: directConnection: heartbeatFrequencyMS: loadBalanced: localThresholdMS: maxPoolSize: readConcern: readPreference: replicaSet: retryReads: retryWrites: serverAPI: serverSelectionTimeoutMS: threadPoolSize: tls: tlsAllowInvalidCertificates: tlsAllowInvalidHostnames: tlsCAFile: tlsCertificateKeyFile: tlsCertificateKeyFilePassword: tlsInsecure: uuidCodingStrategy: writeConcern: ) Convenience initializer allowing any/all parameters to be omitted or optional.
Declaration
Swift
public init( appName: String? = nil, compressors: [Compressor]? = nil, connectTimeoutMS: Int? = nil, credential: MongoCredential? = nil, dataCodingStrategy: DataCodingStrategy? = nil, dateCodingStrategy: DateCodingStrategy? = nil, directConnection: Bool? = nil, heartbeatFrequencyMS: Int? = nil, loadBalanced: Bool? = nil, localThresholdMS: Int? = nil, maxPoolSize: Int? = nil, readConcern: ReadConcern? = nil, readPreference: ReadPreference? = nil, replicaSet: String? = nil, retryReads: Bool? = nil, retryWrites: Bool? = nil, serverAPI: MongoServerAPI? = nil, serverSelectionTimeoutMS: Int? = nil, threadPoolSize: Int? = nil, tls: Bool? = nil, tlsAllowInvalidCertificates: Bool? = nil, tlsAllowInvalidHostnames: Bool? = nil, tlsCAFile: URL? = nil, tlsCertificateKeyFile: URL? = nil, tlsCertificateKeyFilePassword: String? = nil, tlsInsecure: Bool? = nil, uuidCodingStrategy: UUIDCodingStrategy? = nil, writeConcern: WriteConcern? = nil )