Skip to content

Commit

Permalink
pool: remove timeout parameter
Browse files Browse the repository at this point in the history
Timeout was never used in a meaningful way by callers, which is why it
is now entirely internal to the pool.
  • Loading branch information
hanshasselberg committed May 29, 2020
1 parent ad03f86 commit 1fbc1d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion agent/consul/snapshot_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func SnapshotRPC(
) (io.ReadCloser, error) {
// Write the snapshot RPC byte to set the mode, then perform the
// request.
conn, hc, err := connPool.DialTimeout(dc, nodeName, addr, 10*time.Second, pool.RPCSnapshot)
conn, hc, err := connPool.DialTimeout(dc, nodeName, addr, pool.RPCSnapshot)
if err != nil {
return nil, err
}
Expand Down
13 changes: 4 additions & 9 deletions agent/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ func (p *ConnPool) DialTimeout(
dc string,
nodeName string,
addr net.Addr,
timeout time.Duration,
actualRPCType RPCType,
) (net.Conn, HalfCloser, error) {
p.once.Do(p.init)
Expand All @@ -298,7 +297,6 @@ func (p *ConnPool) DialTimeout(
nodeName,
addr,
p.SrcAddr,
timeout,
p.TLSConfigurator.OutgoingALPNRPCWrapper(),
actualRPCType,
RPCTLS,
Expand All @@ -314,7 +312,6 @@ func (p *ConnPool) DialTimeout(
dc,
nodeName,
addr,
timeout,
actualRPCType,
RPCTLS,
)
Expand All @@ -324,12 +321,11 @@ func (p *ConnPool) dial(
dc string,
nodeName string,
addr net.Addr,
timeout time.Duration,
actualRPCType RPCType,
tlsRPCType RPCType,
) (net.Conn, HalfCloser, error) {
// Try to dial the conn
d := &net.Dialer{LocalAddr: p.SrcAddr, Timeout: timeout}
d := &net.Dialer{LocalAddr: p.SrcAddr, Timeout: defaultDialTimeout}
conn, err := d.Dial("tcp", addr.String())
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -393,7 +389,6 @@ func DialTimeoutWithRPCTypeViaMeshGateway(
nodeName string,
addr net.Addr,
src *net.TCPAddr,
timeout time.Duration,
wrapper tlsutil.ALPNWrapper,
actualRPCType RPCType,
tlsRPCType RPCType,
Expand Down Expand Up @@ -425,7 +420,7 @@ func DialTimeoutWithRPCTypeViaMeshGateway(
return nil, nil, structs.ErrDCNotAvailable
}

dialer := &net.Dialer{LocalAddr: src, Timeout: timeout}
dialer := &net.Dialer{LocalAddr: src, Timeout: defaultDialTimeout}

rawConn, err := dialer.Dial("tcp", gwAddr)
if err != nil {
Expand Down Expand Up @@ -461,7 +456,7 @@ func (p *ConnPool) getNewConn(dc string, nodeName string, addr net.Addr) (*Conn,
}

// Get a new, raw connection and write the Consul multiplex byte to set the mode
conn, _, err := p.DialTimeout(dc, nodeName, addr, defaultDialTimeout, RPCMultiplexV2)
conn, _, err := p.DialTimeout(dc, nodeName, addr, RPCMultiplexV2)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -575,7 +570,7 @@ func (p *ConnPool) rpcInsecure(dc string, nodeName string, addr net.Addr, method
}

var codec rpc.ClientCodec
conn, _, err := p.dial(dc, nodeName, addr, 1*time.Second, 0, RPCTLSInsecure)
conn, _, err := p.dial(dc, nodeName, addr, 0, RPCTLSInsecure)
if err != nil {
return fmt.Errorf("rpcinsecure error establishing connection: %v", err)
}
Expand Down

0 comments on commit 1fbc1d4

Please sign in to comment.