mirror of https://github.com/status-im/consul.git
consul: Write the byte to set the RPC mode
This commit is contained in:
parent
8f2d9f9b0d
commit
ee4b1ce9dd
|
@ -14,7 +14,9 @@ type Conn struct {
|
|||
|
||||
// ConnPool is used to maintain a connection pool to other
|
||||
// Consul servers. This is used to reduce the latency of
|
||||
// RPC requests between servers
|
||||
// RPC requests between servers. It is only used to pool
|
||||
// connections in the rpcConsul mode. Raft connections
|
||||
// are pooled seperately.
|
||||
type ConnPool struct {
|
||||
sync.Mutex
|
||||
|
||||
|
@ -99,6 +101,9 @@ func (p *ConnPool) getNewConn(addr net.Addr) (*Conn, error) {
|
|||
conn.SetKeepAlive(true)
|
||||
conn.SetNoDelay(true)
|
||||
|
||||
// Write the Consul RPC byte to set the mode
|
||||
conn.Write([]byte{byte(rpcConsul)})
|
||||
|
||||
// Wrap the connection
|
||||
c := &Conn{
|
||||
addr: addr,
|
||||
|
|
|
@ -74,5 +74,12 @@ func (l *RaftLayer) Addr() net.Addr {
|
|||
|
||||
// Dial is used to create a new outgoing connection
|
||||
func (l *RaftLayer) Dial(address string, timeout time.Duration) (net.Conn, error) {
|
||||
return net.DialTimeout("tcp", address, timeout)
|
||||
conn, err := net.DialTimeout("tcp", address, timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Write the Raft byte to set the mode
|
||||
conn.Write([]byte{byte(rpcRaft)})
|
||||
return conn, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue