mirror of https://github.com/docker/docs.git
Node: Apply a request timeout when communicating with nodes.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
3e930e0e9c
commit
622eb9339e
|
|
@ -15,6 +15,9 @@ import (
|
||||||
const (
|
const (
|
||||||
// Force-refresh the state of the node this often.
|
// Force-refresh the state of the node this often.
|
||||||
stateRefreshPeriod = 30 * time.Second
|
stateRefreshPeriod = 30 * time.Second
|
||||||
|
|
||||||
|
// Timeout for requests sent out to the node.
|
||||||
|
requestTimeout = 10 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewNode(addr string) *Node {
|
func NewNode(addr string) *Node {
|
||||||
|
|
@ -47,7 +50,7 @@ type Node struct {
|
||||||
// Connect will initialize a connection to the Docker daemon running on the
|
// Connect will initialize a connection to the Docker daemon running on the
|
||||||
// host, gather machine specs (memory, cpu, ...) and monitor state changes.
|
// host, gather machine specs (memory, cpu, ...) and monitor state changes.
|
||||||
func (n *Node) Connect(config *tls.Config) error {
|
func (n *Node) Connect(config *tls.Config) error {
|
||||||
c, err := dockerclient.NewDockerClient(n.Addr, config)
|
c, err := dockerclient.NewDockerClientTimeout(n.Addr, config, time.Duration(requestTimeout))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue