elastic.go 411 B

1234567891011121314151617181920
  1. package utils
  2. import (
  3. "github.com/olivere/elastic/v7"
  4. )
  5. var EsClient *elastic.Client
  6. func initEs() {
  7. client, err := elastic.NewClient(
  8. elastic.SetURL(ES_URL),
  9. elastic.SetBasicAuth(ES_USERNAME, ES_PASSWORD),
  10. elastic.SetSniff(false))
  11. EsClient = client
  12. if err != nil {
  13. panic("ElasticSearch连接失败,Err:" + err.Error())
  14. //go alarm_msg.SendAlarmMsg("ElasticSearch连接失败", 2)
  15. }
  16. return
  17. }