Skip to content

Merge duplicate pingEndpoint/checkEndpointHealth in status.go #102

@ewega

Description

@ewega

Problem

status.go has two near-identical functions:

  • pingEndpoint(url, kind) string — returns emoji (✅, ❌, ⚠️)
  • checkEndpointHealth(url, kind) bool — returns true/false

Both build the check URL the same way (append /ping for backend, /api/health for Grafana), create an http.Client with the same timeout (8s), make the same GET request, and check the same status code range. The only difference is the return type.

Fix

Refactor into one function and have the other call it:

`go
func checkEndpointHealth(url string, kind string) bool {
// ... shared logic ...
}

func pingEndpoint(url string, kind string) string {
if checkEndpointHealth(url, kind) {
return "✅"
}
return "❌"
}
`

(The ⚠️ case for non-2xx status codes would need a slightly different signature, but the core logic is shared.)

Acceptance Criteria

  • One shared implementation for endpoint health checking
  • status command output unchanged (same emojis, same JSON fields)
  • go build ./... and go test ./... pass

Metadata

Metadata

Assignees

Labels

refactorCode restructure, no behavior change

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions