|
@@ -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
|
|
|
}
|
|
|
}
|