Skip to content

refactor(NODE-5696): add async-iterator based socket helpers #3896

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

Merged
merged 8 commits into from
Nov 8, 2023
Merged

Conversation

baileympearson
Copy link
Contributor

@baileympearson baileympearson commented Oct 17, 2023

Description

What is changing?

This PR is the first connection layer refactor. It does three things

  • Rename our existing commands (Response, Query, BinMsg and Msg) to more descriptive names. Happy to revert this and put it in a separate PR.
  • Creates a copy of the Connection class, called ModernConnection. This class is unused and the connection layer refactor will be done on this class so that our existing connection layer can remain unaffected until the new connection layer is ready.
  • Creates generic socket helpers.
    -- read & readMany read wire protocol messages from a connection
    -- writeCommand writes a wire protocol message to a connection

These helpers are built on the readWireProtocolMessages async generator. readWireProtocolMessages replaces the message stream - it buffers data emissions from the underlying socket until a full wire protocol message has been received.

I made some additional refactors but these are intentionally additive. No existing functionality is impacted by the new code paths.

Is there new documentation needed for these changes?

No

What is the motivation for this change?

CSOT requires the ability to cancel socket read & socket write for each operation. A generic socket read/write abstraction will make the CSOT implementation at the connection layer much more straightforward.

Release Highlight

Fill in title or leave empty for no highlight

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

Sorry, something went wrong.

@baileympearson baileympearson changed the title refactor refactor(NODE-5696): add async-iterator based socket helpers Oct 18, 2023
@baileympearson baileympearson marked this pull request as ready for review October 18, 2023 14:55
@nbbeeken nbbeeken self-assigned this Oct 18, 2023
@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Oct 18, 2023
@nbbeeken nbbeeken requested a review from durran October 18, 2023 20:11
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

@durran I already requested your review since I will be out soon, you might as well take up the primary review reins.

Left thoughts, didn't look at the tests wanted to get you something to spur discussion on some of the decisions.

durran
durran previously approved these changes Nov 7, 2023
@durran durran added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Nov 7, 2023
@durran durran assigned durran and unassigned nbbeeken Nov 7, 2023
@W-A-James W-A-James self-requested a review November 7, 2023 18:52
@durran durran merged commit b602162 into main Nov 8, 2023
@durran durran deleted the NODE-5696 branch November 8, 2023 17:24
aditi-khare-mongoDB pushed a commit that referenced this pull request Nov 17, 2023
Co-authored-by: Neal Beeken <neal.beeken@mongodb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants