Răsfoiți Sursa

es全局限制

xuzhiheng 2 ani în urmă
părinte
comite
ab6e692623
1 a modificat fișierele cu 12 adăugiri și 5 ștergeri
  1. 12 5
      src/client/customerRule.go

+ 12 - 5
src/client/customerRule.go

@@ -258,17 +258,22 @@ func (c *CustomerRule) ProductData() {
 		// var n int
 		// 小于1000的直接查
 		// if totalCount < 1000 {
+		var times = 0
+		var times2 = 0
 		for {
 			listLen := redis.GetInt("session", "es_status")
 			if listLen == 0 {
 				log.Println("es空闲!")
 				break
-			} else if listLen == 1 || listLen == 2 {
-				log.Println("系统繁忙,请稍后再试 ", listLen)
+			} else if times > 10 {
+				err = errors.New("系统繁忙,请稍后再试")
+				break
+			} else {
+				log.Println("es繁忙,", listLen)
 			}
+			times += 2
 			time.Sleep(2 * time.Second)
 		}
-		var times = 0
 		for {
 			listLens := int(redis.LLEN("datag", "jyqyfw_es_query"))
 			if listLens < 2 {
@@ -276,11 +281,13 @@ func (c *CustomerRule) ProductData() {
 				err, count = UtilEsFind1(*tag)
 				redis.LPOP("datag", "jyqyfw_es_query")
 				break
-			} else if times > 10 {
+			} else if times2 > 10 {
 				err = errors.New("系统繁忙,请稍后再试")
 				break
+			} else {
+				log.Println("企业级服务es进程数过多,", listLens)
 			}
-			times += 2
+			times2 += 2
 			time.Sleep(2 * time.Second)
 		}