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
+ 58
2
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 6
1
@@ -3,6 +3,7 @@ package elastic
import (
"context"
"fmt"
"net/http"
"os"
"strings"
@@ -60,7 +61,7 @@ func NewClient(config *Config) (*Client, error) {
if config.AWS {
credentials := credentials.NewStaticCredentials(config.AccessKey, config.SecretKey, "")
signer := v4.NewSigner(credentials)
awsClient, err := aws_signing_client.New(signer, nil, "es", config.Region)
awsClient, err := aws_signing_client.New(signer, &http.Client{}, "es", config.Region)
if err != nil {
return nil, err
}
@@ -108,6 +109,10 @@ func (c *Client) Flush() error {
return c.bulk.Flush()
}
func (c *Client) Close() {
c.Client.Stop()
}
func (c *Client) Index(id string, thing interface{}) {
req := elastic.NewBulkIndexRequest().
Index(c.IndexName).
Loading