Skip to content

Commit eb9093a

Browse files
authored
CDRIVER-5941 remove deprecated mongoc_client_t API (#1951)
* remove `mongoc_client_get_database_names` * remove `mongoc_client_find_databases` * remove `mongoc_client_get_max_message_size` * remove `mongoc_client_get_max_bson_size` * remove `mongoc_client_get_server_status`
1 parent 609fa5e commit eb9093a

File tree

6 files changed

+19
-121
lines changed

6 files changed

+19
-121
lines changed

NEWS

+19-1
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ Unreleased (2.0.0)
3838
* Support for LibreSSL (the CMake option `ENABLE_SSL=LIBRESSL`) is removed. Associated API is removed (`MONGOC_ENABLE_SSL_LIBRESSL` and `mongoc_stream_tls_libressl_new`).
3939
* `MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED` (value -1) is removed. Use `MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED` (value 0) which is handled equivalently. If specified in a URI, replace: `mongodb://host/?w=-1` with `mongodb://host/?w=0`.
4040
* The deprecated CMake option `ENABLE_AUTOMATIC_INIT_AND_CLEANUP` is removed. See [Initialization and cleanup](https://mongoc.org/libmongoc/1.30.2/init-cleanup.html) for expected use of `mongoc_init()` and `mongoc_cleanup()`.
41+
* `mongoc_client_get_database_names` is removed. Use `mongoc_client_get_database_names_with_opts` instead.
42+
* `mongoc_client_find_databases` is removed. Use `mongoc_client_find_databases_with_opts` instead.
43+
* `mongoc_client_get_max_message_size` is removed.
44+
* `mongoc_client_get_max_bson_size` is removed.
4145
* Deprecated API for `mongoc_bulk_operation_t` is removed:
4246
* `mongoc_bulk_operation_delete` is removed. Use `mongoc_bulk_operation_remove()` instead.
4347
* `mongoc_bulk_operation_delete_one` is removed. Use `mongoc_bulk_operation_remove_one` instead.
4448
* `mongoc_bulk_operation_get_hint` is removed. Use `mongoc_bulk_operation_get_server_id` instead.
4549
* `mongoc_bulk_operation_set_hint` is removed. Use `mongoc_bulk_operation_set_server_id` instead.
4650
* Deprecated `mongoc_apm_command_*_get_server_connection_id` functions are removed. Use `mongoc_apm_command_*_get_server_connection_id_int64` instead.
4751

48-
4952
### Forwarding headers (`#include <bson.h>` and `#include <mongoc.h>`)
5053

5154
The compatibility "forwarding" headers have been removed (previously added in 1.13.0). This means it is no longer valid to include the literal header names `mongoc.h` or `bson.h` directly:
@@ -77,6 +80,21 @@ if (!ok) {
7780
bson_destroy (cmd);
7881
```
7982

83+
### `mongoc_client_get_server_status`
84+
85+
`mongoc_client_get_server_status` is removed. Use a command helper to run the "serverStatus" command instead:
86+
87+
```c
88+
bson_t *cmd = BCON_NEW("serverStatus", BCON_INT32(1));
89+
if (!mongoc_client_command_simple(client, "db", cmd, NULL, &reply, &error)) {
90+
printf("Failed to send 'serverStatus': %s\n", error.message);
91+
} else {
92+
// TODO: use `reply`
93+
}
94+
bson_destroy(&reply);
95+
bson_destroy(cmd);
96+
```
97+
8098

8199
libmongoc 1.30.2
82100
================

src/libmongoc/doc/mongoc_client_get_server_status.rst

-43
This file was deleted.

src/libmongoc/doc/mongoc_client_t.rst

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ Example
7171
mongoc_client_get_read_prefs
7272
mongoc_client_get_server_description
7373
mongoc_client_get_server_descriptions
74-
mongoc_client_get_server_status
7574
mongoc_client_get_uri
7675
mongoc_client_get_write_concern
7776
mongoc_client_new

src/libmongoc/src/mongoc/mongoc-client.c

-37
Original file line numberDiff line numberDiff line change
@@ -2221,43 +2221,6 @@ mongoc_client_find_databases_with_opts (mongoc_client_t *client, const bson_t *o
22212221
}
22222222

22232223

2224-
int32_t
2225-
mongoc_client_get_max_message_size (mongoc_client_t *client) /* IN */
2226-
{
2227-
BSON_ASSERT_PARAM (client);
2228-
2229-
return mongoc_cluster_get_max_msg_size (&client->cluster);
2230-
}
2231-
2232-
2233-
int32_t
2234-
mongoc_client_get_max_bson_size (mongoc_client_t *client) /* IN */
2235-
{
2236-
BSON_ASSERT_PARAM (client);
2237-
2238-
return mongoc_cluster_get_max_bson_obj_size (&client->cluster);
2239-
}
2240-
2241-
2242-
bool
2243-
mongoc_client_get_server_status (mongoc_client_t *client, /* IN */
2244-
mongoc_read_prefs_t *read_prefs, /* IN */
2245-
bson_t *reply, /* OUT */
2246-
bson_error_t *error) /* OUT */
2247-
{
2248-
bson_t cmd = BSON_INITIALIZER;
2249-
bool ret = false;
2250-
2251-
BSON_ASSERT_PARAM (client);
2252-
2253-
BSON_APPEND_INT32 (&cmd, "serverStatus", 1);
2254-
ret = mongoc_client_command_simple (client, "admin", &cmd, read_prefs, reply, error);
2255-
bson_destroy (&cmd);
2256-
2257-
return ret;
2258-
}
2259-
2260-
22612224
void
22622225
mongoc_client_set_stream_initiator (mongoc_client_t *client, mongoc_stream_initiator_t initiator, void *user_data)
22632226
{

src/libmongoc/src/mongoc/mongoc-client.h

-13
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,6 @@ MONGOC_EXPORT (mongoc_cursor_t *) mongoc_client_find_databases (mongoc_client_t
208208
MONGOC_EXPORT (mongoc_cursor_t *)
209209
mongoc_client_find_databases_with_opts (mongoc_client_t *client, const bson_t *opts) BSON_GNUC_WARN_UNUSED_RESULT;
210210

211-
BSON_DEPRECATED ("This function does not work with a mongoc_client_session_t, so this function is "
212-
"deprecated. Prefer to execute a command directly with mongoc_client_read_command_with_opts")
213-
MONGOC_EXPORT (bool) mongoc_client_get_server_status (mongoc_client_t *client,
214-
mongoc_read_prefs_t *read_prefs,
215-
bson_t *reply,
216-
bson_error_t *error);
217-
218-
BSON_DEPRECATED ("Use of this function is deprecated")
219-
MONGOC_EXPORT (int32_t) mongoc_client_get_max_message_size (mongoc_client_t *client);
220-
221-
BSON_DEPRECATED ("Use of this function is deprecated")
222-
MONGOC_EXPORT (int32_t) mongoc_client_get_max_bson_size (mongoc_client_t *client);
223-
224211
MONGOC_EXPORT (const mongoc_write_concern_t *)
225212
mongoc_client_get_write_concern (const mongoc_client_t *client);
226213

src/libmongoc/tests/test-mongoc-client.c

-26
Original file line numberDiff line numberDiff line change
@@ -1719,31 +1719,6 @@ test_recovering (void *ctx)
17191719
}
17201720

17211721

1722-
static void
1723-
test_server_status (void)
1724-
{
1725-
mongoc_client_t *client;
1726-
bson_error_t error;
1727-
bson_iter_t iter;
1728-
bson_t reply;
1729-
1730-
client = test_framework_new_default_client ();
1731-
BSON_ASSERT (client);
1732-
1733-
BEGIN_IGNORE_DEPRECATIONS
1734-
ASSERT_OR_PRINT (mongoc_client_get_server_status (client, NULL, &reply, &error), error);
1735-
END_IGNORE_DEPRECATIONS
1736-
1737-
BSON_ASSERT (bson_iter_init_find (&iter, &reply, "host"));
1738-
BSON_ASSERT (bson_iter_init_find (&iter, &reply, "version"));
1739-
BSON_ASSERT (bson_iter_init_find (&iter, &reply, "ok"));
1740-
1741-
bson_destroy (&reply);
1742-
1743-
mongoc_client_destroy (client);
1744-
}
1745-
1746-
17471722
static void
17481723
test_get_database_names (void)
17491724
{
@@ -3925,7 +3900,6 @@ test_client_install (TestSuite *suite)
39253900
TestSuite_AddMockServerTest (suite, "/Client/mongos_seeds_reconnect/single", test_mongos_seeds_reconnect_single);
39263901
TestSuite_AddMockServerTest (suite, "/Client/mongos_seeds_reconnect/pooled", test_mongos_seeds_reconnect_pooled);
39273902
TestSuite_AddFull (suite, "/Client/recovering", test_recovering, NULL, NULL, test_framework_skip_if_slow);
3928-
TestSuite_AddLive (suite, "/Client/server_status", test_server_status);
39293903
TestSuite_AddMockServerTest (suite, "/Client/database_names", test_get_database_names);
39303904
TestSuite_AddFull (
39313905
suite, "/Client/connect/uds", test_mongoc_client_unix_domain_socket, NULL, NULL, test_framework_skip_if_no_uds);

0 commit comments

Comments
 (0)