Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-934

Implement compression for driver.OperationContext

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Gone away
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Core API
    • None

    Description

      Compression was previously implemented in the connection.connection type, however this required the inspection of an already constructed wire message to determine if compression was allowed. Instead, the driver.OperationContext type should handle this directly. This can be done efficiently by retrieving the command name during wire message construction, returning it, and then using that to determine if compression can be done.

      To hold the compression state, a CompressionContext type is used. This type has a CompressWireMessage method with the following signature:

      func Compress(wm []byte, commandName string, desc description.Server) ([]byte, error)
      

      The CompressionContext itself is defined as:

      type CompressionContext struct {
         Compressors []string
         ZlibLevel int
      }
      

      To aid in reuse of memory, global pools of zlib.ReaderCloser and zlib.Writer are required.

      The Compress method should overwrite the provided slice with the newly compressed message. Internally, it can pull from it's own pool of []byte.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kris.brandow@mongodb.com Kristofer Brandow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: