|
749 | 749 | mongoc_uri_option_is_utf8 (const char *key)
|
750 | 750 | {
|
751 | 751 | return !strcasecmp (key, MONGOC_URI_APPNAME) || !strcasecmp (key, MONGOC_URI_REPLICASET) ||
|
752 |
| - !strcasecmp (key, MONGOC_URI_READPREFERENCE) || !strcasecmp (key, MONGOC_URI_SRVSERVICENAME) || |
753 |
| - !strcasecmp (key, MONGOC_URI_TLSCERTIFICATEKEYFILE) || |
| 752 | + !strcasecmp (key, MONGOC_URI_READPREFERENCE) || !strcasecmp (key, MONGOC_URI_SERVERMONITORINGMODE) || |
| 753 | + !strcasecmp (key, MONGOC_URI_SRVSERVICENAME) || !strcasecmp (key, MONGOC_URI_TLSCERTIFICATEKEYFILE) || |
754 | 754 | !strcasecmp (key, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD) || !strcasecmp (key, MONGOC_URI_TLSCAFILE) ||
|
755 | 755 | /* deprecated options */
|
756 | 756 | !strcasecmp (key, MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE) ||
|
@@ -1142,6 +1142,11 @@ mongoc_uri_apply_options (mongoc_uri_t *uri, const bson_t *options, bool from_dn
|
1142 | 1142 | goto UNSUPPORTED_VALUE;
|
1143 | 1143 | }
|
1144 | 1144 |
|
| 1145 | + } else if (!strcmp (key, MONGOC_URI_SERVERMONITORINGMODE)) { |
| 1146 | + if (!mongoc_uri_set_server_monitoring_mode (uri, value)) { |
| 1147 | + goto UNSUPPORTED_VALUE; |
| 1148 | + } |
| 1149 | + |
1145 | 1150 | } else if (mongoc_uri_option_is_utf8 (key)) {
|
1146 | 1151 | mongoc_uri_bson_append_or_replace_key (&uri->options, canon, value);
|
1147 | 1152 |
|
@@ -2350,6 +2355,30 @@ mongoc_uri_get_ssl (const mongoc_uri_t *uri) /* IN */
|
2350 | 2355 | return mongoc_uri_get_tls (uri);
|
2351 | 2356 | }
|
2352 | 2357 |
|
| 2358 | +const char * |
| 2359 | +mongoc_uri_get_server_monitoring_mode (const mongoc_uri_t *uri) |
| 2360 | +{ |
| 2361 | + BSON_ASSERT_PARAM (uri); |
| 2362 | + |
| 2363 | + return mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_SERVERMONITORINGMODE, "auto"); |
| 2364 | +} |
| 2365 | + |
| 2366 | + |
| 2367 | +bool |
| 2368 | +mongoc_uri_set_server_monitoring_mode (mongoc_uri_t *uri, const char *value) |
| 2369 | +{ |
| 2370 | + BSON_ASSERT_PARAM (uri); |
| 2371 | + BSON_ASSERT_PARAM (value); |
| 2372 | + |
| 2373 | + // Check for valid value |
| 2374 | + if (strcmp (value, "stream") && strcmp (value, "poll") && strcmp (value, "auto")) { |
| 2375 | + return false; |
| 2376 | + } |
| 2377 | + |
| 2378 | + mongoc_uri_bson_append_or_replace_key (&uri->options, MONGOC_URI_SERVERMONITORINGMODE, value); |
| 2379 | + return true; |
| 2380 | +} |
| 2381 | + |
2353 | 2382 | /*
|
2354 | 2383 | *--------------------------------------------------------------------------
|
2355 | 2384 | *
|
@@ -2886,6 +2915,8 @@ mongoc_uri_set_option_as_utf8 (mongoc_uri_t *uri, const char *option_orig, const
|
2886 | 2915 | }
|
2887 | 2916 | if (!bson_strcasecmp (option, MONGOC_URI_APPNAME)) {
|
2888 | 2917 | return mongoc_uri_set_appname (uri, value);
|
| 2918 | + } else if (!bson_strcasecmp (option, MONGOC_URI_SERVERMONITORINGMODE)) { |
| 2919 | + return mongoc_uri_set_server_monitoring_mode (uri, value); |
2889 | 2920 | } else {
|
2890 | 2921 | option_lowercase = lowercase_str_new (option);
|
2891 | 2922 | mongoc_uri_bson_append_or_replace_key (&uri->options, option_lowercase, value);
|
|
0 commit comments