modify elastic urls from string to array.

This commit is contained in:
ruitao.liu 2020-09-10 16:24:09 +08:00
parent 72f9d7f047
commit 719dc43af1
2 changed files with 7 additions and 8 deletions

View file

@ -176,7 +176,11 @@ database = "seaweedfs"
[elastic7] [elastic7]
enabled = false enabled = false
servers = "http://localhost1:9200,http://localhost2:9200,http://localhost3:9200" servers = [
"http://localhost1:9200",
"http://localhost2:9200",
"http://localhost3:9200",
]
username = "" username = ""
password = "" password = ""
sniff_enabled = false sniff_enabled = false

View file

@ -68,13 +68,8 @@ func (store *ElasticStore) Initialize(configuration weed_util.Configuration, pre
} }
func (store *ElasticStore) initialize(configuration weed_util.Configuration, prefix string) (options []elastic.ClientOptionFunc) { func (store *ElasticStore) initialize(configuration weed_util.Configuration, prefix string) (options []elastic.ClientOptionFunc) {
configuration.SetDefault(prefix+"servers", "http://localhost:9200") servers := configuration.GetStringSlice(prefix + "servers")
servers := configuration.GetString(prefix + "servers") options = append(options, elastic.SetURL(servers...))
url := make([]string, 0)
for _, v := range strings.Split(servers, ",") {
url = append(url, v)
}
options = append(options, elastic.SetURL(url...))
username := configuration.GetString(prefix + "username") username := configuration.GetString(prefix + "username")
password := configuration.GetString(prefix + "password") password := configuration.GetString(prefix + "password")
if username != "" && password != "" { if username != "" && password != "" {