Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: cursor to use fetchBatch function when current batch is empty #4093

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Apr 22, 2024

Description

What is changing?

  • Move next into cursor and rename to fetchBatch
  • Remove transform and blocking flags
  • tryNext/next now call fetchBatch as appropriate to get the same behavior the flags provided
  • move cleanupCursor logic to cleanup()
Is there new documentation needed for these changes?

No

What is the motivation for this change?

The next floating function owned too many details of the implementation of each cursor API, tryNext and next now do a small amount more lifting and we have a fetchBatch method that is focused on obtaining the next batch either with the init command or with a getMore.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

Comment on lines +526 to +530
if (
options?.error == null ||
options?.error?.name === 'MongoExpiredSessionError' ||
options?.force
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this change, endSession is sensitive to the exact order of endSession calls that were made by our cursor before this refactor.

@nbbeeken nbbeeken marked this pull request as ready for review May 1, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant