http

package
v0.23.2-rc.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package http is a wrapper around github.com/prometheus/common/config.

Index

Constants

This section is empty.

Variables

View Source
var ThanosUserAgent = fmt.Sprintf("Thanos/%s", version.Version)

Functions

func NewHTTPClient added in v0.11.0

func NewHTTPClient(cfg ClientConfig, name string) (*http.Client, error)

NewHTTPClient returns a new HTTP client.

Types

type AddressProvider added in v0.11.0

type AddressProvider interface {
	Resolve(context.Context, []string) error
	Addresses() []string
}

type BasicAuth

type BasicAuth struct {
	Username     string `yaml:"username"`
	Password     string `yaml:"password"`
	PasswordFile string `yaml:"password_file"`
}

BasicAuth configures basic authentication for HTTP clients.

func (BasicAuth) IsZero

func (b BasicAuth) IsZero() bool

IsZero returns false if basic authentication isn't enabled.

type Client added in v0.11.0

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

Client represents a client that can send requests to a cluster of HTTP-based endpoints.

func NewClient

func NewClient(logger log.Logger, cfg EndpointsConfig, client *http.Client, provider AddressProvider) (*Client, error)

NewClient returns a new Client.

func (*Client) Discover added in v0.11.0

func (c *Client) Discover(ctx context.Context)

Discover runs the service to discover endpoints until the given context is done.

func (*Client) Do added in v0.11.0

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

Do executes an HTTP request with the underlying HTTP client.

func (*Client) Endpoints added in v0.11.0

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

Endpoints returns the list of known endpoints.

func (*Client) Resolve added in v0.11.0

func (c *Client) Resolve(ctx context.Context) error

Resolve refreshes and resolves the list of targets.

type ClientConfig

type ClientConfig struct {
	// The HTTP basic authentication credentials for the targets.
	BasicAuth BasicAuth `yaml:"basic_auth"`
	// The bearer token for the targets.
	BearerToken string `yaml:"bearer_token"`
	// The bearer token file for the targets.
	BearerTokenFile string `yaml:"bearer_token_file"`
	// HTTP proxy server to use to connect to the targets.
	ProxyURL string `yaml:"proxy_url"`
	// TLSConfig to use to connect to the targets.
	TLSConfig TLSConfig `yaml:"tls_config"`
	// ClientMetrics contains metrics that will be used to instrument
	// the client that will be created with this config.
	ClientMetrics *extpromhttp.ClientMetrics `yaml:"-"`
}

ClientConfig configures an HTTP client.

type EndpointsConfig added in v0.11.0

type EndpointsConfig struct {
	// List of addresses with DNS prefixes.
	StaticAddresses []string `yaml:"static_configs"`
	// List of file  configurations (our FileSD supports different DNS lookups).
	FileSDConfigs []FileSDConfig `yaml:"file_sd_configs"`

	// The URL scheme to use when talking to targets.
	Scheme string `yaml:"scheme"`

	// Path prefix to add in front of the endpoint path.
	PathPrefix string `yaml:"path_prefix"`
}

EndpointsConfig configures a cluster of HTTP endpoints from static addresses and file service discovery.

type FileSDConfig added in v0.11.0

type FileSDConfig struct {
	Files           []string       `yaml:"files"`
	RefreshInterval model.Duration `yaml:"refresh_interval"`
}

FileSDConfig represents a file service discovery configuration.

type TLSConfig

type TLSConfig struct {
	// The CA cert to use for the targets.
	CAFile string `yaml:"ca_file"`
	// The client cert file for the targets.
	CertFile string `yaml:"cert_file"`
	// The client key file for the targets.
	KeyFile string `yaml:"key_file"`
	// Used to verify the hostname for the targets.
	ServerName string `yaml:"server_name"`
	// Disable target certificate validation.
	InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
}

TLSConfig configures TLS connections.

Jump to

Keyboard shortcuts

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