Procházet zdrojové kódy

feat:初始化新es

wangshan před 1 rokem
rodič
revize
438d017d0f
1 změnil soubory, kde provedl 20 přidání a 2 odebrání
  1. 20 2
      public/db.go

+ 20 - 2
public/db.go

@@ -35,8 +35,9 @@ type dbConf struct {
 		Seo     *mgoConf
 	}
 	Elasticsearch struct {
-		Main *esConf
-		Doc  *esConf
+		Main  *esConf
+		Doc   *esConf
+		Other *esConf
 	}
 	Redis struct {
 		Main  *redisConf
@@ -79,6 +80,10 @@ type mysqlConf struct {
 	MaxIdleConns int
 }
 
+var (
+	Other elastic.Es
+)
+
 func init() {
 	util.ReadConfig("./db.json", &DbConf)
 	if DbConf != nil {
@@ -93,6 +98,19 @@ func init() {
 			log.Println("初始化 doc elasticsearch")
 		}
 
+		if DbConf.Elasticsearch.Other != nil {
+			Other = &elastic.EsV7{
+				Address:  DbConf.Elasticsearch.Other.Address,
+				UserName: DbConf.Elasticsearch.Other.UserName,
+				Password: DbConf.Elasticsearch.Other.Password,
+				Size:     DbConf.Elasticsearch.Other.Size,
+			}
+			Other.Init()
+			//es.InitElasticSizeByAuth(DbConf.Elasticsearch.Other.Address, DbConf.Elasticsearch.Other.Size,
+			//	DbConf.Elasticsearch.Other.UserName, DbConf.Elasticsearch.Other.Password)
+			log.Println("初始化 Other elasticsearch")
+		}
+
 		//初始化redis
 		if DbConf.Redis.Main != nil {
 			log.Println("初始化 redis")