estransport

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package estransport provides the transport layer for the Elasticsearch client.

It is automatically included in the client provided by the github.com/elastic/go-elasticsearch package and is not intended for direct use: to configure the client, use the elasticsearch.Config struct.

At the moment, the implementation is rather minimal: the client takes a slice of url.URL pointers, and round-robins across them when performing the request.

The default HTTP transport of the client is http.Transport.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents the HTTP client.

func New

func New(cfg Config) *Client

New creates new HTTP client.

http.DefaultTransport will be used if no transport is passed in the configuration.

func (*Client) Perform

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

Perform executes the request and returns a response or error.

func (*Client) URLs

func (c *Client) URLs() []*url.URL

URLs returns a list of transport URLs.

type Config

type Config struct {
	URLs      []*url.URL
	Transport http.RoundTripper
}

Config represents the configuration of HTTP client.

type Interface

type Interface interface {
	Perform(*http.Request) (*http.Response, error)
}

Interface defines the interface for HTTP client.

type RoundRobinSelector

type RoundRobinSelector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RoundRobinSelector implements a round-robin selection strategy.

func NewRoundRobinSelector

func NewRoundRobinSelector(urls ...*url.URL) *RoundRobinSelector

NewRoundRobinSelector creates a new RoundRobinSelector.

func (*RoundRobinSelector) Select

func (r *RoundRobinSelector) Select() (*url.URL, error)

Select returns a URL or error from the list of URLs in a round-robin fashion.

type Selector

type Selector interface {
	Select() (*url.URL, error)
}

Selector defines the interface for selecting URLs for performing request.

Jump to

Keyboard shortcuts

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