forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase maxIdleConnection limit in etcd client.
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package etcd | ||
|
||
import ( | ||
"errors" | ||
"net" | ||
"time" | ||
) | ||
|
||
// dial attempts to open a TCP connection to the provided address, explicitly | ||
// enabling keep-alives with a one-second interval. | ||
func Dial(network, addr string) (net.Conn, error) { | ||
conn, err := net.DialTimeout(network, addr, time.Second) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
tcpConn, ok := conn.(*net.TCPConn) | ||
if !ok { | ||
return nil, errors.New("Failed type-assertion of net.Conn as *net.TCPConn") | ||
} | ||
|
||
// Keep TCP alive to check whether or not the remote machine is down | ||
if err = tcpConn.SetKeepAlive(true); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err = tcpConn.SetKeepAlivePeriod(time.Second); err != nil { | ||
return nil, err | ||
} | ||
|
||
return tcpConn, nil | ||
} |