consul: do not clear connection cache on RPC errors
This commit is contained in:
parent
a817a398dc
commit
32f3d17931
|
@ -44,6 +44,11 @@ type StreamClient struct {
|
||||||
client *rpc.Client
|
client *rpc.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sc *StreamClient) Close() {
|
||||||
|
sc.stream.Close()
|
||||||
|
sc.client.Close()
|
||||||
|
}
|
||||||
|
|
||||||
// Conn is a pooled connection to a Consul server
|
// Conn is a pooled connection to a Consul server
|
||||||
type Conn struct {
|
type Conn struct {
|
||||||
refCount int32
|
refCount int32
|
||||||
|
@ -106,7 +111,7 @@ func (c *Conn) returnClient(client *StreamClient) {
|
||||||
}
|
}
|
||||||
c.clientLock.Unlock()
|
c.clientLock.Unlock()
|
||||||
if !didSave {
|
if !didSave {
|
||||||
client.stream.Close()
|
client.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +350,7 @@ func (p *ConnPool) RPC(addr net.Addr, version int, method string, args interface
|
||||||
// Make the RPC call
|
// Make the RPC call
|
||||||
err = sc.client.Call(method, args, reply)
|
err = sc.client.Call(method, args, reply)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.clearConn(conn)
|
sc.Close()
|
||||||
p.releaseConn(conn)
|
p.releaseConn(conn)
|
||||||
return fmt.Errorf("rpc error: %v", err)
|
return fmt.Errorf("rpc error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue