~hduran-8/juju-core/trunk

« back to all changes in this revision

Viewing changes to state/open.go

  • Committer: Tarmac
  • Author(s): Andrew Wilkins
  • Date: 2014-05-07 10:06:46 UTC
  • mfrom: (2701.1.1 state-dialtimeout)
  • Revision ID: tarmac-20140507100646-ttk89g2v9ds7ek85
[r=axwalk] state: reduce default dial timeout to 30s

Previously we could have been dialling state connections
across the Internet, since the CLI would connect to Mongo
directly. Now, with the CLI going to API only, we can
safely reduce the timeout.

It is possible that the timeout will be exceeded if the
peers in an HA setup are not all ready. In this case the
dial operation will fail and the caller (state server agent)
will restart.

This change will reduce the time to failure in tests, and
allow us to capture some information about the failed test
without exceeding the Go test timeout.

https://codereview.appspot.com/97100045/

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
// default.
33
33
const mongoSocketTimeout = 10 * time.Second
34
34
 
 
35
// defaultDialTimeout should be representative of
 
36
// the upper bound of time taken to dial a mongo
 
37
// server from within the same cloud/private network.
 
38
const defaultDialTimeout = 30 * time.Second
 
39
 
35
40
// Info encapsulates information about cluster of
36
41
// servers holding juju state and can be used to make a
37
42
// connection to that cluster.
63
68
// DefaultDialOpts returns a DialOpts representing the default
64
69
// parameters for contacting a state server.
65
70
func DefaultDialOpts() DialOpts {
66
 
        return DialOpts{
67
 
                Timeout: 10 * time.Minute,
68
 
        }
 
71
        return DialOpts{Timeout: defaultDialTimeout}
69
72
}
70
73
 
71
74
// Open connects to the server described by the given