clientconfig

package
v0.37.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package clientconfig is a wrapper around github.com/prometheus/common/config with additional support for gRPC clients.

Index

Constants

This section is empty.

Variables

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

Functions

func NewHTTPClient

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

NewHTTPClient returns a new HTTP client.

func NewRoundTripperFromConfig

func NewRoundTripperFromConfig(cfg config_util.HTTPClientConfig, transportConfig TransportConfig, name string) (http.RoundTripper, error)

NewRoundTripperFromConfig returns a new HTTP RoundTripper configured for the given http.HTTPClientConfig and http.HTTPClientOption.

Types

type AddressProvider

type AddressProvider interface {
	Resolve(context.Context, []string, bool) 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 Config

type Config struct {
	HTTPConfig HTTPConfig  `yaml:",inline"`
	GRPCConfig *GRPCConfig `yaml:"grpc_config"`
}

Config is a structure that allows pointing to various HTTP and GRPC endpoints, e.g. ruler connecting to queriers.

func BuildConfigFromGRPCAddresses

func BuildConfigFromGRPCAddresses(addrs []string) ([]Config, error)

BuildConfigFromGRPCAddresses returns a configuration from a static addresses.

func BuildConfigFromHTTPAddresses

func BuildConfigFromHTTPAddresses(addrs []string) ([]Config, error)

BuildConfigFromHTTPAddresses returns a configuration from static addresses.

func DefaultConfig

func DefaultConfig() Config

func LoadConfigs

func LoadConfigs(confYAML []byte) ([]Config, error)

LoadConfigs loads a list of Config from YAML data.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type GRPCConfig

type GRPCConfig struct {
	EndpointAddrs []string `yaml:"endpoint_addresses"`
}

type HTTPClient

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

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

func NewClient

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

NewClient returns a new Client.

func (*HTTPClient) Discover

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

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

func (*HTTPClient) Do

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

Do executes an HTTP request with the underlying HTTP client.

func (*HTTPClient) Endpoints

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

Endpoints returns the list of known endpoints.

func (*HTTPClient) Resolve

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

Resolve refreshes and resolves the list of targets.

type HTTPClientConfig

type HTTPClientConfig 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"`
	// TransportConfig for Client transport properties
	TransportConfig TransportConfig `yaml:"transport_config"`
	// ClientMetrics contains metrics that will be used to instrument
	// the client that will be created with this config.
	ClientMetrics *extpromhttp.ClientMetrics `yaml:"-"`
}

HTTPClientConfig configures an HTTP client.

func NewDefaultHTTPClientConfig

func NewDefaultHTTPClientConfig() HTTPClientConfig

func NewHTTPClientConfigFromYAML

func NewHTTPClientConfigFromYAML(cfg []byte) (*HTTPClientConfig, error)

type HTTPConfig

type HTTPConfig struct {
	HTTPClientConfig HTTPClientConfig    `yaml:"http_config"`
	EndpointsConfig  HTTPEndpointsConfig `yaml:",inline"`
}

HTTPConfig is a structure that allows pointing to various HTTP endpoint, e.g ruler connecting to queriers.

func (*HTTPConfig) NotEmpty

func (c *HTTPConfig) NotEmpty() bool

type HTTPEndpointsConfig

type HTTPEndpointsConfig struct {
	// List of addresses with DNS prefixes.
	StaticAddresses []string `yaml:"static_configs"`
	// List of file  configurations (our FileSD supports different DNS lookups).
	FileSDConfigs []HTTPFileSDConfig `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"`
}

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

type HTTPFileSDConfig

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

HTTPFileSDConfig 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. See https://tools.ietf.org/html/rfc4366#section-3.1
	ServerName string `yaml:"server_name"`
	// Disable target certificate validation.
	InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
}

TLSConfig configures TLS connections.

type TransportConfig

type TransportConfig struct {
	MaxIdleConns          int   `yaml:"max_idle_conns"`
	MaxIdleConnsPerHost   int   `yaml:"max_idle_conns_per_host"`
	IdleConnTimeout       int64 `yaml:"idle_conn_timeout"`
	ResponseHeaderTimeout int64 `yaml:"response_header_timeout"`
	ExpectContinueTimeout int64 `yaml:"expect_continue_timeout"`
	MaxConnsPerHost       int   `yaml:"max_conns_per_host"`
	DisableCompression    bool  `yaml:"disable_compression"`
	TLSHandshakeTimeout   int64 `yaml:"tls_handshake_timeout"`
	DialerTimeout         int64 `yaml:"dialer_timeout"`
}

TransportConfig configures client's transport properties.

Jump to

Keyboard shortcuts

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