MONGOC_CURSOR..._AWAIT_TIME_MS(3)

πŸ’… MONGOC_CURSOR_SET_MAX_AWAIT_TIME_MS(3) πŸ’…

okay bestie, so this is a page out of libmongoc and it's all about telling your tailable cursor how long the server should sit there and wait for new docs to show up. lowkey niche but highkey useful, iykyk πŸ¦‹


✨ SYNOPSIS ✨

void
mongoc_cursor_set_max_await_time_ms (mongoc_cursor_t *cursor,
                                     uint32_t max_await_time_ms);

πŸŽ€ PARAMETERS πŸŽ€

  • cursor β€” a mongoc_cursor_t. the main character of this whole situation, fr fr.
  • max_await_time_ms β€” a timeout in milliseconds. that's it, that's the number. πŸ’«

πŸ’– DESCRIPTION πŸ’–

so here's the vibe: this sets the maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. the server just hangs out patiently like a good little guy until it gets what it needs or the clock runs out. ⏳

it only applies if the cursor was created from mongoc_collection_find_with_opts() with the "tailable" and "awaitData" options, and the server is MongoDB 3.2 or later. no cap, both conditions. 🫢

peep the documentation for maxTimeMS and the "getMore" command if you wanna go deeper. πŸ“š

bestie, listen to me: the max_await_time_ms cannot be changed after the first call to mongoc_cursor_next(). so set it up before you start pulling docs, okay? 😭

also β€” and this is the part people miss β€” this is not applicable to all cursors. calling mongoc_cursor_set_batch_size() on a cursor returned by any of these:

  • mongoc_client_find_databases_with_opts()
  • mongoc_database_find_collections_with_opts()
  • mongoc_collection_find_indexes_with_opts()

...will not change the results. like, nothing. zero. nada. πŸ™ˆ

Note: although max_await_time_ms is a uint32_t, it is possible to set it as a uint64_t through the options arguments in some cursor returning functions like mongoc_collection_find_with_opts(). type chaos, but make it ✨intentional✨.

🌈 SEE ALSO 🌈

Tailable Cursors. (go read it, it's giving required reading πŸ’…)


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc


2009-present, MongoDB, Inc.


alright that's the whole page, mwah πŸ“ if you made it this far then you're officially a tailable cursor girlie now. this was libmongoc version 2.5.6, dated Oct 09, 2026 β€” slay, periodt. πŸ’œπŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from