-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
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
- Introduce helpers for
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