From 56633a87da9ee6eda44f5e527f811605a4d5e685 Mon Sep 17 00:00:00 2001 From: Phil Pearl Date: Fri, 12 Apr 2024 11:37:37 +0100 Subject: [PATCH] Use buffered writer for Snappy compression. The non-buffered writer is now deprecated. Also the amount of compression achieved and the CPU overhead is much better when using the buffered writer. --- conn.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/conn.go b/conn.go index 321da690..8ec8a4ab 100644 --- a/conn.go +++ b/conn.go @@ -119,8 +119,7 @@ func NewConn(addr string, config *Config, delegate ConnDelegate) *Conn { // The logger parameter is an interface that requires the following // method to be implemented (such as the the stdlib log.Logger): // -// Output(calldepth int, s string) -// +// Output(calldepth int, s string) func (c *Conn) SetLogger(l logger, lvl LogLevel, format string) { c.logGuard.Lock() defer c.logGuard.Unlock() @@ -468,7 +467,7 @@ func (c *Conn) upgradeSnappy() error { conn = c.tlsConn } c.r = snappy.NewReader(conn) - c.w = snappy.NewWriter(conn) + c.w = snappy.NewBufferedWriter(conn) frameType, data, err := ReadUnpackedResponse(c, c.config.MaxMsgSize) if err != nil { return err