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!
4 files
+ 76
33
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 4
13
@@ -20,8 +20,8 @@ const (
// TODO: make this configurable / detectable.
// Limiting to 10MiB lets us work on small AWS clusters, but unnecessarily
// increases round trips in larger or non-AWS clusters
MaxBulkSize = 10 * 1024 * 1024
BulkWorkers = 10
MaxBulkSize = 10 * 1024 * 1024
BulkWorkers = 10
)
type Client struct {
@@ -104,16 +104,11 @@ func (c *Client) ParentID() string {
return c.ProjectID
}
// FIXME(nick): this should reserve some space for encoding
func (c *Client) SubmissionLimit() int64 {
return MaxBulkSize
}
func (c *Client) Flush() error {
return c.bulk.Flush()
}
func (c *Client) Index(id string, thing interface{}) error {
func (c *Client) Index(id string, thing interface{}) {
req := elastic.NewBulkIndexRequest().
Index(c.IndexName).
Type("repository").
@@ -122,11 +117,9 @@ func (c *Client) Index(id string, thing interface{}) error {
Doc(thing)
c.bulk.Add(req)
return nil
}
func (c *Client) Remove(id string) error {
func (c *Client) Remove(id string) {
req := elastic.NewBulkDeleteRequest().
Index(c.IndexName).
Type("repository").
@@ -134,6 +127,4 @@ func (c *Client) Remove(id string) error {
Id(id)
c.bulk.Add(req)
return nil
}
Loading