Browse Source

Added method that exposes connection state; whether it is closed or not.

pull/196/head
bdular 1 year ago
parent
commit
4bf56e6808
2 changed files with 13 additions and 0 deletions
  1. +5
    -0
      connection.go
  2. +8
    -0
      internal/connectionmanager/connection_manager.go

+ 5
- 0
connection.go View File

@ -88,3 +88,8 @@ func (conn *Conn) Close() error {
conn.closeConnectionToManagerCh <- struct{}{}
return conn.connectionManager.Close()
}
// IsClosed returns whether the connection is closed or not
func (conn *Conn) IsClosed() bool {
return conn.connectionManager.IsClosed()
}

+ 8
- 0
internal/connectionmanager/connection_manager.go View File

@ -171,3 +171,11 @@ func (connManager *ConnectionManager) reconnect() error {
connManager.connection = conn
return nil
}
// IsClosed checks if the connection is closed
func (connManager *ConnectionManager) IsClosed() bool {
connManager.connectionMu.Lock()
defer connManager.connectionMu.Unlock()
return connManager.connection.IsClosed()
}

Loading…
Cancel
Save