Switch to using the official etcd health check.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user