Support failover in cluster (experimental)

This commit is contained in:
finley
2025-04-19 22:11:58 +08:00
parent 14ec8277ca
commit f4a2c92fc1
20 changed files with 739 additions and 136 deletions

View File

@@ -57,7 +57,9 @@ func (c *Connection) RemoteAddr() string {
// Close disconnect with the client
func (c *Connection) Close() error {
c.sendingData.WaitWithTimeout(10 * time.Second)
_ = c.conn.Close()
if c.conn != nil { // may be a fake conn for tests
_ = c.conn.Close()
}
c.subs = nil
c.password = ""
c.queue = nil
@@ -219,6 +221,7 @@ func (c *Connection) IsSlave() bool {
return c.flags&flagSlave > 0
}
// SetMaster marks c as a connection with master
func (c *Connection) SetMaster() {
c.flags |= flagMaster
}