From 35c673862d6487f7279c2d29a0f2b131eddca97e Mon Sep 17 00:00:00 2001 From: Matt Brittan Date: Fri, 17 Sep 2021 09:26:23 +1200 Subject: [PATCH] Add warning to Disconnect function (reuse of the client may cause a panic). --- client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client.go b/client.go index b43ef73..fcc1eeb 100644 --- a/client.go +++ b/client.go @@ -439,6 +439,9 @@ func (c *client) attemptConnection() (net.Conn, byte, bool, error) { // Disconnect will end the connection with the server, but not before waiting // the specified number of milliseconds to wait for existing work to be // completed. +// WARNING: `Disconnect` may return before all activities (goroutines) have completed. This means that +// reusing the `client` may lead to panics. If you want to reconnect when the connection drops then use +// `SetAutoReconnect` and/or `SetConnectRetry`options instead of implementing this yourself. func (c *client) Disconnect(quiesce uint) { status := atomic.LoadUint32(&c.status) if status == connected {