MCPcopy Index your code
hub / github.com/cortexproject/cortex / NewProxyBackend

Function NewProxyBackend

tools/querytee/proxy_backend.go:30–52  ·  view source on GitHub ↗

NewProxyBackend makes a new ProxyBackend

(name string, endpoint *url.URL, timeout time.Duration, preferred bool)

Source from the content-addressed store, hash-verified

28
29// NewProxyBackend makes a new ProxyBackend
30func NewProxyBackend(name string, endpoint *url.URL, timeout time.Duration, preferred bool) *ProxyBackend {
31 return &ProxyBackend{
32 name: name,
33 endpoint: endpoint,
34 timeout: timeout,
35 preferred: preferred,
36 client: &http.Client{
37 CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
38 return errors.New("the query-tee proxy does not follow redirects")
39 },
40 Transport: &http.Transport{
41 Proxy: http.ProxyFromEnvironment,
42 DialContext: (&net.Dialer{
43 Timeout: 30 * time.Second,
44 KeepAlive: 30 * time.Second,
45 }).DialContext,
46 MaxIdleConns: 100,
47 MaxIdleConnsPerHost: 100, // see https://github.com/golang/go/issues/13801
48 IdleConnTimeout: 90 * time.Second,
49 },
50 },
51 }
52}
53
54func (b *ProxyBackend) ForwardRequest(orig *http.Request) (int, []byte, error) {
55 req, err := b.createBackendRequest(orig)

Calls

no outgoing calls