v2

package
v3.0.1-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: MIT Imports: 14 Imported by: 1

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(esURL string, maxRetries int, indexes ...string) *Client

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

func NewClientWithHTTPClient

func NewClientWithHTTPClient(esURL string, httpCli dphttp.Clienter, indexes ...string) *Client

func (*Client) AddDocument

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

AddDocument adds a JSON document to elasticsearch

func (*Client) BulkIndexAdd

func (cli *Client) BulkIndexAdd(ctx context.Context, action client.BulkIndexerAction, index, documentID string, document []byte) error

func (*Client) BulkIndexClose

func (cli *Client) BulkIndexClose(context.Context) error

Close waits until all added items are flushed and closes the indexer.

func (*Client) BulkUpdate

func (cli *Client) BulkUpdate(ctx context.Context, esDestIndex, esDestURL string, bulk []byte) ([]byte, 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) CountIndices

func (cli *Client) CountIndices(ctx context.Context, indices []string) ([]byte, error)

CountIndices feature is not supported for ES version 2.

func (*Client) CreateIndex

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

CreateIndex creates an index in elasticsearch

func (*Client) DeleteIndex

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

DeleteIndex deletes an index in elasticsearch

func (*Client) DeleteIndices

func (cli *Client) DeleteIndices(ctx context.Context, indices []string) error

func (*Client) GetAlias

func (cli *Client) GetAlias(ctx context.Context) ([]byte, error)

GetAlias returns a list of indices.

func (*Client) GetIndices

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

GetIndices gets an index from elasticsearch

func (*Client) MultiSearch

func (cli *Client) MultiSearch(ctx context.Context, searches []client.Search) ([]byte, error)

func (*Client) NewBulkIndexer

func (cli *Client) NewBulkIndexer(ctx context.Context) error

func (*Client) Search

func (cli *Client) Search(ctx context.Context, search client.Search) ([]byte, error)

func (*Client) UpdateAliases

func (cli *Client) UpdateAliases(ctx context.Context, alias string, addIndices, removeIndices []string) error

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