batch

package
v0.0.0-...-36157cb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2017 License: MIT Imports: 3 Imported by: 38

Documentation

Overview

Package batch lets you buffer bulk documents for insert. None of the methods provided are thread-safe, you must synchronize if desired.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	Elastic Elasticsearch // Elasticsearch implementation
	Docs    []interface{} // Docs buffered
	Index   string        // Index name
	Type    string        // Type name
}

Batch indexes docs in bulk for reporting. Currently documents are flushed in a single write, however may allow streaming in the future.

func (*Batch) Add

func (b *Batch) Add(doc interface{})

Add document.

func (*Batch) Bytes

func (b *Batch) Bytes() (*bytes.Buffer, error)

Bytes returns the request body.

func (*Batch) Flush

func (b *Batch) Flush() (err error)

Flush checks in bulk.

func (*Batch) Size

func (b *Batch) Size() int

Size returns the number of documents pending flush.

type Elasticsearch

type Elasticsearch interface {
	Bulk(io.Reader) error
}

Elasticsearch interface.

type Index

type Index struct {
	Index   string `json:"_index"`
	Type    string `json:"_type"`
	Routing string `json:"_routing,omitempty"`
	ID      string `json:"_id,omitempty"`
}

Index metadata.

type IndexOp

type IndexOp struct {
	Index Index `json:"index"`
}

IndexOp is an index operation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL