• Type: Icon: Sub-task Sub-task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • 6.3.0
    • Affects Version/s: None
    • Component/s: None
    • 0
    • 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?

      Acceptance Criteria

      Create new connection class and introduce compress, decompress, and buffer response helpers. Add generic socket read, socket write, and socket readMany helpers and refactor.

      Implementation Requirements

      • Add compression helpers
        • compressCommand(command: Uint8Array): Promise<Uint8Array>) 
        • decompressResponse(buffer: Uint8Array) : Promise<OpMsgResponse | OpQueryResponse>
      • Add socket write helper
          • write(command: Uint8Array): Promise<void>
            • pushes a command into the socket's buffer and waits until a `drain` event has been emitted
      • Add wire protocol message buffer helper
        • bufferReponse(socket) : AsyncGenerator<Uint8Array>
      • Add socket read helpers
        • read(socket): Promise<OpMsgResponse | OpQueryResponse>
        • readMany(socket): AsyncGenerator<OpMsgResponse | OpQueryResponse>
      • Create a copy of the connection class.  
        • This is done now primarily so that future PRs have an easy diff, once refactors are started on the connection.

      Testing Requirements

      • Add compression helpers
        • compressCommand
          • when compression is disabled, compress returns the raw buffer
          • when compression is enabled, it returns a compressed command
          • when compression is enabled but the command is not a compressible command, the uncompressed command is returned
        • decompressResponse
          • when the command is not OP_COMPRESSED, it returns the raw buffer
          • when the command is OP_COMPRESSED, it returns a decompressed buffer
      • Add socket write helper
        • when `drain` is not emitted, this function never resolves
        • when the `drain` event is emitted, this function resolves
      • Add wire protocol message buffer helper
        • when an invalid message size is received from the socket, an error is thrown
        • when a chunk is received but it is not a full message, no message is returned
        • when a full message is received, a buffer is yielded to the consumer
        • when multiple wire protocol messages are received, it yields multiple wire protocol messages
      • Add socket read helpers
        • read(socket)
          • when a single wire protocol message is received, it returns the message
          • when multiple wire protocol messages received, it only returns the first
        • readMany(socket): AsyncGenerator<OpMsgResponse | OpQueryResponse>
          • when a single message without moreToCome set is received, only one message is returned
          • when multiple messages without moreToCome set are received, only one message is returned
          • when multiple messages with moreToCome set are received, all messages are yielded
          • no more messages are returned after a message with moreToCome unset is received

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: