소스 검색

Merge commit '4289580ee0616511a199afc72f0687fb18bb5160' into v1

* commit '4289580ee0616511a199afc72f0687fb18bb5160':
  添加用户密码
Jianghan 2 년 전
부모
커밋
e0adaeae8a
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      elastic/elasticSim.go

+ 3 - 1
elastic/elasticSim.go

@@ -22,6 +22,8 @@ type Elastic struct {
 	lastTime     int64
 	lastTimeLock sync.Mutex
 	ntimeout     int
+	Username     string
+	Password     string
 }
 
 func (e *Elastic) InitElasticSize() {
@@ -30,7 +32,7 @@ func (e *Elastic) InitElasticSize() {
 		e.Addrs = append(e.Addrs, s)
 	}
 	for i := 0; i < e.I_size; i++ {
-		client, _ := es.NewClient(es.SetURL(e.Addrs...), es.SetMaxRetries(2), es.SetSniff(false))
+		client, _ := es.NewClient(es.SetURL(e.Addrs...), es.SetBasicAuth(e.Username, e.Password), es.SetMaxRetries(2), es.SetSniff(false))
 		e.Pool <- client
 	}
 }