discoveryutils

package
v1.81.2-cluster Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 19 Imported by: 45

Documentation

Index

Constants

View Source
const BlockingClientReadTimeout = 10 * time.Minute

BlockingClientReadTimeout is the maximum duration for waiting the response from GetBlockingAPI*

Variables

This section is empty.

Functions

func DoRequestWithPossibleRetry added in v1.81.0

func DoRequestWithPossibleRetry(hc *fasthttp.HostClient, req *fasthttp.Request, resp *fasthttp.Response, deadline time.Time, requestCounter, retryCounter *metrics.Counter) error

DoRequestWithPossibleRetry performs the given req at hc and stores the response at resp.

func GetHTTPClient added in v1.35.1

func GetHTTPClient() *http.Client

GetHTTPClient returns default client for http API requests.

func InternString added in v1.81.0

func InternString(s string) string

InternString returns interned s.

This may be needed for reducing the amounts of allocated memory.

func JoinHostPort

func JoinHostPort(host string, port int) string

JoinHostPort returns host:port.

Host may be dns name, ipv4 or ipv6 address.

func SanitizeLabelName

func SanitizeLabelName(name string) string

SanitizeLabelName replaces anything that doesn't match client_label.LabelNameRE with an underscore.

This has been copied from Prometheus sources at util/strutil/strconv.go

Types

type Client added in v1.35.1

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

Client is http client, which talks to the given apiServer.

func NewClient added in v1.35.1

func NewClient(apiServer string, ac *promauth.Config, proxyURL *proxy.URL, proxyAC *promauth.Config) (*Client, error)

NewClient returns new Client for the given args.

func (*Client) Addr added in v1.49.0

func (c *Client) Addr() string

Addr returns the address the client connects to.

func (*Client) GetAPIResponse added in v1.35.1

func (c *Client) GetAPIResponse(path string) ([]byte, error)

GetAPIResponse returns response for the given absolute path.

func (*Client) GetAPIResponseWithReqParams added in v1.62.0

func (c *Client) GetAPIResponseWithReqParams(path string, modifyRequestParams func(request *fasthttp.Request)) ([]byte, error)

GetAPIResponseWithReqParams returns response for given absolute path with optional callback for request. modifyRequestParams should never reference data from request.

func (*Client) GetBlockingAPIResponse added in v1.49.0

func (c *Client) GetBlockingAPIResponse(path string, inspectResponse func(resp *fasthttp.Response)) ([]byte, error)

GetBlockingAPIResponse returns response for given absolute path with blocking client and optional callback for api response, inspectResponse - should never reference data from response.

type ConfigMap added in v1.35.1

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

ConfigMap is a map for storing discovery api configs.

It automatically removes old configs which weren't accessed recently.

func NewConfigMap added in v1.35.1

func NewConfigMap() *ConfigMap

NewConfigMap creates ConfigMap

func (*ConfigMap) Delete added in v1.55.0

func (cm *ConfigMap) Delete(key interface{}) interface{}

Delete deletes config for the given key from cm and returns it.

func (*ConfigMap) Get added in v1.35.1

func (cm *ConfigMap) Get(key interface{}, newConfig func() (interface{}, error)) (interface{}, error)

Get returns config for the given key.

Key must be a pointer.

It creates new config map with newConfig() call if cm doesn't contain config under the given key.

type SortedLabels

type SortedLabels []prompbmarshal.Label

SortedLabels represents sorted labels.

func GetSortedLabels

func GetSortedLabels(m map[string]string) SortedLabels

GetSortedLabels returns SortedLabels built from m.

func (*SortedLabels) GetByName added in v1.68.0

func (sls *SortedLabels) GetByName(name string) string

GetByName returns the label with the given name from sls.

func (*SortedLabels) UnmarshalJSON

func (sls *SortedLabels) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON from data.

Jump to

Keyboard shortcuts

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