Node: Apply a request timeout when communicating with nodes.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2014-11-21 15:54:30 -08:00
parent 3e930e0e9c
commit 622eb9339e
1 changed files with 4 additions and 1 deletions

View File

@ -15,6 +15,9 @@ import (
const (
// Force-refresh the state of the node this often.
stateRefreshPeriod = 30 * time.Second
// Timeout for requests sent out to the node.
requestTimeout = 10 * time.Second
)
func NewNode(addr string) *Node {
@ -47,7 +50,7 @@ type Node struct {
// Connect will initialize a connection to the Docker daemon running on the
// host, gather machine specs (memory, cpu, ...) and monitor state changes.
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 {
return err
}