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 --- service/EnableStatusControlService.go | 57 +++++++++++++++++++++++++++++++++------------------------ 1 files changed, 33 insertions(+), 24 deletions(-) diff --git a/service/EnableStatusControlService.go b/service/EnableStatusControlService.go index 7206b0b..045f9b9 100644 --- a/service/EnableStatusControlService.go +++ b/service/EnableStatusControlService.go @@ -2,24 +2,28 @@ import ( "basic.com/dbapi.git" - "basic.com/pubsub/protomsg.git" + "basic.com/valib/logger.git" "encoding/json" "fmt" "strconv" "strings" "time" - "webserver/discovery" + "webserver/cache" "webserver/extend/config" "webserver/extend/esutil" - "webserver/extend/logger" ) func GetVerificationData() []map[string]interface{} { - 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)) + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/_search" var setApi dbapi.SysSetApi _, sysconf := setApi.GetServerInfo() - jsonDsl := `{ + jsonDSL := `{ "query": { "bool": { "filter": [{ @@ -38,7 +42,7 @@ "size": 10000 } ` - buf, err := esutil.EsReq("POST", url, []byte(jsonDsl)) + buf, err := esutil.EsReq("POST", url, []byte(jsonDSL)) if err != nil { logger.Debug(err) } @@ -85,7 +89,12 @@ status = 1 } enable := strconv.Itoa(status) - url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + + localConf, err2 := cache.GetServerInfo() + if err2 !=nil || localConf.AlarmIp == "" { + logger.Debug("localConfig is wrong!!!") + return "localConf wrong" + } + url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/_update_by_query?refresh" jsonDsl := ` { @@ -119,23 +128,23 @@ } if middle > 0 { logger.Debug("淇敼鎴愬姛") - if flag {//鐢熸晥鐨� - discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ - Type: protomsg.EsCacheChanged_T_DbTable, - PersonId: "", - TableId: id, - Feature: "", - Action: protomsg.DbAction_Insert, - }) - } else {//澶辨晥鐨� - discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ - Type: protomsg.EsCacheChanged_T_DbTable, - PersonId: "", - TableId: id, - Feature: "", - Action: protomsg.DbAction_Insert, - }) - } + //if flag {//鐢熸晥鐨� + // discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ + // Type: protomsg.EsCacheChanged_T_DbTable, + // PersonId: "", + // TableId: id, + // Feature: "", + // Action: protomsg.DbAction_Insert, + // }) + //} else {//澶辨晥鐨� + // discovery.AddDbMessage(&protomsg.EsPersonCacheChange{ + // Type: protomsg.EsCacheChanged_T_DbTable, + // PersonId: "", + // TableId: id, + // Feature: "", + // Action: protomsg.DbAction_Insert, + // }) + //} message = "淇敼鎴愬姛" } return message -- Gitblit v1.8.0