-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: move session support check to operation layer #2739
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cb14ee3
fix: move session support check to operation layer
nbbeeken 8b4e695
Move session support check into server selection for unified topology
nbbeeken 8a0e3ef
fix: update to simple fix
nbbeeken f621a49
refactor to use maybePromise, clean up comments and organize control …
nbbeeken b22fe87
fix: maybePromise refactor passes undefined to callbacks
nbbeeken 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
refactor to use maybePromise, clean up comments and organize control …
…flow
- Loading branch information
commit f621a498caea16014b2251aa6619fc37505447a5
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.
sorry to be so nitpicky, but I prefer what we do in the 4.0 branch where there's a
maybePromise
for each of these cases. The way this is written right now, you might end up nesting promises, whereas in 4.0 if you haven't provided a callback we are using the callback from the topmaybePromise
to pass into the secondaryexecuteOperation
.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.
(No worries, please nitpick away!)
I don't see how you can nest promises here since
selectServerForSessionSupport
will get passed a defined callback frommaybePromise
and so the next call to executeOperation will have that callback defined so the "second"maybePromise
won't create a new Promise.Something to consider is that this provides one point of exit to executeOperation. Entirely an 🧅 but that pattern is preferable to what is on 4.0. It's a strange pattern to me to have more code run "synchronously" in the remainder of the function after you've returned a function that appears to do an async task. (In this instance, I know maybePromise is all sync it's just wrapping a bit of setup work, but my style point remains). I'm glossing over the callback detail by just returning but we get the idea.
vs.
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.
Hm, you're right there's no Promise nesting. Maybe my ultimate concern is just about the multiple
maybePromise
calls in theexecuteOperation
stacktrace. A call toinsertOne
right now will look like:I guess we could provide a further abstraction of
executeOperation
(executeOperationImpl
or something) where you could skip one of themaybePromise
, but maybe it's not so much of a concern here. It's unlikely thatselectServerForSessionSupport
is called many times, so this isn't a big problem.Ok! Sounds good to me, maybe you want to make a similar change to the 4.0 branch while you're here?
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.
Yea we'll need to make a port of this sessions related fix to 4.0 so I can do that when I'm there (If anyone else reviewing has a differing opinion please feel free to chime in!)