Esempio n. 1
0
func apiGetProxyList(param martini.Params) (int, string) {
	conn := CreateCoordConn()
	defer conn.Close()

	proxies, err := models.ProxyList(conn, globalEnv.ProductName(), nil)
	if err != nil {
		log.Warning(err)
		return 500, err.Error()
	}

	b, err := json.MarshalIndent(proxies, " ", "  ")
	return 200, string(b)
}
Esempio n. 2
0
func getAllProxyOps() int64 {
	conn := CreateCoordConn()
	defer conn.Close()

	proxies, err := models.ProxyList(conn, globalEnv.ProductName(), nil)
	if err != nil {
		log.Warning(err)
		return -1
	}

	var total int64
	for _, p := range proxies {
		i, err := p.Ops()
		if err != nil {
			log.Warning(err)
		}
		total += i
	}
	return total
}
Esempio n. 3
0
// for debug
func getAllProxyDebugVars() map[string]map[string]interface{} {
	conn := CreateCoordConn()
	defer conn.Close()

	proxies, err := models.ProxyList(conn, globalEnv.ProductName(), nil)
	if err != nil {
		log.Warning(err)
		return nil
	}

	ret := make(map[string]map[string]interface{})
	for _, p := range proxies {
		m, err := p.DebugVars()
		if err != nil {
			log.Warning(err)
		}
		ret[p.ID] = m
	}
	return ret
}