[GODRIVER-934] Implement compression for driver.OperationContext Created: 04/Apr/19  Updated: 27/Oct/23  Resolved: 29/Apr/19

Status: Closed
Project: Go Driver
Component/s: Core API
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Unassigned
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Core API

 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.


Generated at Thu Feb 08 08:35:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.