Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5677

Remove the MessageStream abstraction from the connection layer

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 6.4.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • 8
    • 3
    • Not Needed
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      As a driver engineer / CSOT engineer,
      I want a connection layer that has easy to understand read / write semantics,
      So that CSOT's connection layer timeouts can be easily reasoned about and implemented.

      User Impact

      • n/a

      Dependencies

      • n/a

      Unknowns

      • Should we also refactor to use async-await at this point? 
        • yes, we will refactor the internals of the connection layer to use promises but we will continue to prove a callback interface for `Connection.command()` to ensure compatibility throughout the driver

      Acceptance Criteria

      Implementation Requirements

      Use subtasks as necessary. 

      To allow development with subtasks for easier PR review and logical breakdown - create a copy of the Connection class (ModernConnection or a similar name) and make refactors on the copy.  Once refactors are complete, rename the new class to Connection and delete the old class.

      • Remove the `MessageStream`
        • Introduce helpers for 
          • compression / decompression
          • serialization / deserialization 
          • buffering of server responses until we receive a full OP_MSG
        • Wrap the above helpers in generic "read", "write" and "readMany" helpers
        • Remove the message stream from the Connection class and listen to the socket for timeout and error events 
        • Adjust the `onMessage` handler to directly return a result or throw an error - no callbacks or async code is needed
        • adjust `Connection.command()` and write() to call the generic read/write helpers
        • Add a `readMany` helper specifically for use in monitoring and adjust the monitor to consume `hello`s using readMany

      Testing Requirements

      • Leave existing unit tests alone to provide coverage to the Connection class until the refactor is completed.
      • Port any valuable connection-layer unit tests to a new test suite for the new socket layer implemenation
      • Ensure all tests pass in the driver (integration and unit)

      Documentation Requirements

      • n/a

      Follow Up Requirements

      • n/a

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: