github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/storage/bucket/http/config.go (about)

     1  package http
     2  
     3  import (
     4  	"flag"
     5  	"time"
     6  )
     7  
     8  // Config stores the http.Client configuration for the storage clients.
     9  type Config struct {
    10  	IdleConnTimeout       time.Duration `yaml:"idle_conn_timeout"`
    11  	ResponseHeaderTimeout time.Duration `yaml:"response_header_timeout"`
    12  	InsecureSkipVerify    bool          `yaml:"insecure_skip_verify"`
    13  	TLSHandshakeTimeout   time.Duration `yaml:"tls_handshake_timeout"`
    14  	ExpectContinueTimeout time.Duration `yaml:"expect_continue_timeout"`
    15  	MaxIdleConns          int           `yaml:"max_idle_connections"`
    16  	MaxIdleConnsPerHost   int           `yaml:"max_idle_connections_per_host"`
    17  	MaxConnsPerHost       int           `yaml:"max_connections_per_host"`
    18  }
    19  
    20  // RegisterFlags registers the flags for the storage HTTP client.
    21  func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
    22  	cfg.RegisterFlagsWithPrefix("", f)
    23  }
    24  
    25  // RegisterFlagsWithPrefix registers the flags for the storage HTTP client with the provided prefix.
    26  func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
    27  	f.DurationVar(&cfg.IdleConnTimeout, prefix+"http.idle-conn-timeout", 90*time.Second, "The time an idle connection will remain idle before closing.")
    28  	f.DurationVar(&cfg.ResponseHeaderTimeout, prefix+"http.response-header-timeout", 2*time.Minute, "The amount of time the client will wait for a servers response headers.")
    29  	f.BoolVar(&cfg.InsecureSkipVerify, prefix+"http.insecure-skip-verify", false, "If the client connects via HTTPS and this option is enabled, the client will accept any certificate and hostname.")
    30  	f.DurationVar(&cfg.TLSHandshakeTimeout, prefix+"tls-handshake-timeout", 10*time.Second, "Maximum time to wait for a TLS handshake. 0 means no limit.")
    31  	f.DurationVar(&cfg.ExpectContinueTimeout, prefix+"expect-continue-timeout", 1*time.Second, "The time to wait for a server's first response headers after fully writing the request headers if the request has an Expect header. 0 to send the request body immediately.")
    32  	f.IntVar(&cfg.MaxIdleConns, prefix+"max-idle-connections", 100, "Maximum number of idle (keep-alive) connections across all hosts. 0 means no limit.")
    33  	f.IntVar(&cfg.MaxIdleConnsPerHost, prefix+"max-idle-connections-per-host", 100, "Maximum number of idle (keep-alive) connections to keep per-host. If 0, a built-in default value is used.")
    34  	f.IntVar(&cfg.MaxConnsPerHost, prefix+"max-connections-per-host", 0, "Maximum number of connections per host. 0 means no limit.")
    35  }