opensearch

package module
v0.0.0-...-0e11c02 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const Version = version.Client

Version returns the package version as a string.

Variables

This section is empty.

Functions

func ParseVersion

func ParseVersion(version string) (int64, int64, int64, error)

ParseVersion returns an int64 representation of version.

Types

type Client

type Client struct {
	Transport opensearchtransport.Interface
}

Client represents the OpenSearch client.

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient creates a new client with configuration from cfg.

It will use http://localhost:9200 as the default address.

It will use the OPENSEARCH_URL/ELASTICSEARCH_URL environment variable, if set, to configure the addresses; use a comma to separate multiple URLs.

It's an error to set both OPENSEARCH_URL and ELASTICSEARCH_URL.

func NewDefaultClient

func NewDefaultClient() (*Client, error)

NewDefaultClient creates a new client with default options.

It will use http://localhost:9200 as the default address.

It will use the OPENSEARCH_URL/ELASTICSEARCH_URL environment variable, if set, to configure the addresses; use a comma to separate multiple URLs.

It's an error to set both OPENSEARCH_URL and ELASTICSEARCH_URL.

func (*Client) DiscoverNodes

func (c *Client) DiscoverNodes() error

DiscoverNodes reloads the client connections by fetching information from the cluster.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req Request, dataPointer interface{}) (*Response, error)

func (*Client) Metrics

func (c *Client) Metrics() (opensearchtransport.Metrics, error)

Metrics returns the client metrics.

func (*Client) Perform

func (c *Client) Perform(req *http.Request) (*http.Response, error)

Perform delegates to Transport to execute a request and return a response.

type Config

type Config struct {
	Addresses []string // A list of nodes to use.
	Username  string   // Username for HTTP Basic Authentication.
	Password  string   // Password for HTTP Basic Authentication.

	Header http.Header // Global HTTP request header.

	Signer signer.Signer

	// PEM-encoded certificate authorities.
	// When set, an empty certificate pool will be created, and the certificates will be appended to it.
	// The option is only valid when the transport is not specified, or when it's http.Transport.
	CACert []byte

	RetryOnStatus        []int // List of status codes for retry. Default: 502, 503, 504.
	DisableRetry         bool  // Default: false.
	EnableRetryOnTimeout bool  // Default: false.
	MaxRetries           int   // Default: 3.

	CompressRequestBody bool // Default: false.

	DiscoverNodesOnStart  bool          // Discover nodes when initializing the client. Default: false.
	DiscoverNodesInterval time.Duration // Discover nodes periodically. Default: disabled.

	EnableMetrics     bool // Enable the metrics collection.
	EnableDebugLogger bool // Enable the debug logging.

	RetryBackoff func(attempt int) time.Duration // Optional backoff duration. Default: nil.

	Transport http.RoundTripper            // The HTTP transport object.
	Logger    opensearchtransport.Logger   // The logger object.
	Selector  opensearchtransport.Selector // The selector object.

	// Optional constructor function for a custom ConnectionPool. Default: nil.
	ConnectionPoolFunc func([]*opensearchtransport.Connection, opensearchtransport.Selector) opensearchtransport.ConnectionPool
}

Config represents the client configuration.

type Inspect

type Inspect struct {
	Response *Response
}

type Request

type Request interface {
	GetRequest() (*http.Request, error)
}

type Response

type Response struct {
	StatusCode int
	Header     http.Header
	Body       io.ReadCloser
}

Response represents the API response.

func (*Response) IsError

func (r *Response) IsError() bool

IsError returns true when the response status indicates failure.

func (*Response) Status

func (r *Response) Status() string

func (*Response) String

func (r *Response) String() string

String returns the response as a string.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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