rubber

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HEAD is an http method constant
	HEAD = "HEAD"
	// GET is an http method constant
	GET = "GET"
	// POST is an http method constant
	POST = "POST"
	// PUT is an http method constant
	PUT = "PUT"
	// DELETE is an http method constant
	DELETE = "DELETE"
)
View Source
const (
	// ConfigWeightedBackend is the constant that should appear in the configuration to create
	// a weighted backend
	ConfigWeightedBackend = "weighted"

	// ConfigSimpleBackend is the constant that should appear in the configuration to create
	// a simple backend
	ConfigSimpleBackend = "simple"
)
View Source
const NoIndex = ""

NoIndex is the index to be given to the request functions when there is no index

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Request(index, method, path string, body io.Reader) (int, []byte, error)
	CountRetries() uint64
}

Backend defines a way to connect to elasticsearch

func CreateWeightedBackend

func CreateWeightedBackend(settings Settings, logger *zap.Logger) (Backend, error)

CreateWeightedBackend creates a backend that directs requests for a given shard to its server

type Elastic

type Elastic struct {
	Backend
}

Elastic is a wrapper that creates helper functions around the backend

func Create

func Create(backend Backend) *Elastic

Create is a function that creates an elasticsearch client

func New

func New(log *zap.Logger, settings Settings) (*Elastic, error)

New creates an elasticsearch client

func (*Elastic) CreateIndex

func (es *Elastic) CreateIndex(index string, body io.Reader) (int, error)

CreateIndex creates an index in the cluster

func (*Elastic) Delete

func (es *Elastic) Delete(index, esType, id string) (int, error)

Delete makes a DELETE request against the cluster

func (*Elastic) DeleteIndex

func (es *Elastic) DeleteIndex(index string) (int, error)

DeleteIndex deletes an index in the cluster

func (*Elastic) GetByID

func (es *Elastic) GetByID(index, esType, id string, Response interface{}) (int, error)

GetByID gets a document with a given ID

func (*Elastic) GetHead

func (es *Elastic) GetHead(index, esType, id string) (int, error)

GetHead performs a HEAD request against the server

func (*Elastic) Post

func (es *Elastic) Post(index, esType, id string, obj interface{}) (int, error)

Post makes a POST request to the ElasticSearch server

func (*Elastic) PostBulk

func (es *Elastic) PostBulk(body io.Reader) (int, error)

PostBulk makes a bulk ElasticSearch post request

func (*Elastic) Put

func (es *Elastic) Put(index, esType, id string, obj interface{}) (int, error)

Put makes a PUT request to the elasticsearch server

func (*Elastic) Query

func (es *Elastic) Query(index, esType string, query, response interface{}) (int, error)

Query performs a query in elasticsearch

type Settings

type Settings struct {
	// Simple settings
	Nodes     []string
	Preferred string

	// Weighted Settings
	Seed  string
	Limit int

	// Generic settings
	Timeout time.Duration
	Type    string
}

Settings define how the single server client works

Jump to

Keyboard shortcuts

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