示例#1
0
文件: manager.go 项目: vys/doozerd
func getAddrs(g store.Getter, cals []string) (a []*net.UDPAddr) {
	a = make([]*net.UDPAddr, len(cals))
	var i int
	var err error
	for _, id := range cals {
		s := store.GetString(g, "/ctl/node/"+id+"/addr")
		a[i], err = net.ResolveUDPAddr("udp", s)
		if err != nil {
			log.Println(err)
		} else {
			i++
		}
	}
	return a[:i]
}
示例#2
0
文件: manager.go 项目: vys/doozerd
func getCals(g store.Getter) []string {
	ents := store.Getdir(g, "/ctl/cal")
	cals := make([]string, len(ents))

	i := 0
	for _, cal := range ents {
		id := store.GetString(g, "/ctl/cal/"+cal)
		if id != "" {
			cals[i] = id
			i++
		}
	}

	cals = cals[0:i]
	sort.Strings(cals)

	return cals
}