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) }
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 }
// 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 }