rename probe.Status to probe.Result.
This commit is contained in:
@@ -33,7 +33,7 @@ func New() ExecProber {
|
||||
|
||||
type ExecProber struct{}
|
||||
|
||||
func (pr ExecProber) Probe(e uexec.Cmd) (probe.Status, error) {
|
||||
func (pr ExecProber) Probe(e uexec.Cmd) (probe.Result, error) {
|
||||
data, err := e.CombinedOutput()
|
||||
glog.V(4).Infof("health check response: %s", string(data))
|
||||
if err != nil {
|
||||
|
@@ -35,7 +35,7 @@ func (f *FakeCmd) CombinedOutput() ([]byte, error) {
|
||||
func (f *FakeCmd) SetDir(dir string) {}
|
||||
|
||||
type healthCheckTest struct {
|
||||
expectedStatus probe.Status
|
||||
expectedStatus probe.Result
|
||||
expectError bool
|
||||
output []byte
|
||||
err error
|
||||
|
@@ -38,7 +38,7 @@ type HTTPProber struct {
|
||||
}
|
||||
|
||||
// Probe returns a ProbeRunner capable of running an http check.
|
||||
func (pr *HTTPProber) Probe(host string, port int, path string, timeout time.Duration) (probe.Status, error) {
|
||||
func (pr *HTTPProber) Probe(host string, port int, path string, timeout time.Duration) (probe.Result, error) {
|
||||
return DoHTTPProbe(formatURL(host, port, path), &http.Client{Timeout: timeout, Transport: pr.transport})
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ type HTTPGetInterface interface {
|
||||
// If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Success.
|
||||
// If the HTTP response code is unsuccessful or HTTP communication fails, it returns Failure.
|
||||
// This is exported because some other packages may want to do direct HTTP probes.
|
||||
func DoHTTPProbe(url string, client HTTPGetInterface) (probe.Status, error) {
|
||||
func DoHTTPProbe(url string, client HTTPGetInterface) (probe.Result, error) {
|
||||
res, err := client.Get(url)
|
||||
if err != nil {
|
||||
glog.V(1).Infof("HTTP probe error: %v", err)
|
||||
|
@@ -54,7 +54,7 @@ func TestHTTPProbeChecker(t *testing.T) {
|
||||
prober := New()
|
||||
testCases := []struct {
|
||||
handler func(w http.ResponseWriter)
|
||||
health probe.Status
|
||||
health probe.Result
|
||||
}{
|
||||
// The probe will be filled in below. This is primarily testing that an HTTP GET happens.
|
||||
{handleReq(http.StatusOK), probe.Success},
|
||||
|
@@ -16,16 +16,16 @@ limitations under the License.
|
||||
|
||||
package probe
|
||||
|
||||
type Status int
|
||||
type Result int
|
||||
|
||||
// Status values must be one of these constants.
|
||||
const (
|
||||
Success Status = iota
|
||||
Success Result = iota
|
||||
Failure
|
||||
Unknown
|
||||
)
|
||||
|
||||
func (s Status) String() string {
|
||||
func (s Result) String() string {
|
||||
switch s {
|
||||
case Success:
|
||||
return "success"
|
||||
|
@@ -32,7 +32,7 @@ func New() TCPProber {
|
||||
|
||||
type TCPProber struct{}
|
||||
|
||||
func (pr TCPProber) Probe(host string, port int, timeout time.Duration) (probe.Status, error) {
|
||||
func (pr TCPProber) Probe(host string, port int, timeout time.Duration) (probe.Result, error) {
|
||||
return DoTCPProbe(net.JoinHostPort(host, strconv.Itoa(port)), timeout)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func (pr TCPProber) Probe(host string, port int, timeout time.Duration) (probe.S
|
||||
// If the socket can be opened, it returns Success
|
||||
// If the socket fails to open, it returns Failure.
|
||||
// This is exported because some other packages may want to do direct TCP probes.
|
||||
func DoTCPProbe(addr string, timeout time.Duration) (probe.Status, error) {
|
||||
func DoTCPProbe(addr string, timeout time.Duration) (probe.Result, error) {
|
||||
conn, err := net.DialTimeout("tcp", addr, timeout)
|
||||
if err != nil {
|
||||
return probe.Failure, nil
|
||||
|
@@ -31,7 +31,7 @@ import (
|
||||
func TestTcpHealthChecker(t *testing.T) {
|
||||
prober := New()
|
||||
tests := []struct {
|
||||
expectedStatus probe.Status
|
||||
expectedStatus probe.Result
|
||||
usePort bool
|
||||
expectError bool
|
||||
}{
|
||||
|
Reference in New Issue
Block a user