Skip to content

Commit

Permalink
Read the categories once per updateCachedHealth call
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamas Molnar committed Feb 13, 2018
1 parent 9181b39 commit a30f891
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cachingController.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ func (c *healthCheckController) collectChecksFromCachesFor(categories map[string

func (c *healthCheckController) updateCachedHealth(services map[string]service, categories map[string]category) {
// adding new services, not touching existing
refreshPeriod := findShortestPeriod(categories)
categories, err := c.healthCheckService.getCategories()
if err != nil {
warnLogger.Printf("Cannot read categories: [%v]\n Using minimum refresh period for services", err)
}
for _, service := range services {
if mService, ok := c.measuredServices[service.name]; !ok || !reflect.DeepEqual(service, c.measuredServices[service.name].service) {
if ok {
mService.cachedHealth.terminate <- true
}
newMService := newMeasuredService(service)
c.measuredServices[service.name] = newMService
refreshPeriod := findShortestPeriod(categories)
categories, err := c.healthCheckService.getCategories()
if err != nil {
warnLogger.Printf("Cannot read categories: [%v]\n Using minimum refresh period for service [%s]", err, service.name)
} else {
if categories != nil {
for _, category := range categories {
if isStringInSlice(service.name, category.services) {
refreshPeriod = category.refreshPeriod
Expand Down

0 comments on commit a30f891

Please sign in to comment.