From 2dd1fa03c93b400ff1e8e4f44e27387965e4daa7 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期四, 19 九月 2019 17:23:59 +0800 Subject: [PATCH] get ip,port config from db,update realtime --- controllers/es.go | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/controllers/es.go b/controllers/es.go index 46cb2f5..a2c591b 100644 --- a/controllers/es.go +++ b/controllers/es.go @@ -2,11 +2,13 @@ import ( "basic.com/dbapi.git" + "basic.com/valib/logger.git" "fmt" "github.com/gin-gonic/gin" "math/rand" "strconv" "strings" + "webserver/cache" "webserver/extend/code" "webserver/extend/config" "webserver/extend/esutil" @@ -40,18 +42,20 @@ //浜屾鎼滅储鍜屾帓搴� twiceM := GetCompareDataTwice(co,searchBody) util.ResponseFormat(c,code.Success,twiceM) + return } else { m :=make(map[string]interface{},0) m["compareNum"] = searchBody.CompareNum m["total"] = 0 - m["totalList"] = []service.CompareResult{} + m["totalList"] = []CompareResult{} util.ResponseFormat(c,code.CompareResultGone,m) + return } } m :=make(map[string]interface{},0) m["compareNum"] = searchBody.CompareNum m["total"] = 0 - m["totalList"] = []service.CompareResult{} + m["totalList"] = []CompareResult{} util.ResponseFormat(c,code.CompareResultGone,m) } @@ -101,7 +105,12 @@ esSize := strconv.Itoa(webSize) //浣跨敤es搴曞眰鏈哄埗澶勭悊鍒嗛〉 //璇锋眰澶� - url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + + localConf, err2 := cache.GetServerInfo() + if err2 !=nil || localConf.AlarmIp == "" { + logger.Debug("localConfig is wrong!!!") + return nil + } + url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + "/" + index + "/_search?search_type=dfs_query_then_fetch" var setApi dbapi.SysSetApi -- Gitblit v1.8.0