The Driver Sessions Spec requires all functions that communicate with the server to accept a session parameter. We'll do this in the C Driver by accepting an arbitrary BSON document called "opts" that can include a variety of options, including a session.
Details:
Users create sessions with mongoc_client_start_session and bind the session to an opts document. A new function mongoc_client_session_append (mongoc_client_session_t *, bson_t *) appends an opaque integer id to the opts document, with the field name "sessionId".
When the driver executes a command with opts, the driver checks the opts for a "sessionId", retrieves the mongoc_client_session_t from a list of them in the mongoc_client_t, and adds the session's lsid and (if causally consistent) its clusterTime to the command it sends to the server.
Make a list of every public function in the driver that does not end with "_with_opts". Remove from the list any functions that have a "_with_opts" equivalent. Remove any that don't communicate with the server. For all remaining functions, add a "_with_opts" equivalent and test it in test-mongoc-client-session.c.
Done: Remove some workarounds from test-mongoc-client-session.c, like the direct call to the "insert" command (works around the current lack of mongoc_collection_insert_with_opts) and the "suspend_monitoring" field used in tests.
- Done: mongoc_client_find_databases_with_opts
- Done: mongoc_client_get_database_names_with_opts
- Done: mongoc_collection_create_bulk_operation_with_opts
- Done: mongoc_collection_find_indexes_with_opts
- Done: mongoc_collection_insert_one_with_opts
- Done: mongoc_database_find_collections_with_opts
- Done: mongoc_database_get_collection_names_with_opts
- Done: Rename the
CDRIVER-2205functions mongoc_collection_update_one/many_with_opts and mongoc_collection_replace_one_with_opts: remove "_with_opts". - mongoc_collection_insert_many, delete_one, delete_many
The generic command function is split out into CDRIVER-2207, GridFS work is split out in CDRIVER-2332 and delayed for a future version.
Don't do mongoc_database_create_user_with_opts, mongoc_database_remove_all_users_with_opts, or mongoc_database_remove_user_with_opts. Same justification as when we cancelled CDRIVER-326: this is not a libmongoc priority.
- depends on
-
CDRIVER-2207 Introduce generic mongoc_client_command_with_opts() function
- Closed
- is depended on by
-
CDRIVER-2192 Implement Driver Sessions API
- Closed
- is related to
-
CDRIVER-2332 New "with_opts" functions to support sessions with GridFS
- Closed
- related to
-
CDRIVER-2296 Option to pass bson_validate_flags_t to update/insert functions
- Closed