TP-55555 clean up
This commit is contained in:
@@ -4,6 +4,7 @@ type ElasticConfig struct {
|
||||
Addresses []string
|
||||
Username string
|
||||
Password string
|
||||
APIKey string
|
||||
}
|
||||
|
||||
func getElasticConfig() *ElasticConfig {
|
||||
@@ -11,5 +12,6 @@ func getElasticConfig() *ElasticConfig {
|
||||
Addresses: getStringSlice("elastic.addresses", true),
|
||||
Username: getString("elastic.username", true),
|
||||
Password: getString("elastic.password", true),
|
||||
APIKey: getString("elastic.api_key", true),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,13 +66,12 @@ DocumentService:
|
||||
mock:
|
||||
generate_token: DOCUMENT_SERVICE_MOCK_GENERATE_TOKEN
|
||||
|
||||
|
||||
elastic:
|
||||
addresses: http://localhost:9200
|
||||
username: aa
|
||||
password: aa
|
||||
error:
|
||||
index: cybertron
|
||||
addresses: https://localhost:9200
|
||||
username: elastic
|
||||
password: 9457611267
|
||||
index: cybertron
|
||||
api_key: Uk1ScGFKRUJYaHF5bTJkOWRuUmY6eWhIRGpFc1lUak9sRjcxY0taMzUydw==
|
||||
|
||||
aws:
|
||||
region: ap-south-1
|
||||
|
||||
1
go.mod
1
go.mod
@@ -10,7 +10,6 @@ require (
|
||||
github.com/gin-contrib/zap v0.2.0
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/golang-migrate/migrate/v4 v4.17.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/prometheus/client_golang v1.19.1
|
||||
github.com/spf13/cobra v1.8.0
|
||||
github.com/spf13/viper v1.17.0
|
||||
|
||||
@@ -16,8 +16,7 @@ type ElasticSearchClient struct {
|
||||
func NewElasticClient(elasticConfig configs.ElasticConfig) (*ElasticSearchClient, error) {
|
||||
cfg := elasticsearch8.Config{
|
||||
Addresses: elasticConfig.Addresses,
|
||||
Username: elasticConfig.Username,
|
||||
Password: elasticConfig.Password,
|
||||
APIKey: elasticConfig.APIKey,
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
@@ -26,6 +25,9 @@ func NewElasticClient(elasticConfig configs.ElasticConfig) (*ElasticSearchClient
|
||||
}
|
||||
|
||||
client, err := elasticsearch8.NewTypedClient(cfg)
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating the client: %s", err)
|
||||
}
|
||||
return &ElasticSearchClient{
|
||||
client: client,
|
||||
}, err
|
||||
@@ -34,9 +36,9 @@ func NewElasticClient(elasticConfig configs.ElasticConfig) (*ElasticSearchClient
|
||||
func (el *ElasticSearchClient) IndexDocument(document interface{}) {
|
||||
_, err := el.client.Index("cybertron").
|
||||
Request(document).
|
||||
Do(context.TODO())
|
||||
Do(context.Background())
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatalf("Error ingesting the doc: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user