Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian-panek-vmltech committed Jan 16, 2024
1 parent 54cd78b commit 751b8e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,20 +424,19 @@ func (c ReachableHTTPChecker) Spec() CheckSpec {
}

func (c ReachableHTTPChecker) Check(_ CheckContext, instance Instance) CheckResult {
address := fmt.Sprintf("%s:%s", instance.http.Hostname(), instance.http.Port())
reachable, _ := netx.IsReachable(instance.http.Hostname(), instance.http.Port(), c.Timeout)
if c.Reachable == reachable {
return CheckResult{ok: true}
}
if reachable {
return CheckResult{
ok: false,
message: fmt.Sprintf("still reachable: %s", address),
message: fmt.Sprintf("still reachable: %s", instance.http.Address()),
}
}
return CheckResult{
ok: false,
message: fmt.Sprintf("not reachable (%s)", address),
message: fmt.Sprintf("not reachable (%s)", instance.http.Address()),
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (h *HTTP) Hostname() string {
return urlConfig.Hostname()
}

func (h *HTTP) Address() string {
return fmt.Sprintf("%s:%s", h.Hostname(), h.Port())
}

func (h *HTTP) BaseURL() string {
return h.baseURL
}

0 comments on commit 751b8e2

Please sign in to comment.