mirror of https://github.com/status-im/consul.git
consul: RaftLayer does not use ConnPool
This commit is contained in:
parent
fa76825247
commit
8f2d9f9b0d
|
@ -16,9 +16,6 @@ type RaftLayer struct {
|
||||||
// connCh is used to accept connections
|
// connCh is used to accept connections
|
||||||
connCh chan net.Conn
|
connCh chan net.Conn
|
||||||
|
|
||||||
// ConnPool is used to make outbound connections
|
|
||||||
connPool *ConnPool
|
|
||||||
|
|
||||||
// Tracks if we are closed
|
// Tracks if we are closed
|
||||||
closed bool
|
closed bool
|
||||||
closeCh chan struct{}
|
closeCh chan struct{}
|
||||||
|
@ -27,12 +24,11 @@ type RaftLayer struct {
|
||||||
|
|
||||||
// NewRaftLayer is used to initialize a new RaftLayer which can
|
// NewRaftLayer is used to initialize a new RaftLayer which can
|
||||||
// be used as a StreamLayer for Raft
|
// be used as a StreamLayer for Raft
|
||||||
func NewRaftLayer(addr net.Addr, pool *ConnPool) *RaftLayer {
|
func NewRaftLayer(addr net.Addr) *RaftLayer {
|
||||||
layer := &RaftLayer{
|
layer := &RaftLayer{
|
||||||
addr: addr,
|
addr: addr,
|
||||||
connCh: make(chan net.Conn),
|
connCh: make(chan net.Conn),
|
||||||
connPool: pool,
|
closeCh: make(chan struct{}),
|
||||||
closeCh: make(chan struct{}),
|
|
||||||
}
|
}
|
||||||
return layer
|
return layer
|
||||||
}
|
}
|
||||||
|
@ -78,18 +74,5 @@ func (l *RaftLayer) Addr() net.Addr {
|
||||||
|
|
||||||
// Dial is used to create a new outgoing connection
|
// Dial is used to create a new outgoing connection
|
||||||
func (l *RaftLayer) Dial(address string, timeout time.Duration) (net.Conn, error) {
|
func (l *RaftLayer) Dial(address string, timeout time.Duration) (net.Conn, error) {
|
||||||
// Get a net.Addr
|
return net.DialTimeout("tcp", address, timeout)
|
||||||
addr, err := net.ResolveTCPAddr("tcp", address)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the conn pool
|
|
||||||
conn, err := l.connPool.Acquire(addr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Discard the Conn wrapper
|
|
||||||
return conn.conn, nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ func (s *Server) setupRPC() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
s.rpcListener = list
|
s.rpcListener = list
|
||||||
s.raftLayer = NewRaftLayer(s.rpcListener.Addr(), s.connPool)
|
s.raftLayer = NewRaftLayer(s.rpcListener.Addr())
|
||||||
go s.listen()
|
go s.listen()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue