This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
feat: Added GetBulkAsRawMap function to the MongoDB API #259
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to note here: since this context is getting reused, all the cursor.Next calls need to complete before the timeout. Might be an issue if there's a large result set.
I see that I also did the same thing in the
collectBulkGetResults
method. Perhaps it's not urgent right now, but might be worth reworking in the future to use a new context for each call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on how timeout is defined. If timeout is defined as the timeout for the entire function, i.e. GetBulk, then this is correct. Otherwise, you'd have a variable timeout for GetBulk depending on how many items in the result set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably need to define the timeout more explicitly. Right now here's how I defined it above the WithTimeout function:
When I created that option, I was thinking the timeout was per remote call to MongoDB (which a cursor.Next would be, depending on the current page). So far in the other areas of the code, I create a new timeout for every possible MongoDB call (with the exception of the bulk results collection as mentioned above). But I now see a problem with that approach. Some calls to MongoDB can take longer than others (e.g. some
Find
calls that execute queries). I think ideally the caller should be able to pass in their own timeout to each call, which is tricky with the current interface. I think I should create a followup issue for me to address this in the future. What do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, ideally the caller should be providing the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #262