mongo-c-driver icon indicating copy to clipboard operation
mongo-c-driver copied to clipboard

Add mongoc_cursor_get_batch_num

Open Roman-Koshelev opened this issue 1 year ago • 3 comments

Roman-Koshelev avatar May 17 '24 16:05 Roman-Koshelev

Thank you for the PR @Roman-Koshelev. Can you describe the use case for mongoc_cursor_get_batch_num? There may be other ways to solve the problem (e.g. command monitoring can be used to get information about commands sent to the server).

kevinAlbs avatar May 17 '24 19:05 kevinAlbs

Usage example https://github.com/userver-framework/userver/blob/develop/mongo/src/storages/mongo/cdriver/cursor_impl.cpp#L68 . If there is a more elegant solution then I'm happy to use it

Roman-Koshelev avatar May 18 '24 06:05 Roman-Koshelev

Thank you for sharing the use case. IIUC, this PR is intended help answer "Did mongoc_cursor_next contact the server?" to get the duration of a command sent to the server. I expect this may be possible to do with existing command monitoring events for. Here is an example (can be extended to listen for command failed).

kevinAlbs avatar May 28 '24 15:05 kevinAlbs

Did it in https://github.com/userver-framework/userver/commit/9860015811e6139991709579cb881b207f896764

Roman-Koshelev avatar Oct 15 '24 09:10 Roman-Koshelev