1MONGOC_CLIENT_SELECT_SERVER(3) libmongoc MONGOC_CLIENT_SELECT_SERVER(3)
2
3
4
6 mongoc_client_select_server - mongoc_client_select_server()
7
9 mongoc_server_description_t *
10 mongoc_client_select_server (mongoc_client_t *client,
11 bool for_writes,
12 const mongoc_read_prefs_t *prefs,
13 bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT;
14
15 Choose a server for an operation, according to the logic described in
16 the Server Selection Spec.
17
18 Use this function only for building a language driver that wraps the C
19 Driver. When writing applications in C, higher-level functions automat‐
20 ically select a suitable server.
21
23 • client: A mongoc_client_t.
24
25 • for_writes: Whether to choose a server suitable for writes or reads.
26
27 • prefs: An optional mongoc_read_prefs_t. If for_writes is true, prefs
28 must be NULL. Otherwise, use prefs to customize server selection, or
29 pass NULL to use read preference PRIMARY.
30
31 • error: An optional location for a bson_error_t or NULL.
32
34 A mongoc_server_description_t that must be freed with
35 mongoc_server_description_destroy(). If no suitable server is found,
36 returns NULL and error is filled out.
37
39 MongoDB, Inc
40
42 2017-present, MongoDB, Inc
43
44
45
46
471.23.1 Oct 20, 2022 MONGOC_CLIENT_SELECT_SERVER(3)