MONGOC_TOPOLO...EADABLE_SERVER(3)

πŸ’… mongoc_topology_description_has_readable_server β€” the vibe check for "is anybody home and can I read from them" ✨

okay so bestie, welcome to the libmongoc manual, section 3 πŸŽ€ this one is a little function that answers one very important question: can I actually read from somebody right now? πŸ‘‘


🌸 SYNOPSIS 🌸

bool
mongoc_topology_description_has_readable_server (
  const mongoc_topology_description_t *td, const mongoc_read_prefs_t *prefs);

πŸ’– DESCRIPTION πŸ’–

So like, this function determines if the topology has a readable server available πŸ’… that's the whole plot.

Servers get filtered by the given read preferences β€” but only if the driver is connected to a replica set πŸ¦‹ otherwise the read preferences are literally ignored, no cap.

And the most important part: this function uses the driver's current knowledge of the state of the MongoDB server or servers it is connected to. It does no I/O and it does not block ✨ so it's giving "instant answer, zero waiting, main character energy" β€” it just tells you what it already knows, periodt.


πŸŽ€ PARAMETERS πŸŽ€

  • td β€” a mongoc_topology_description_t πŸ’œ like, the topology description itself, the thing you're asking about.
  • read_prefs β€” a mongoc_read_prefs_t, or NULL for default read preferences 🌸 (NULL is totally fine, it'll use the defaults, iykyk).

⭐ RETURNS ⭐

True if there is a known server matching prefs πŸ‘‘ that's it, that's the answer.

🫢 remember: it's the known server β€” this is a vibe check on the driver's existing knowledge, not a fresh probe of the network, so no I/O happens and nothing blocks 😭

πŸ‘€ SEE ALSO:

Introduction to Application Performance Monitoring


πŸ’€ AUTHOR

MongoDB, Inc

2009-present, MongoDB, Inc.


and that's the whole page, bestie πŸ“ mwah πŸ’‹ β€” this little gem is from libmongoc 2.5.6, dated Oct 09, 2026 πŸ§šβ€β™€οΈ go forth and check your readable servers πŸ’œβœ¨

πŸ“¦ where this page comes from