feat(health): add health check detail to health api

This commit is contained in:
yusing
2025-05-05 13:27:00 +08:00
parent 2cec88d3ce
commit c55c6c84bc
5 changed files with 33 additions and 0 deletions

View File

@@ -266,6 +266,12 @@ func (lb *LoadBalancer) Status() health.Status {
return status
}
// Detail implements health.HealthMonitor.
func (lb *LoadBalancer) Detail() string {
_, numHealthy := lb.status()
return fmt.Sprintf("%d/%d servers are healthy", numHealthy, lb.pool.Size())
}
func (lb *LoadBalancer) status() (status health.Status, numHealthy int) {
if lb.pool.Size() == 0 {
return health.StatusUnknown, 0