add Probers to Probe pkgs.

This commit is contained in:
Mike Danese
2015-01-27 10:00:21 -08:00
parent a298402bd4
commit 6eb0b89cbd
7 changed files with 38 additions and 11 deletions

View File

@@ -25,7 +25,13 @@ import (
"github.com/golang/glog"
)
func Probe(host string, port int) (probe.Status, error) {
func New() TCPProber {
return TCPProber{}
}
type TCPProber struct{}
func (pr TCPProber) Probe(host string, port int) (probe.Status, error) {
return DoTCPProbe(net.JoinHostPort(host, strconv.Itoa(port)))
}

View File

@@ -28,6 +28,7 @@ import (
)
func TestTcpHealthChecker(t *testing.T) {
prober := New()
tests := []struct {
expectedStatus probe.Status
usePort bool
@@ -58,7 +59,7 @@ func TestTcpHealthChecker(t *testing.T) {
if !test.usePort {
p = -1
}
status, err := Probe(host, p)
status, err := prober.Probe(host, p)
if status != test.expectedStatus {
t.Errorf("expected: %v, got: %v", test.expectedStatus, status)
}