Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func NewClient(url string, signRequests bool, maxRetries int, indexes ...string) *Client
- func NewClientWithHTTPClient(url string, signRequests bool, httpClient dphttp.Clienter, indexes ...string) *Client
- func NewClientWithHTTPClientAndAwsSigner(url string, signer *esauth.Signer, signRequests bool, httpCli dphttp.Clienter, ...) *Client
- func (cli *Client) AddDocument(ctx context.Context, indexName, documentType, documentID string, ...) (int, error)
- func (cli *Client) BulkUpdate(ctx context.Context, esDestIndex string, esDestURL string, bulk []byte) ([]byte, int, error)
- func (cli *Client) Checker(ctx context.Context, state *health.CheckState) error
- func (cli *Client) CreateIndex(ctx context.Context, indexName string, indexSettings []byte) (int, error)
- func (cli *Client) DeleteIndex(ctx context.Context, indexName string) (int, error)
- func (cli *Client) GetIndices(ctx context.Context, indexPatterns []string) (int, []byte, error)
- type ClusterHealth
- type HealthStatus
Constants ¶
const ( HealthGreen = iota HealthYellow HealthRed )
Possible values for the HealthStatus
const MsgHealthy = "elasticsearch is healthy and the required indexes exist"
MsgHealthy Check message returned when elasticsearch is healthy and the required indexes exist
const (
ServiceName = "elasticsearch"
)
ServiceName elasticsearch
Variables ¶
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 ¶
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 (*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 ¶
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 ¶
DeleteIndex deletes an index in 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