From 91e74b86bf7f5b9c50fb0ae925ade7e07788f3a0 Mon Sep 17 00:00:00 2001 From: "WEINBERG, MICHAEL" Date: Wed, 20 Nov 2019 15:03:32 -0500 Subject: [PATCH 1/7] increase write buffer to 1mb --- connection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connection.go b/connection.go index 4e64d375..d4456d62 100644 --- a/connection.go +++ b/connection.go @@ -50,7 +50,7 @@ type auth struct { func (ws *Ws) connect() (err error) { d := websocket.Dialer{ - WriteBufferSize: 8192, + WriteBufferSize: 1000000, ReadBufferSize: 8192, HandshakeTimeout: ws.timeout, // Timeout or else we'll hang forever and never fail on bad hosts. } From 8ae7247a93e20c68e6045428f9524c74d06fc1e5 Mon Sep 17 00:00:00 2001 From: "WEINBERG, MICHAEL" Date: Wed, 20 Nov 2019 15:14:11 -0500 Subject: [PATCH 2/7] update module path --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2472c555..7af2fac6 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/schwartzmx/gremtune +module github.com/weinbergm/gremtune require ( github.com/gofrs/uuid v3.2.0+incompatible From 3d8016c1c78c0ab53cba7e3705c95cdd4f1435eb Mon Sep 17 00:00:00 2001 From: "WEINBERG, MICHAEL" Date: Wed, 20 Nov 2019 17:04:37 -0500 Subject: [PATCH 3/7] make buffer size configurable --- configuration.go | 9 +++++++++ connection.go | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/configuration.go b/configuration.go index dd7fdae5..b7512c6e 100644 --- a/configuration.go +++ b/configuration.go @@ -40,3 +40,12 @@ func SetReadingWait(seconds int) DialerConfig { c.readingWait = time.Duration(seconds) * time.Second } } + + +//SetBufferSize sets the read/write buffer size +func SetBufferSize(readBufferSize int, writeBufferSize int) DialerConfig { + return func(c *Ws) { + c.readBufferSize = readBufferSize + c.writeBufferSize = writeBufferSize + } +} diff --git a/connection.go b/connection.go index d4456d62..eabeb42a 100644 --- a/connection.go +++ b/connection.go @@ -38,6 +38,8 @@ type Ws struct { writingWait time.Duration readingWait time.Duration timeout time.Duration + readBufSize int + writeBufSize int quit chan struct{} sync.RWMutex } @@ -50,8 +52,8 @@ type auth struct { func (ws *Ws) connect() (err error) { d := websocket.Dialer{ - WriteBufferSize: 1000000, - ReadBufferSize: 8192, + WriteBufferSize: ws.readBufSize, + ReadBufferSize: ws.writeBufSize, HandshakeTimeout: ws.timeout, // Timeout or else we'll hang forever and never fail on bad hosts. } ws.conn, _, err = d.Dial(ws.host, http.Header{}) From e0605cc8a9785fde673ace3bb29b625e4e1c4bb4 Mon Sep 17 00:00:00 2001 From: "WEINBERG, MICHAEL" Date: Wed, 20 Nov 2019 17:09:21 -0500 Subject: [PATCH 4/7] make buffer size configurable --- configuration.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration.go b/configuration.go index b7512c6e..0a0fd84b 100644 --- a/configuration.go +++ b/configuration.go @@ -45,7 +45,7 @@ func SetReadingWait(seconds int) DialerConfig { //SetBufferSize sets the read/write buffer size func SetBufferSize(readBufferSize int, writeBufferSize int) DialerConfig { return func(c *Ws) { - c.readBufferSize = readBufferSize - c.writeBufferSize = writeBufferSize + c.readBufSize = readBufferSize + c.writeBufSize = writeBufferSize } } From e77edae5a1d6a00e24b42c7fb28990766d8be360 Mon Sep 17 00:00:00 2001 From: "WEINBERG, MICHAEL" Date: Wed, 20 Nov 2019 17:13:32 -0500 Subject: [PATCH 5/7] make buffer size configurable --- connection.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connection.go b/connection.go index eabeb42a..83929e95 100644 --- a/connection.go +++ b/connection.go @@ -52,8 +52,8 @@ type auth struct { func (ws *Ws) connect() (err error) { d := websocket.Dialer{ - WriteBufferSize: ws.readBufSize, - ReadBufferSize: ws.writeBufSize, + WriteBufferSize: ws.writeBufSize, + ReadBufferSize: ws.readBufSize, HandshakeTimeout: ws.timeout, // Timeout or else we'll hang forever and never fail on bad hosts. } ws.conn, _, err = d.Dial(ws.host, http.Header{}) From 95cf7991ef1136f654a5e4a97e9f95e41e5ffae7 Mon Sep 17 00:00:00 2001 From: "WEINBERG, MICHAEL" Date: Wed, 20 Nov 2019 17:17:48 -0500 Subject: [PATCH 6/7] change back original module name --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 7af2fac6..2472c555 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/weinbergm/gremtune +module github.com/schwartzmx/gremtune require ( github.com/gofrs/uuid v3.2.0+incompatible From 5e34861a927e398bda42ffe8061b7ba22685f5a5 Mon Sep 17 00:00:00 2001 From: "WEINBERG, MICHAEL" Date: Fri, 6 Dec 2019 10:59:51 -0500 Subject: [PATCH 7/7] fix line indentation and add default values for Read and Write buffer sizes --- client.go | 2 ++ configuration.go | 3 +-- connection.go | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index a975178a..8ee73615 100644 --- a/client.go +++ b/client.go @@ -30,6 +30,8 @@ func NewDialer(host string, configs ...DialerConfig) (dialer *Ws) { readingWait: 15 * time.Second, connected: false, quit: make(chan struct{}), + readBufSize: 8192, + writeBufSize: 8192, } for _, conf := range configs { diff --git a/configuration.go b/configuration.go index 0a0fd84b..4820e94d 100644 --- a/configuration.go +++ b/configuration.go @@ -41,11 +41,10 @@ func SetReadingWait(seconds int) DialerConfig { } } - //SetBufferSize sets the read/write buffer size func SetBufferSize(readBufferSize int, writeBufferSize int) DialerConfig { return func(c *Ws) { c.readBufSize = readBufferSize - c.writeBufSize = writeBufferSize + c.writeBufSize = writeBufferSize } } diff --git a/connection.go b/connection.go index 83929e95..ff103a4d 100644 --- a/connection.go +++ b/connection.go @@ -38,8 +38,8 @@ type Ws struct { writingWait time.Duration readingWait time.Duration timeout time.Duration - readBufSize int - writeBufSize int + readBufSize int + writeBufSize int quit chan struct{} sync.RWMutex }