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