- add Timeout field to CheckType and CheckHTTP to make http request timeout configurable by the client
This commit is contained in:
parent
9efda655a1
commit
4d105487a8
|
@ -721,6 +721,7 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *CheckType, persist
|
|||
CheckID: check.CheckID,
|
||||
HTTP: chkType.HTTP,
|
||||
Interval: chkType.Interval,
|
||||
Timeout: chkType.Timeout,
|
||||
Logger: a.logger,
|
||||
}
|
||||
http.Start()
|
||||
|
|
|
@ -36,7 +36,8 @@ type CheckType struct {
|
|||
HTTP string
|
||||
Interval time.Duration
|
||||
|
||||
TTL time.Duration
|
||||
Timeout time.Duration
|
||||
TTL time.Duration
|
||||
|
||||
Notes string
|
||||
}
|
||||
|
@ -269,6 +270,7 @@ type CheckHTTP struct {
|
|||
CheckID string
|
||||
HTTP string
|
||||
Interval time.Duration
|
||||
Timeout time.Duration
|
||||
Logger *log.Logger
|
||||
|
||||
httpClient *http.Client
|
||||
|
@ -287,7 +289,9 @@ func (c *CheckHTTP) Start() {
|
|||
// For long (>10s) interval checks the http timeout is 10s, otherwise the
|
||||
// timeout is the interval. This means that a check *should* return
|
||||
// before the next check begins.
|
||||
if c.Interval < 10*time.Second {
|
||||
if c.Timeout > 0 && c.Timeout < c.Interval {
|
||||
c.httpClient = &http.Client{Timeout: c.Timeout}
|
||||
} else if c.Interval < 10*time.Second {
|
||||
c.httpClient = &http.Client{Timeout: c.Interval}
|
||||
} else {
|
||||
c.httpClient = &http.Client{Timeout: 10 * time.Second}
|
||||
|
|
Loading…
Reference in New Issue