PYTHON-5856 Move cursor execution logic into cursor class#2894
Open
aclark4life wants to merge 7 commits into
Open
PYTHON-5856 Move cursor execution logic into cursor class#2894aclark4life wants to merge 7 commits into
aclark4life wants to merge 7 commits into
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
Move the command preparation and response construction that lived in Server.run_operation into _AsyncCursorBase._run_with_conn, so cursors call run_cursor_command directly without routing through Server. - Extract _CURSOR_DOC_FIELDS, _split_message, and _operation_to_command as module-level helpers in cursor_base.py - Add abstract _unpack_response to _AsyncCursorBase to make the interface explicit - Add _run_with_conn (carrying the @_handle_reauth decorator) to _AsyncCursorBase; this is the new home for all of run_operation's logic - client._run_operation now accepts execute_fn(conn, op, rp) -> Response instead of routing through server.run_operation - Remove Server.run_operation, Server.operation_to_command, and Server._split_message entirely
The execute_fn -> run_with_conn rename missed this call site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PYTHON-5856
Changes in this PR
Moves the command preparation and response construction that lived in
Server.run_operationinto_AsyncCursorBase._run_with_conn, completing the consolidation started in PYTHON-5676. Cursors now callrun_cursor_commanddirectly without routing throughServer._CURSOR_DOC_FIELDSand_split_message(incursor_shared.py) and_operation_to_command(incursor_base.py) as module-level helpers_unpack_responseto_AsyncCursorBaseto make the interface explicit_run_with_conn(carrying the@_handle_reauthdecorator) to_AsyncCursorBase— new home for all ofServer.run_operation's logicclient._run_operation's second parameter, previouslyunpack_res(only decoded the wire response), is replaced byrun_with_conn(conn, operation, read_preference) -> Response, which executes the whole operation instead of routing throughserver.run_operation; callers (cursor.py,command_cursor.py) passself._run_with_connServer.run_operation,Server.operation_to_command, andServer._split_messageentirelyPYTHON-5745 (#2891) merged into master and was picked up here via a merge from master. That merge left
Server.run_operation/operation_to_command(and their now-orphaned imports) unreconciled since master no longer had the caller this branch had moved tocursor_base.py; this PR removes that leftover code and drops theaddress/startargs from_run_with_conn's call torun_cursor_command, matching the new_CommandTelemetry-based signature.Test Plan
No new tests — this is a behavior-preserving refactor. The existing spec suites (APM/command-monitoring, auth, cursor) assert the exact behavior that any regression would change. Updated
test_stale_getmoreto use therun_with_connparameter name.Checklist
Checklist for Author
Checklist for Reviewer