Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pkg/services/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,26 @@ func (c *HealthChecker) Register(service HealthReporter) error {
}

c.servicesMu.Lock()
defer c.servicesMu.Unlock()
if testing.Testing() {
if orig, ok := c.services[name]; ok {
panic(fmt.Errorf("duplicate name %q: service names must be unique: types %T & %T", name, service, orig))
}
}
c.services[name] = service
c.servicesMu.Unlock()

// Populate health state directly for the new service so it is
// visible immediately without waiting for the next polling tick.
ready := service.Ready()
report := service.HealthReport()

c.stateMu.Lock()
c.ready[name] = ready
for n, err := range report {
c.healthy[n] = err
}
c.stateMu.Unlock()

return nil
}

Expand Down
Loading