Switch to using the official etcd health check.

This commit is contained in:
Brendan Burns
2015-06-23 21:47:24 -07:00
parent f4e7b5480d
commit f4e97be78e
5 changed files with 72 additions and 4 deletions

View File

@@ -33,11 +33,14 @@ type httpGet interface {
Get(url string) (*http.Response, error)
}
type ValidatorFn func([]byte) error
type Server struct {
Addr string
Port int
Path string
EnableHTTPS bool
Validate ValidatorFn
}
type ServerStatus struct {
@@ -85,5 +88,10 @@ func (server *Server) DoServerCheck(rt http.RoundTripper) (probe.Result, string,
return probe.Failure, string(data),
fmt.Errorf("unhealthy http status code: %d (%s)", resp.StatusCode, resp.Status)
}
if server.Validate != nil {
if err := server.Validate(data); err != nil {
return probe.Failure, string(data), err
}
}
return probe.Success, string(data), nil
}