当前位置: 首页>>代码示例>>Golang>>正文


Golang Store.ListAssignedPools方法代码示例

本文整理汇总了Golang中github.com/litl/galaxy/config.Store.ListAssignedPools方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.ListAssignedPools方法的具体用法?Golang Store.ListAssignedPools怎么用?Golang Store.ListAssignedPools使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/litl/galaxy/config.Store的用法示例。


在下文中一共展示了Store.ListAssignedPools方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: pruneShuttleBackends

func pruneShuttleBackends(configStore *config.Store, env, shuttleAddr string) {
	if client == nil {
		return
	}

	config, err := client.GetConfig()
	if err != nil {
		log.Errorf("ERROR: Unable to get shuttle config: %s", err)
		return
	}

	registrations, err := configStore.ListRegistrations(env)
	if err != nil {
		log.Errorf("ERROR: Unable to list registrations: %s", err)
		return
	}

	// FIXME: THERE SHOULD HAVE BEEN AN ERROR IF `len(registrations) == 0` IS WRONG!
	if len(registrations) == 0 {
		// If there are no registrations, skip pruning it because we might be in a bad state and
		// don't want to inadvertently unregister everything.  Shuttle will handle the down
		// nodes if they are really down.
		return
	}

	for _, service := range config.Services {

		app, err := configStore.GetApp(service.Name, env)
		if err != nil {
			log.Errorf("ERROR: Unable to load app %s: %s", app, err)
			continue
		}

		pools, err := configStore.ListAssignedPools(env, service.Name)
		if err != nil {
			log.Errorf("ERROR: Unable to list pool assignments for %s: %s", service.Name, err)
			continue
		}

		if app == nil || len(pools) == 0 {
			err := client.RemoveService(service.Name)
			if err != nil {
				log.Errorf("ERROR: Unable to remove service %s from shuttle: %s", service.Name, err)
			}
			log.Printf("Unregisterred shuttle service %s", service.Name)
			continue
		}

		for _, backend := range service.Backends {
			backendExists := false
			for _, r := range registrations {
				if backend.Name == r.ContainerID[0:12] {
					backendExists = true
					break
				}
			}

			if !backendExists {
				err := client.RemoveBackend(service.Name, backend.Name)
				if err != nil {
					log.Errorf("ERROR: Unable to remove backend %s from shuttle: %s", backend.Name, err)
				}
				log.Printf("Unregisterred shuttle backend %s", backend.Name)
			}
		}
	}
}
开发者ID:zombor,项目名称:galaxy,代码行数:67,代码来源:shuttle.go


注:本文中的github.com/litl/galaxy/config.Store.ListAssignedPools方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。