FreeBSD Manual Pages
MONGOC_URI_T(3) libmongoc MONGOC_URI_T(3) SYNOPSIS typedef struct _mongoc_uri_t mongoc_uri_t; DESCRIPTION mongoc_uri_t provides an abstraction on top of the MongoDB connection URI format. It provides standardized parsing as well as convenience methods for extracting useful information such as replica hosts or au- thorization information. See Connection String URI Reference on the MongoDB website for more in- formation. FORMAT mongodb[+srv]:// <1> [username:password@] <2> host1 <3> [:port1] <4> [,host2[:port2],...[,hostN[:portN]]] <5> [/[database] <6> [?options]] <7> 1. "mongodb" is the specifier of the MongoDB protocol. Use "mon- godb+srv" with a single service name in place of "host1" to specify the initial list of servers with an SRV record. 2. An optional username and password. 3. The only required part of the uri. This specifies either a host- name, IPv4 address, IPv6 address enclosed in "[" and "]", or UNIX domain socket. 4. An optional port number. Defaults to :27017. 5. Extra optional hosts and ports. You would specify multiple hosts, for example, for connections to replica sets. 6. The name of the database to authenticate if the connection string includes authentication credentials. If /database is not specified and the connection string includes credentials, defaults to the 'ad- min' database. 7. Connection specific options. NOTE: Option names are case-insensitive. Do not repeat the same option (e.g. "mongodb://localhost/db?opt=value1&OPT=value2") since this may have unexpected results. The MongoDB C Driver exposes constants for each supported connection option. These constants make it easier to discover connection options, but their string values can be used as well. For example, the following calls are equal. uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_APPNAME "=applicationName"); uri = mongoc_uri_new ("mongodb://localhost/?appname=applicationName"); uri = mongoc_uri_new ("mongodb://localhost/?appName=applicationName"); REPLICA SET EXAMPLE To describe a connection to a replica set named 'test' with the follow- ing mongod hosts: • db1.example.com on port 27017 • db2.example.com on port 2500 You would use a connection string that resembles the following. mongodb://db1.example.com,db2.example.com:2500/?replicaSet=test SRV EXAMPLE If you have configured an SRV record with a name like "_mon- godb._tcp.server.example.com" whose records are a list of one or more MongoDB server hostnames, use a connection string like this: uri = mongoc_uri_new ("mongodb+srv://server.example.com/?replicaSet=rs&appName=applicationName"); The driver prefixes the service name with "_mongodb._tcp.", then per- forms a DNS SRV query to resolve the service name to one or more host- names. If this query succeeds, the driver performs a DNS TXT query on the service name (without the "_mongodb._tcp" prefix) for additional URI options configured as TXT records. On Unix, the MongoDB C Driver relies on libresolv to look up SRV and TXT records. If libresolv is unavailable, then using a "mongodb+srv" URI will cause an error. If your libresolv lacks res_nsearch then the driver will fall back to res_search, which is not thread-safe. Set the environment variable MONGOC_EXPERIMENTAL_SRV_PREFER_TCP to pre- fer TCP for the initial queries. The environment variable is ignored for res_search. Large DNS responses over UDP may be truncated due to UDP size limitations. DNS resolvers are expected to retry over TCP if the UDP response indicates truncation. Some observed DNS environments do not set the truncation flag (TC), preventing the TCP retry. This en- vironment variable is currently experimental and subject to change. IPV4 AND IPV6 If connecting to a hostname that has both IPv4 and IPv6 DNS records, the behavior follows RFC-6555. A connection to the IPv6 address is at- tempted first. If IPv6 fails, then a connection is attempted to the IPv4 address. If the connection attempt to IPv6 does not complete within 250ms, then IPv4 is tried in parallel. Whichever succeeds con- nection first cancels the other. The successful DNS result is cached for 10 minutes. As a consequence, attempts to connect to a mongod only listening on IPv4 may be delayed if there are both A (IPv4) and AAAA (IPv6) DNS records associated with the host. To avoid a delay, configure hostnames to match the MongoDB configura- tion. That is, only create an A record if the mongod is only listening on IPv4. CONNECTION OPTIONS +--------------------+------------------+------------------+-------------------------------------+ | Constant | Key | Default | Description | +--------------------+------------------+------------------+-------------------------------------+ | MON- | retryreads | true | If "true" and | | GOC_URI_RETRYREADS | | | the server is a | | | | | MongoDB 3.6+ | | | | | standalone, | | | | | replica set, or | | | | | sharded cluster, | | | | | the driver | | | | | safely retries a | | | | | read that failed | | | | | due to a network | | | | | error or replica | | | | | set failover. | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_RETRY- | retrywrites | true if driver | If "true" and | | WRITES | | built w/ TLS | the server is a | | | | | MongoDB 3.6+ | | | | | replica set or | | | | | sharded cluster, | | | | | the driver | | | | | safely retries a | | | | | write that | | | | | failed due to a | | | | | network error or | | | | | replica set | | | | | failover. Only | | | | | inserts, updates | | | | | of single docu- | | | | | ments, or | | | | | deletes of sin- | | | | | gle documents | | | | | are retried. | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_APPNAME | appname | Empty (no app- | The client ap- | | | | name) | plication name. | | | | | This value is | | | | | used by MongoDB | | | | | when it logs | | | | | connection in- | | | | | formation and | | | | | profile informa- | | | | | tion, such as | | | | | slow queries. | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_TLS | tls | Empty (not set, | {true|false}, | | | | same as false) | indicating if | | | | | TLS must be | | | | | used. (See also | | | | | mongoc_client_set_ssl_opts() | | | | | and | | | | | mongoc_client_pool_set_ssl_opts().) | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_COM- | compressors | Empty (no com- | Comma separated list of compres- | | PRESSORS | | pressors) | sors, if any, to use to compress | | | | | the wire protocol messages. Snappy, | | | | | zlib, and zstd are optional build | | | | | time dependencies, and enable the | | | | | "snappy", "zlib", and "zstd" values | | | | | respectively. | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_CON- | connecttimeoutms | 10,000 ms (10 | This setting applies to new server | | NECTTIMEOUTMS | | seconds) | connections. It is also used as the | | | | | socket timeout for server discovery | | | | | and monitoring operations. | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_SOCKET- | sockettimeoutms | 300,000 ms (5 | The time in milliseconds to attempt | | TIMEOUTMS | | minutes) | to send or receive on a socket be- | | | | | fore the attempt times out. | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_REPLI- | replicaset | Empty (no repli- | The name of the Replica Set that | | CASET | | caset) | the driver should connect to. | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_ZLIB- | zlibcompression- | -1 | When the MONGOC_URI_COMPRESSORS in- | | COMPRESSIONLEVEL | level | | cludes "zlib" this options config- | | | | | ures the zlib compression level, | | | | | when the zlib compressor is used to | | | | | compress client data. | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_LOAD- | loadbalanced | false | If true, this indicates the driver | | BALANCED | | | is connecting to a MongoDB cluster | | | | | behind a load balancer. | +--------------------+------------------+------------------+-------------------------------------+ | MONGOC_URI_SRVMAX- | srvmaxhosts | 0 | If zero, the number of hosts in DNS | | HOSTS | | | results is unlimited. If greater | | | | | than zero, the number of hosts in | | | | | DNS results is limited to being | | | | | less than or equal to the given | | | | | value. | +--------------------+------------------+------------------+-------------------------------------+ WARNING: Setting any of the *timeoutMS options above to either 0 or a nega- tive value is discouraged due to unspecified and inconsistent behav- ior. The "default value" historically specified as a fallback for 0 or a negative value is NOT related to the default values for the *timeoutMS options documented above. The meaning of a timeout of 0 or a negative value may vary depending on the operation being exe- cuted, even when specified by the same URI option. To specify the documented default value for a *timeoutMS option, use the MONGOC_DE- FAULT_* constants defined in mongoc-client.h instead. AUTHENTICATION OPTIONS +---------------------+--------------------+---------------------+ | Constant | Key | Description | +---------------------+--------------------+---------------------+ | MONGOC_URI_AUTH- | authmechanism | Specifies the mech- | | MECHANISM | | anism to use when | | | | authenticating as | | | | the provided user. | | | | See Authentication | | | | for supported val- | | | | ues. | +---------------------+--------------------+---------------------+ | MONGOC_URI_AUTH- | authmechanismprop- | Certain authentica- | | MECHANISMPROPERTIES | erties | tion mechanisms | | | | have additional op- | | | | tions that can be | | | | configured. These | | | | options should be | | | | provided as comma | | | | separated op- | | | | tion_key:op- | | | | tion_value pair and | | | | provided as auth- | | | | MechanismProper- | | | | ties. Specifying | | | | the same option_key | | | | multiple times has | | | | undefined behavior. | +---------------------+--------------------+---------------------+ | MONGOC_URI_AUTH- | authsource | The authSource de- | | SOURCE | | fines the database | | | | that should be used | | | | to authenticate to. | | | | It is unnecessary | | | | to provide this op- | | | | tion the database | | | | name is the same as | | | | the database used | | | | in the URI. | +---------------------+--------------------+---------------------+ Mechanism Properties +---------------------+-------------------+---------------------+ | Constant | Key | Description | +---------------------+-------------------+---------------------+ | MONGOC_URI_CANONI- | canonicalizehost- | Use the canonical | | CALIZEHOSTNAME | name | hostname of the | | | | service, rather | | | | than its configured | | | | alias, when authen- | | | | ticating with | | | | Cyrus-SASL Ker- | | | | beros. | +---------------------+-------------------+---------------------+ | MONGOC_URI_GSSAPIS- | gssapiservicename | Use alternative | | ERVICENAME | | service name. The | | | | default is mongodb. | +---------------------+-------------------+---------------------+ TLS OPTIONS +---------------------+---------------------+---------------------+ | Constant | Key | Description | +---------------------+---------------------+---------------------+ | MONGOC_URI_TLS | tls | {true|false}, indi- | | | | cating if TLS must | | | | be used. | +---------------------+---------------------+---------------------+ | MONGOC_URI_TLSCER- | tlscertificatekey- | Path to PEM format- | | TIFICATEKEYFILE | file | ted Private Key, | | | | with its Public | | | | Certificate con- | | | | catenated at the | | | | end. | +---------------------+---------------------+---------------------+ | MONGOC_URI_TLSCER- | tlscertificatekey- | The password, if | | TIFICATEKEY- | password | any, to use to un- | | FILEPASSWORD | | lock encrypted Pri- | | | | vate Key. | +---------------------+---------------------+---------------------+ | MON- | tlscafile | One, or a bundle | | GOC_URI_TLSCAFILE | | of, Certificate Au- | | | | thorities whom | | | | should be consid- | | | | ered to be trusted. | +---------------------+---------------------+---------------------+ | MONGOC_URI_TLSAL- | tlsallowinvalidcer- | Accept and ignore | | LOWINVALIDCERTIFI- | tificates | certificate verifi- | | CATES | | cation errors (e.g. | | | | untrusted issuer, | | | | expired, etc.) | +---------------------+---------------------+---------------------+ | MONGOC_URI_TLSAL- | tlsallowinvalid- | Ignore hostname | | LOWINVALIDHOSTNAMES | hostnames | verification of the | | | | certificate (e.g. | | | | Man In The Middle, | | | | using valid cer- | | | | tificate, but is- | | | | sued for another | | | | hostname) | +---------------------+---------------------+---------------------+ | MONGOC_URI_TLSINSE- | tlsinsecure | {true|false}, indi- | | CURE | | cating if insecure | | | | TLS options should | | | | be used. Currently | | | | this implies MON- | | | | GOC_URI_TLSALLOWIN- | | | | VALIDCERTIFICATES | | | | and MONGOC_URI_TL- | | | | SALLOWINVALIDHOST- | | | | NAMES. | +---------------------+---------------------+---------------------+ | MONGOC_URI_TLSDIS- | tlsdisablecertifi- | {true|false}, indi- | | ABLECERTIFICATERE- | caterevocationcheck | cates if revocation | | VOCATIONCHECK | | checking (CRL / | | | | OCSP) should be | | | | disabled. | +---------------------+---------------------+---------------------+ | MONGOC_URI_TLSDIS- | tlsdisableocspend- | {true|false}, indi- | | ABLEOCSPEND- | pointcheck | cates if OCSP re- | | POINTCHECK | | sponder endpoints | | | | should not be re- | | | | quested when an | | | | OCSP response is | | | | not stapled. | +---------------------+---------------------+---------------------+ See Configuring TLS for details about these options and about building libmongoc with TLS support. DEPRECATED SSL OPTIONS The following options have been deprecated and may be removed from fu- ture releases of libmongoc. +-----------------------+------------------+-------------------+------------------+ | Constant | Key | Deprecated For | Key | +-----------------------+------------------+-------------------+------------------+ | MONGOC_URI_SSL | ssl | MONGOC_URI_TLS | tls | +-----------------------+------------------+-------------------+------------------+ | MON- | sslclientcer- | MON- | tlscertifi- | | GOC_URI_SSLCLIENTCER- | tificatekeyfile | GOC_URI_TLSCER- | catekeyfile | | TIFICATEKEYFILE | | TIFICATEKEYFILE | | +-----------------------+------------------+-------------------+------------------+ | MON- | sslclientcer- | MON- | tlscertifi- | | GOC_URI_SSLCLIENTCER- | tificatekeypass- | GOC_URI_TLSCER- | catekeypassword | | TIFICATEKEYPASSWORD | word | TIFICATEKEY- | | | | | FILEPASSWORD | | +-----------------------+------------------+-------------------+------------------+ | MONGOC_URI_SSLCER- | sslcertifi- | MON- | tlscafile | | TIFICATEAUTHORITYFILE | cateauthority- | GOC_URI_TLSCAFILE | | | | file | | | +-----------------------+------------------+-------------------+------------------+ | MONGOC_URI_SSLALLOW- | sslallowinvalid- | MONGOC_URI_TLSAL- | tlsallowinvalid- | | INVALIDCERTIFICATES | certificates | LOWINVALIDCER- | certificates | | | | TIFICATES | | +-----------------------+------------------+-------------------+------------------+ | MONGOC_URI_SSLALLOW- | sslallowinvalid- | MONGOC_URI_TLSAL- | tlsallowinvalid- | | INVALIDHOSTNAMES | hostnames | LOWINVALIDHOST- | hostnames | | | | NAMES | | +-----------------------+------------------+-------------------+------------------+ SERVER DISCOVERY, MONITORING, AND SELECTION OPTIONS Clients in a mongoc_client_pool_t share a topology scanner that runs on a background thread. The thread wakes every heartbeatFrequencyMS (de- fault 10 seconds) to scan all MongoDB servers in parallel. Whenever an application operation requires a server that is not known--for example, if there is no known primary and your application attempts an in- sert--the thread rescans all servers every half-second. In this situa- tion the pooled client waits up to serverSelectionTimeoutMS (default 30 seconds) for the thread to find a server suitable for the operation, then returns an error with domain MONGOC_ERROR_SERVER_SELECTION. Technically, the total time an operation may wait while a pooled client scans the topology is controlled both by serverSelectionTimeoutMS and connectTimeoutMS. The longest wait occurs if the last scan begins just at the end of the selection timeout, and a slow or down server requires the full connection timeout before the client gives up. A non-pooled client is single-threaded. Every heartbeatFrequencyMS, it blocks the next application operation while it does a parallel scan. This scan takes as long as needed to check the slowest server: roughly connectTimeoutMS. Therefore the default heartbeatFrequencyMS for sin- gle-threaded clients is greater than for pooled clients: 60 seconds. By default, single-threaded (non-pooled) clients scan only once when an operation requires a server that is not known. If you attempt an insert and there is no known primary, the client checks all servers once try- ing to find it, then succeeds or returns an error with domain MON- GOC_ERROR_SERVER_SELECTION. But if you set serverSelectionTryOnce to "false", the single-threaded client loops, checking all servers every half-second, until serverSelectionTimeoutMS. The total time an operation may wait for a single-threaded client to scan the topology is determined by connectTimeoutMS in the try-once case, or serverSelectionTimeoutMS and connectTimeoutMS if serverSelec- tionTryOnce is set "false". +---------------------+---------------------+---------------------+ | Constant | Key | Description | +---------------------+---------------------+---------------------+ | MONGOC_URI_HEART- | heartbeatfrequen- | The interval be- | | BEATFREQUENCYMS | cyms | tween server moni- | | | | toring checks. De- | | | | faults to 10,000ms | | | | (10 seconds) in | | | | pooled | | | | (multi-threaded) | | | | mode, 60,000ms (60 | | | | seconds) in | | | | non-pooled mode | | | | (single-threaded). | +---------------------+---------------------+---------------------+ | MONGOC_URI_SERVERS- | serverselection- | A timeout in mil- | | ELECTIONTIMEOUTMS | timeoutms | liseconds to block | | | | for server selec- | | | | tion before throw- | | | | ing an exception. | | | | The default is | | | | 30,0000ms (30 sec- | | | | onds). | +---------------------+---------------------+---------------------+ | MONGOC_URI_SERVERS- | serverselectiontry- | If "true", the dri- | | ELECTIONTRYONCE | once | ver scans the | | | | topology exactly | | | | once after server | | | | selection fails, | | | | then either selects | | | | a server or returns | | | | an error. If it is | | | | false, then the | | | | driver repeatedly | | | | searches for a | | | | suitable server for | | | | up to serverSelec- | | | | tionTimeoutMS mil- | | | | liseconds (pausing | | | | a half second be- | | | | tween attempts). | | | | The default for | | | | serverSelectionTry- | | | | Once is "false" for | | | | pooled clients, | | | | otherwise "true". | | | | Pooled clients ig- | | | | nore serverSelec- | | | | tionTryOnce; they | | | | signal the thread | | | | to rescan the | | | | topology every | | | | half-second until | | | | serverSelection- | | | | TimeoutMS expires. | +---------------------+---------------------+---------------------+ | MONGOC_URI_SOCK- | socketcheckinter- | Only applies to | | ETCHECKINTERVALMS | valms | single threaded | | | | clients. If a | | | | socket has not been | | | | used within this | | | | time, its connec- | | | | tion is checked | | | | with a quick | | | | "hello" call before | | | | it is used again. | | | | Defaults to 5,000ms | | | | (5 seconds). | +---------------------+---------------------+---------------------+ | MONGOC_URI_DIRECT- | directconnection | If "true", the dri- | | CONNECTION | | ver connects to a | | | | single server di- | | | | rectly and will not | | | | monitor additional | | | | servers. If | | | | "false", the driver | | | | connects based on | | | | the presence and | | | | value of the repli- | | | | caSet option. | +---------------------+---------------------+---------------------+ Setting any of the *TimeoutMS options above to 0 will be interpreted as "use the default value". CONNECTION POOL OPTIONS These options govern the behavior of a mongoc_client_pool_t. They are ignored by a non-pooled mongoc_client_t. +---------------------+--------------------+--------------------------+ | Constant | Key | Description | +---------------------+--------------------+--------------------------+ | MONGOC_URI_MAXPOOL- | maxpoolsize | The maximum number | | SIZE | | of clients created | | | | by a | | | | mongoc_client_pool_t | | | | total (both in the | | | | pool and checked | | | | out). The default | | | | value is 100. Once | | | | it is reached, | | | | mongoc_client_pool_pop() | | | | blocks until an- | | | | other thread pushes | | | | a client. | +---------------------+--------------------+--------------------------+ | MONGOC_URI_MINPOOL- | minpoolsize | Deprecated. This op- | | SIZE | | tion's behavior does not | | | | match its name, and its | | | | actual behavior will | | | | likely hurt performance. | +---------------------+--------------------+--------------------------+ | MONGOC_URI_MAXIDLE- | maxidletimems | Not implemented. | | TIMEMS | | | +---------------------+--------------------+--------------------------+ | MONGOC_URI_WAIT- | waitqueuemultiple | Not implemented. | | QUEUEMULTIPLE | | | +---------------------+--------------------+--------------------------+ | MONGOC_URI_WAIT- | waitqueuetimeoutms | The maximum time to wait | | QUEUETIMEOUTMS | | for a client to become | | | | available from the pool. | +---------------------+--------------------+--------------------------+ WRITE CONCERN OPTIONS +--------------------+------------+---------------------+ | Constant | Key | Description | +--------------------+------------+---------------------+ | MONGOC_URI_W | w | Determines the | | | | write concern | | | | (guarantee). Valid | | | | values: | | | | | | | | • 0 = The | | | | driver | | | | will not | | | | acknowl- | | | | edge write | | | | operations | | | | but will | | | | pass or | | | | handle any | | | | network | | | | and socket | | | | errors | | | | that it | | | | receives | | | | to the | | | | client. If | | | | you dis- | | | | able write | | | | concern | | | | but enable | | | | the get- | | | | LastError | | | | commands w | | | | option, w | | | | overrides | | | | the w op- | | | | tion. | | | | | | | | • 1 = Pro- | | | | vides ba- | | | | sic ac- | | | | knowledge- | | | | ment of | | | | write op- | | | | erations. | | | | By speci- | | | | fying 1, | | | | you re- | | | | quire that | | | | a stand- | | | | alone mon- | | | | god in- | | | | stance, or | | | | the pri- | | | | mary for | | | | replica | | | | sets, ac- | | | | knowledge | | | | all write | | | | opera- | | | | tions. For | | | | drivers | | | | released | | | | after the | | | | default | | | | write con- | | | | cern | | | | change, | | | | this is | | | | the de- | | | | fault | | | | write con- | | | | cern set- | | | | ting. | | | | | | | | • majority = | | | | For | | | | replica | | | | sets, if | | | | you spec- | | | | ify the | | | | special | | | | majority | | | | value to w | | | | option, | | | | write op- | | | | erations | | | | will only | | | | return | | | | success- | | | | fully af- | | | | ter a ma- | | | | jority of | | | | the con- | | | | figured | | | | replica | | | | set mem- | | | | bers have | | | | acknowl- | | | | edged the | | | | write op- | | | | eration. | | | | | | | | • n = For | | | | replica | | | | sets, if | | | | you spec- | | | | ify a num- | | | | ber n | | | | greater | | | | than 1, | | | | operations | | | | with this | | | | write con- | | | | cern re- | | | | turn only | | | | after n | | | | members of | | | | the set | | | | have ac- | | | | knowledged | | | | the write. | | | | If you set | | | | n to a | | | | number | | | | that is | | | | greater | | | | than the | | | | number of | | | | available | | | | set mem- | | | | bers or | | | | members | | | | that hold | | | | data, Mon- | | | | goDB will | | | | wait, po- | | | | tentially | | | | indefi- | | | | nitely, | | | | for these | | | | members to | | | | become | | | | available. | | | | | | | | • tags = For | | | | replica | | | | sets, you | | | | can spec- | | | | ify a tag | | | | set to re- | | | | quire that | | | | all mem- | | | | bers of | | | | the set | | | | that have | | | | these tags | | | | configured | | | | return | | | | confirma- | | | | tion of | | | | the write | | | | operation. | +--------------------+------------+---------------------+ | MONGOC_URI_WTIME- | wtimeoutms | The time in mil- | | OUTMS | | liseconds to wait | | | | for replication to | | | | succeed, as speci- | | | | fied in the w op- | | | | tion, before timing | | | | out. When wtime- | | | | outMS is 0, write | | | | operations will | | | | never time out. | +--------------------+------------+---------------------+ | MONGOC_URI_JOURNAL | journal | Controls whether | | | | write operations | | | | will wait until the | | | | mongod acknowledges | | | | the write opera- | | | | tions and commits | | | | the data to the on | | | | disk journal. | | | | | | | | • true = | | | | Enables | | | | journal | | | | commit ac- | | | | knowledge- | | | | ment write | | | | concern. | | | | Equivalent | | | | to speci- | | | | fying the | | | | getLastEr- | | | | ror com- | | | | mand with | | | | the j op- | | | | tion en- | | | | abled. | | | | | | | | • false = | | | | Does not | | | | require | | | | that mon- | | | | god commit | | | | write op- | | | | erations | | | | to the | | | | journal | | | | before ac- | | | | knowledg- | | | | ing the | | | | write op- | | | | eration. | | | | This is | | | | the de- | | | | fault op- | | | | tion for | | | | the jour- | | | | nal para- | | | | meter. | +--------------------+------------+---------------------+ READ CONCERN OPTIONS +---------------------+------------------+---------------------+ | Constant | Key | Description | +---------------------+------------------+---------------------+ | MONGOC_URI_READCON- | readconcernlevel | The level of isola- | | CERNLEVEL | | tion for read oper- | | | | ations. If the | | | | level is left un- | | | | specified, the | | | | server default will | | | | be used. See | | | | readConcern in the | | | | MongoDB Manual for | | | | details. | +---------------------+------------------+---------------------+ READ PREFERENCE OPTIONS When connected to a replica set, the driver chooses which member to query using the read preference: 1. Choose members whose type matches "readPreference". 2. From these, if there are any tags sets configured, choose members matching the first tag set. If there are none, fall back to the next tag set and so on, until some members are chosen or the tag sets are exhausted. 3. From the chosen servers, distribute queries randomly among the server with the fastest round-trip times. These include the server with the fastest time and any whose round-trip time is no more than "localThresholdMS" slower. +---------------------+---------------------+---------------------+ | Constant | Key | Description | +---------------------+---------------------+---------------------+ | MONGOC_URI_READ- | readpreference | Specifies the | | PREFERENCE | | replica set read | | | | preference for this | | | | connection. This | | | | setting overrides | | | | any secondaryOk | | | | value. The read | | | | preference values | | | | are the following: | | | | | | | | • primary | | | | (default) | | | | | | | | • prima- | | | | ryPre- | | | | ferred | | | | | | | | • secondary | | | | | | | | • sec- | | | | ondaryPre- | | | | ferred | | | | | | | | • nearest | +---------------------+---------------------+---------------------+ | MONGOC_URI_READ- | readpreferencetags | A representation of | | PREFERENCETAGS | | a tag set. See also | | | | Tag Sets. | +---------------------+---------------------+---------------------+ | MONGOC_URI_LO- | localthresholdms | How far to distrib- | | CALTHRESHOLDMS | | ute queries, beyond | | | | the server with the | | | | fastest round-trip | | | | time. By default, | | | | only servers within | | | | 15ms of the fastest | | | | round-trip time re- | | | | ceive queries. | +---------------------+---------------------+---------------------+ | MONGOC_URI_MAXSTAL- | maxstalenessseconds | The maximum repli- | | ENESSSECONDS | | cation lag, in wall | | | | clock time, that a | | | | secondary can suf- | | | | fer and still be | | | | eligible. The | | | | smallest allowed | | | | value for maxStale- | | | | nessSeconds is 90 | | | | seconds. | +---------------------+---------------------+---------------------+ NOTE: When connecting to more than one mongos, libmongoc's localThresh- oldMS applies only to the selection of mongos servers. The threshold for selecting among replica set members in shards is controlled by the mongos's localThreshold command line option. LEGACY OPTIONS For historical reasons, the following options are available. They should however not be used. +-----------------+------+---------------------+ | Constant | Key | Description | +-----------------+------+---------------------+ | MONGOC_URI_SAFE | safe | {true|false} Same | | | | as w={1|0} | +-----------------+------+---------------------+ AUTHOR MongoDB, Inc COPYRIGHT 2009-present, MongoDB, Inc. 1.30.2 Apr 12, 2025 MONGOC_URI_T(3)
SYNOPSIS | DESCRIPTION | FORMAT | REPLICA SET EXAMPLE | SRV EXAMPLE | IPV4 AND IPV6 | CONNECTION OPTIONS | AUTHENTICATION OPTIONS | TLS OPTIONS | DEPRECATED SSL OPTIONS | SERVER DISCOVERY, MONITORING, AND SELECTION OPTIONS | CONNECTION POOL OPTIONS | WRITE CONCERN OPTIONS | READ CONCERN OPTIONS | READ PREFERENCE OPTIONS | LEGACY OPTIONS | AUTHOR | COPYRIGHT
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=mongoc_uri_t&sektion=3&manpath=FreeBSD+Ports+14.3.quarterly>
