Skip to content

Commit bcdc484

Browse files
committed
CDRIVER-3396 add 64-bit support for wTimeoutMS
1 parent 622b3c8 commit bcdc484

10 files changed

+527
-29
lines changed

src/libmongoc/doc/mongoc_uri_get_option_as_int32.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Synopsis
88

99
.. code-block:: c
1010
11-
int32
11+
int32_t
1212
mongoc_uri_get_option_as_int32 (const mongoc_uri_t *uri,
1313
const char *option,
14-
int32 fallback);
14+
int32_t fallback);
1515
1616
Parameters
1717
----------
@@ -23,7 +23,7 @@ Parameters
2323
Description
2424
-----------
2525

26-
Returns the value of the URI option if it is set and of the correct type (int32). Returns ``fallback`` if the option is not set, set to an invalid type, or zero.
26+
Returns the value of the URI option if it is set and of the correct type (integer). Returns ``fallback`` if the option is not set, set to an invalid type, or zero.
2727

2828
Zero is considered "unset", so URIs can be constructed like so, and still accept default values:
2929

@@ -33,3 +33,9 @@ Zero is considered "unset", so URIs can be constructed like so, and still accept
3333
3434
If ``myvalue`` is non-zero it is the connection timeout; if it is zero the driver uses the default timeout.
3535

36+
When reading an option that is an int64, this function will return the value as ``int32_t``. If the value is outside the range of a 32-bit integer, a warning will be emitted and ``fallback`` is returned instead.
37+
38+
See Also
39+
--------
40+
41+
* :symbol:`mongoc_uri_get_option_as_int64()`
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
:man_page: mongoc_uri_get_option_as_int64
2+
3+
mongoc_uri_get_option_as_int64()
4+
================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
int64_t
12+
mongoc_uri_get_option_as_int64 (const mongoc_uri_t *uri,
13+
const char *option,
14+
int64_t fallback);
15+
16+
Parameters
17+
----------
18+
19+
* ``uri``: A :symbol:`mongoc_uri_t`.
20+
* ``option``: The name of an option, case insensitive.
21+
* ``fallback``: A default value to return.
22+
23+
Description
24+
-----------
25+
26+
Returns the value of the URI option if it is set and of the correct type (integer). Returns ``fallback`` if the option is not set, set to an invalid type, or zero.
27+
28+
Zero is considered "unset", so URIs can be constructed like so, and still accept default values:
29+
30+
.. code-block:: c
31+
32+
bson_strdup_printf ("mongodb://localhost/?wTimeoutMS=%" PRId64, myvalue)
33+
34+
If ``myvalue`` is non-zero it is the write concern timeout; if it is zero the driver uses the default timeout.
35+
36+
See Also
37+
--------
38+
39+
* :symbol:`mongoc_uri_get_option_as_int32()`

src/libmongoc/doc/mongoc_uri_option_is_int32.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ Parameters
1919
Description
2020
-----------
2121

22-
Returns true if the option is a known MongoDB URI option of integer type. For example, "socketTimeoutMS=100" is a valid MongoDB URI option, so ``mongoc_uri_option_is_int32 ("connectTimeoutMS")`` is true.
22+
Returns true if the option is a known MongoDB URI option of integer type. For example, "zlibCompressionLevel=5" is a valid integer MongoDB URI option, so ``mongoc_uri_option_is_int32 ("zlibCompressionLevel")`` is true. This will also return true for all 64-bit integer options.
2323

24+
See Also
25+
--------
26+
27+
* :symbol:`mongoc_uri_option_is_int64()`
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
:man_page: mongoc_uri_option_is_int64
2+
3+
mongoc_uri_option_is_int64()
4+
============================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
bool
12+
mongoc_uri_option_is_int64 (const char *option);
13+
14+
Parameters
15+
----------
16+
17+
* ``option``: The name of an option, case insensitive.
18+
19+
Description
20+
-----------
21+
22+
Returns true if the option is a known MongoDB URI option of 64-bit integer type. For example, "wTimeoutMS=100" is a valid 64-bit integer MongoDB URI option, so ``mongoc_uri_option_is_int64 ("wTimeoutMS")`` is true.
23+
24+
See Also
25+
--------
26+
27+
* :symbol:`mongoc_uri_option_is_int32()`

src/libmongoc/doc/mongoc_uri_set_option_as_int32.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Synopsis
1111
bool
1212
mongoc_uri_set_option_as_int32 (const mongoc_uri_t *uri,
1313
const char *option,
14-
int32 value);
14+
int32_t value);
1515
1616
Parameters
1717
----------
@@ -25,11 +25,16 @@ Description
2525

2626
Sets an individual URI option, after the URI has been parsed from a string.
2727

28-
Only known options of type int32 can be set. Some int32 options, such as :ref:`minHeartbeatFrequencyMS <sdam_uri_options>`, have additional constraints.
28+
Only known options of type integer can be set. Some integer options, such as :ref:`minHeartbeatFrequencyMS <sdam_uri_options>`, have additional constraints.
2929

3030
Updates the option in-place if already set, otherwise appends it to the URI's :symbol:`bson:bson_t` of options.
3131

3232
Returns
3333
-------
3434

35-
True if successfully set (the named option is a known option of type int32).
35+
True if successfully set (the named option is a known option of type int32 or int64).
36+
37+
See Also
38+
--------
39+
40+
* :symbol:`mongoc_uri_set_option_as_int64()`
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
:man_page: mongoc_uri_set_option_as_int64
2+
3+
mongoc_uri_set_option_as_int64()
4+
================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
bool
12+
mongoc_uri_set_option_as_int64 (const mongoc_uri_t *uri,
13+
const char *option,
14+
int64_t value);
15+
16+
Parameters
17+
----------
18+
19+
* ``uri``: A :symbol:`mongoc_uri_t`.
20+
* ``option``: The name of an option, case insensitive.
21+
* ``value``: The new value.
22+
23+
Description
24+
-----------
25+
26+
Sets an individual URI option, after the URI has been parsed from a string.
27+
28+
Only known options of type int32 or int64 can be set. For 32-bit integer options, the function returns ``false`` when trying to set a 64-bit value that exceeds the range of an ``int32_t``. Values that fit into an ``int32_t`` will be set correctly. In both cases, a warning will be emitted.
29+
30+
Updates the option in-place if already set, otherwise appends it to the URI's :symbol:`bson:bson_t` of options.
31+
32+
Returns
33+
-------
34+
35+
True if successfully set (the named option is a known option of type int64).
36+
37+
See Also
38+
--------
39+
40+
* :symbol:`mongoc_uri_option_is_int64()`
41+
* :symbol:`mongoc_uri_set_option_as_int32()`

src/libmongoc/doc/mongoc_uri_t.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ MONGOC_URI_SLAVEOK slaveok Whe
295295
mongoc_uri_get_mechanism_properties
296296
mongoc_uri_get_option_as_bool
297297
mongoc_uri_get_option_as_int32
298+
mongoc_uri_get_option_as_int64
298299
mongoc_uri_get_option_as_utf8
299300
mongoc_uri_get_options
300301
mongoc_uri_get_password
@@ -313,6 +314,7 @@ MONGOC_URI_SLAVEOK slaveok Whe
313314
mongoc_uri_new_with_error
314315
mongoc_uri_option_is_bool
315316
mongoc_uri_option_is_int32
317+
mongoc_uri_option_is_int64
316318
mongoc_uri_option_is_utf8
317319
mongoc_uri_set_auth_mechanism
318320
mongoc_uri_set_auth_source
@@ -321,6 +323,7 @@ MONGOC_URI_SLAVEOK slaveok Whe
321323
mongoc_uri_set_mechanism_properties
322324
mongoc_uri_set_option_as_bool
323325
mongoc_uri_set_option_as_int32
326+
mongoc_uri_set_option_as_int64
324327
mongoc_uri_set_option_as_utf8
325328
mongoc_uri_set_password
326329
mongoc_uri_set_read_concern

0 commit comments

Comments
 (0)