feat: refactor Service interface to replace Health() with Status() (string, error) for human-readable diagnostics (by AI)
This commit is contained in:
parent
674ec88117
commit
4bf0ed1d4e
@ -12,8 +12,8 @@ type Service interface {
|
|||||||
Start(ctx context.Context, logger *log.Logger) error
|
Start(ctx context.Context, logger *log.Logger) error
|
||||||
// Stop stops the service. It should block until the service is cleaned up.
|
// Stop stops the service. It should block until the service is cleaned up.
|
||||||
Stop(ctx context.Context) error
|
Stop(ctx context.Context) error
|
||||||
// Health returns the health status of the service.
|
// Status returns the current status and health of the service.
|
||||||
Health() error
|
Status() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reloader defines an optional interface for services that support configuration reloading.
|
// Reloader defines an optional interface for services that support configuration reloading.
|
||||||
|
|||||||
13
starter.go
13
starter.go
@ -367,11 +367,16 @@ func getInternalStatus() string {
|
|||||||
|
|
||||||
for _, p := range priorities {
|
for _, p := range priorities {
|
||||||
for _, ms := range services[p] {
|
for _, ms := range services[p] {
|
||||||
status := shell.Green("OK")
|
statusMsg, err := ms.svc.Status()
|
||||||
if err := ms.svc.Health(); err != nil {
|
indicator := shell.Green("OK")
|
||||||
status = shell.Red(fmt.Sprintf("FAIL (%v)", err))
|
if err != nil {
|
||||||
|
indicator = shell.Red(fmt.Sprintf("FAIL (%v)", err))
|
||||||
|
}
|
||||||
|
if statusMsg != "" {
|
||||||
|
out += fmt.Sprintf("[%d] %-20s %s (%s)\n", p, ms.Name, indicator, statusMsg)
|
||||||
|
} else {
|
||||||
|
out += fmt.Sprintf("[%d] %-20s %s\n", p, ms.Name, indicator)
|
||||||
}
|
}
|
||||||
out += fmt.Sprintf("[%d] %-20s %s\n", p, ms.Name, status)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user