elasticsearch

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (
	HealthGreen = iota
	HealthYellow
	HealthRed
)

Possible values for the HealthStatus

View Source
const MsgHealthy = "elasticsearch is healthy and the required indexes exist"

MsgHealthy Check message returned when elasticsearch is healthy and the required indexes exist

View Source
const (
	ServiceName = "elasticsearch"
)

ServiceName elasticsearch

Variables

View Source
var (
	ErrorUnexpectedStatusCode   = errors.New("unexpected status code from api")
	ErrorParsingBody            = errors.New("error parsing cluster health response body")
	ErrorClusterAtRisk          = errors.New("elasticsearch cluster state yellow but functional. Data might be at risk, check your replica shards")
	ErrorUnhealthyClusterStatus = errors.New("error cluster health red. Cluster is unhealthy")
	ErrorInvalidHealthStatus    = errors.New("error invalid health status returned")
	ErrorIndexDoesNotExist      = errors.New("error index does not exist in cluster")
	ErrorInternalServer         = errors.New("error internal server error")
)

List of errors

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an ElasticSearch client containing an HTTP client to contact the elasticsearch API.

func NewClient

func NewClient(url string, signRequests bool, maxRetries int, indexes ...string) *Client

NewClient returns a new initialised elasticsearch client with the default dp-net/http client

func NewClientWithHTTPClient

func NewClientWithHTTPClient(url string, signRequests bool, httpClient dphttp.Clienter, indexes ...string) *Client

NewClientWithHTTPClient returns a new initialised elasticsearch client with the provided HTTP client

func NewClientWithHTTPClientAndAwsSigner added in v2.1.1

func NewClientWithHTTPClientAndAwsSigner(url string, signer *esauth.Signer, signRequests bool, httpCli dphttp.Clienter, indexes ...string) *Client

func (*Client) AddDocument

func (cli *Client) AddDocument(ctx context.Context, indexName, documentType, documentID string, document []byte) (int, error)

AddDocument adds a JSON document to elasticsearch

func (*Client) BulkUpdate added in v2.3.0

func (cli *Client) BulkUpdate(ctx context.Context, esDestIndex string, esDestURL string, bulk []byte) ([]byte, int, error)

BulkUpdate uses an HTTP post request to submit data to Elastic Search

func (*Client) Checker

func (cli *Client) Checker(ctx context.Context, state *health.CheckState) error

Checker checks health of Elasticsearch, if the required indexes exist and updates the provided CheckState accordingly.

func (*Client) CreateIndex

func (cli *Client) CreateIndex(ctx context.Context, indexName string, indexSettings []byte) (int, error)

CreateIndex creates an index in elasticsearch

func (*Client) DeleteIndex

func (cli *Client) DeleteIndex(ctx context.Context, indexName string) (int, error)

DeleteIndex deletes an index in elasticsearch

func (*Client) GetIndices added in v2.2.1

func (cli *Client) GetIndices(ctx context.Context, indexPatterns []string) (int, []byte, error)

GetIndices gets an index from elasticsearch

type ClusterHealth

type ClusterHealth struct {
	Status string `json:"status"`
}

ClusterHealth represents the response from the elasticsearch cluster health check

type HealthStatus

type HealthStatus int

HealthStatus - iota enum of possible health states returned by Elasticsearch API

func (HealthStatus) String

func (hs HealthStatus) String() string

Jump to

Keyboard shortcuts

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