Skip to content
Snippets Groups Projects

Initial implementation of an elasticsearch indexer in Go

Merged Nick Thomas requested to merge 1-initial-implementation into master
All threads resolved!
2 files
+ 63
12
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 12
12
@@ -54,19 +54,9 @@ func FromEnv(projectID string) (*Client, error) {
}
func NewClient(config *Config) (*Client, error) {
opts := []elastic.ClientOptionFunc{
elastic.SetURL(config.URL...),
elastic.SetSniff(false), // For now. Move back to AWS-only later
}
// Sniffer should look for HTTPS URLs if at-least-one initial URL is HTTPS
for _, url := range config.URL {
if strings.HasPrefix(url, "https:") {
opts = append(opts, elastic.SetScheme("https"))
break
}
}
var opts []elastic.ClientOptionFunc
// AWS settings have to come first or they override custom URL, etc
if config.AWS {
credentials := credentials.NewStaticCredentials(config.AccessKey, config.SecretKey, "")
signer := v4.NewSigner(credentials)
@@ -78,6 +68,16 @@ func NewClient(config *Config) (*Client, error) {
opts = append(opts, elastic.SetHttpClient(awsClient))
}
// Sniffer should look for HTTPS URLs if at-least-one initial URL is HTTPS
for _, url := range config.URL {
if strings.HasPrefix(url, "https:") {
opts = append(opts, elastic.SetScheme("https"))
break
}
}
opts = append(opts, elastic.SetURL(config.URL...), elastic.SetSniff(false))
client, err := elastic.NewClient(opts...)
if err != nil {
return nil, err
Loading