Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit eacb06f

Browse files
author
Mateus Moury
committed
feat(store): basic store now encodes record into elastic record before writing it
1 parent 4457a88 commit eacb06f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/injector/store/store.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package store
22

33
import (
4+
"github.com/go-kit/kit/log"
45
"github.com/inloco/kafka-elasticsearch-injector/src/elasticsearch"
56
"github.com/inloco/kafka-elasticsearch-injector/src/models"
6-
"github.com/go-kit/kit/log"
77
)
88

99
type Store interface {
@@ -12,17 +12,26 @@ type Store interface {
1212
}
1313

1414
type basicStore struct {
15-
db elasticsearch.RecordDatabase
15+
db elasticsearch.RecordDatabase
16+
codec elasticsearch.Codec
1617
}
1718

1819
func (s basicStore) Insert(records []*models.Record) error {
19-
return s.db.Insert(records)
20+
elasticRecords, err := s.codec.EncodeElasticRecords(records)
21+
if err != nil {
22+
return err
23+
}
24+
return s.db.Insert(elasticRecords)
2025
}
2126

2227
func (s basicStore) ReadinessCheck() bool {
2328
return s.db.ReadinessCheck()
2429
}
2530

2631
func NewStore(logger log.Logger) Store {
27-
return basicStore{elasticsearch.NewDatabase(logger, elasticsearch.NewConfig())}
32+
config := elasticsearch.NewConfig()
33+
return basicStore{
34+
db: elasticsearch.NewDatabase(logger, config),
35+
codec: elasticsearch.NewCodec(logger, config),
36+
}
2837
}

0 commit comments

Comments
 (0)