Skip to content

Commit

Permalink
Fixed elastic config parsing and introduced optional disableHealthCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
spmistry committed Dec 8, 2020
1 parent e336c77 commit cc95e83
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions common/elasticsearch/client_v6.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func NewV6Client(
if connectConfig.DisableSniff {
clientOptFuncs = append(clientOptFuncs, elastic.SetSniff(false))
}
if connectConfig.DisableHealthCheck {
clientOptFuncs = append(clientOptFuncs, elastic.SetHealthcheck(false))
}
client, err := elastic.NewClient(clientOptFuncs...)
if err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions common/elasticsearch/client_v7.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func NewV7Client(
if connectConfig.DisableSniff {
clientOptFuncs = append(clientOptFuncs, elastic.SetSniff(false))
}
if connectConfig.DisableHealthCheck {
clientOptFuncs = append(clientOptFuncs, elastic.SetHealthcheck(false))
}
client, err := elastic.NewClient(clientOptFuncs...)
if err != nil {
return nil, err
Expand Down
14 changes: 8 additions & 6 deletions common/service/config/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ import (
// ElasticSearchConfig for connecting to ElasticSearch
type (
ElasticSearchConfig struct {
URL url.URL `yaml:url` //nolint:govet
Indices map[string]string `yaml:indices` //nolint:govet
URL url.URL `yaml:"url"` //nolint:govet
Indices map[string]string `yaml:"indices"` //nolint:govet
// supporting v6 and v7. Default to v6 if empty.
Version string `yaml:version` //nolint:govet
Version string `yaml:"version"` //nolint:govet
// optional username to communicate with ElasticSearch
Username string `yaml:username` //nolint:govet
Username string `yaml:"username"` //nolint:govet
// optional password to communicate with ElasticSearch
Password string `yaml:password` //nolint:govet
Password string `yaml:"password"` //nolint:govet
// optional to disable sniff, according to issues on Github,
// Sniff could cause issue like "no Elasticsearch node available"
DisableSniff bool `yaml:disableSniff`
DisableSniff bool `yaml:"disableSniff"`
// optional to disable health check
DisableHealthCheck bool `yaml:"disableHealthCheck"`
}
)

Expand Down

0 comments on commit cc95e83

Please sign in to comment.