Skip to content

Commit

Permalink
Populate existing clusterConfig.Endpoint field and refactor NewEsProb…
Browse files Browse the repository at this point in the history
…e to use it

Allows direct usage of API without having to use the ES API go package,
if needed.
  • Loading branch information
eappere committed Sep 27, 2024
1 parent 3420de1 commit 797e6f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions probe/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ type EsProbe struct {
controlChan chan bool
}

func NewEsProbe(clusterName string, endpoint string, clusterConfig common.Cluster, config *common.Config, consulClient *api.Client, controlChan chan bool) (EsProbe, error) {
func NewEsProbe(clusterName string, clusterConfig common.Cluster, config *common.Config, consulClient *api.Client, controlChan chan bool) (EsProbe, error) {
var allEverKnownEsNodes []string
esNodesList, err := common.DiscoverNodesForService(consulClient, clusterConfig.Name)
if err != nil {
return EsProbe{}, errors.Wrapf(err, "Impossible to discover ES nodes during bootstrap for cluster %s", clusterName)
}
allEverKnownEsNodes = common.UpdateEverKnownNodes(allEverKnownEsNodes, esNodesList)

client, err := initEsClient(clusterConfig.Scheme, endpoint, config.ElasticsearchUser, config.ElasticsearchPassword)
client, err := initEsClient(clusterConfig.Scheme, clusterConfig.Endpoint, config.ElasticsearchUser, config.ElasticsearchPassword)
if err != nil {
return EsProbe{}, errors.Wrapf(err, "Failed to init elasticsearch client for cluster %s", clusterName)
}
Expand Down
4 changes: 3 additions & 1 deletion watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ func (w *Watcher) createNewEsProbes(servicesToAdd map[string]common.Cluster) {
continue
}

clusterConfig.Endpoint = endpoint

probeChan = make(chan bool)
esProbe, err := probe.NewEsProbe(cluster, endpoint, clusterConfig, w.config, w.consulClient, probeChan)
esProbe, err := probe.NewEsProbe(cluster, clusterConfig, w.config, w.consulClient, probeChan)

if err != nil {
log.Errorf("Error while creating probe: %s", err.Error())
Expand Down

0 comments on commit 797e6f6

Please sign in to comment.