Files

33 lines
547 B
Go
Raw Normal View History

2021-11-02 09:43:19 +08:00
package es
import "github.com/elastic/go-elasticsearch/v7"
type Es struct{ *EsConfig }
type EsConfig struct {
Address []string
}
type EsServer func(*EsConfig) *Es
var esClient = new(elasticsearch.Client)
func (this *Es) Run() {
obj := elasticsearch.Config{
Addresses: this.Address,
Username: "",
Password: "",
}
var err error
if esClient, err = elasticsearch.NewClient(obj); err != nil {
panic("Elasticsearch Error " + err.Error())
}
}
func NewEs() EsServer {
return func(config *EsConfig) *Es {
return &Es{config}
}
}