type Checker interface { CheckHealth(strict bool) error } type entry struct { checker Checker } // Service provides health check HTTP handlers. type Service struct { entries []entry } // Add appends for Checker. func (s *Service) Add(name string, c Checker) { // … appends Checker into entries. }
// CheckReadiness returns error if any checker is unhealthy. func (s *Service) CheckReadiness(strict bool) error { for _, e := range s.entries { if err := e.checker.CheckHealth(strict); err != nil { ... } } return nil }