Пример #1
0
func (store *RealStore) GetDesiredState() (results map[string]models.DesiredAppState, err error) {
	t := time.Now()

	results = make(map[string]models.DesiredAppState)

	node, err := store.adapter.ListRecursively(store.SchemaRoot() + "/apps/desired")

	if err == storeadapter.ErrorKeyNotFound {
		return results, nil
	} else if err != nil {
		return results, err
	}

	for _, desiredNode := range node.ChildNodes {
		components := strings.Split(desiredNode.Key, "/")
		appGuidVersion := strings.Split(components[len(components)-1], ",")

		desiredState, err := models.NewDesiredAppStateFromCSV(appGuidVersion[0], appGuidVersion[1], desiredNode.Value)
		if err != nil {
			return results, err
		}

		results[desiredState.StoreKey()] = desiredState
	}

	store.logger.Debug(fmt.Sprintf("Get Duration Desired"), map[string]string{
		"Number of Items": fmt.Sprintf("%d", len(results)),
		"Duration":        fmt.Sprintf("%.4f seconds", time.Since(t).Seconds()),
	})
	return results, nil
}
Пример #2
0
func (store *RealStore) getDesiredStateForApp(appGuid string, appVersion string) (desired models.DesiredAppState, err error) {
	node, err := store.adapter.Get(store.SchemaRoot() + "/apps/desired/" + store.AppKey(appGuid, appVersion))
	if err == storeadapter.ErrorKeyNotFound {
		return desired, nil
	} else if err != nil {
		return desired, err
	}

	return models.NewDesiredAppStateFromCSV(appGuid, appVersion, node.Value)
}