mongodb / specifications

Specifications related to MongoDB
http://specifications.readthedocs.io/en/latest
Other
389 stars 242 forks source link

DRIVERS-2533: add RunCursorCommand API #1412

Closed nbbeeken closed 1 year ago

nbbeeken commented 1 year ago

Summary

Adds a new runCursorCommand database API that can handle running a generic command that returns a cursor from the server. MongoDB cursors need the client to track some pieces of metadata that are generally internal to a driver implementation (session.lsid, cursor.id, server/connection, namespace) so this API is aware that the command being run needs to maintain these components for subsequent iteration of the cursor, via getMore commands.

Changes

Tasks

nbbeeken commented 1 year ago

@alcaeus

allow customization of batchSize, comment, and maxTimeMS for getMore command invocations: does this apply to all cursors or only those created through runCursorCommand?

It MAY only apply to this API, I don't see a reason other than expanding the scope of existing APIs why driver's should or should not allow getMore fields to be configurable for all cursors. It's likely that there is no need in other cursors intended to provide a high level API where getMores are a hidden implementation detail. For this API, the user is seeking the ability to control command construction, so the motivation is to try and provide the knobs that also impact getMore command construction.

Some more discussion here: https://github.com/mongodb/specifications/pull/1412#discussion_r1190202154

Use case examples here: https://mongodb.slack.com/archives/C7WJZNUTA/p1675879216249919 https://jira.mongodb.org/browse/GODRIVER-1605

Given that context do you think there is something to add? I wouldn't recommend it for other cursor implementations but I don't see anything wrong with it either.

alcaeus commented 1 year ago

@nbbeeken thanks for the explanation. I don't think we need to add it to the rest of the cursor-generating API at this time. We may want to consider that in the future, at which point we should also revisit how these options are set: whether it's in the original call that produces the cursor or on the resulting cursor itself.