func (analyzer *Analyzer) populateActualState() error { nodes, err := analyzer.fetchNodesUnderDir("/actual") if err != nil { return err } analyzer.runningByApp = make(map[string]int, 0) analyzer.actualStates = make([]models.InstanceHeartbeat, len(nodes)) for i, node := range nodes { analyzer.actualStates[i], err = models.NewInstanceHeartbeatFromJSON(node.Value) if err != nil { return err } key := analyzer.actualStates[i].AppGuid + "-" + analyzer.actualStates[i].AppVersion value, ok := analyzer.runningByApp[key] if ok { analyzer.runningByApp[key] = value + 1 } else { analyzer.runningByApp[key] = 1 } } return nil }
func (store *RealStore) GetActualState() ([]models.InstanceHeartbeat, error) { nodes, err := store.fetchNodesUnderDir("/actual") if err != nil { return []models.InstanceHeartbeat{}, err } instanceHeartbeats := make([]models.InstanceHeartbeat, len(nodes)) for i, node := range nodes { instanceHeartbeats[i], err = models.NewInstanceHeartbeatFromJSON(node.Value) if err != nil { return []models.InstanceHeartbeat{}, err } } return instanceHeartbeats, nil }