github.com/aavshr/aws-sdk-go@v1.41.3/example/aws/request/httptrace/config.go (about) 1 package main 2 3 import ( 4 "flag" 5 "net/http" 6 "time" 7 ) 8 9 // ClientConfig provides the timeouts from CLI flags and default values for the 10 // example apps's configuration. 11 type ClientConfig struct { 12 KeepAlive bool 13 Timeouts Timeouts 14 } 15 16 // SetupFlags initializes the CLI flags. 17 func (c *ClientConfig) SetupFlags(prefix string, flagset *flag.FlagSet) { 18 prefix += "client." 19 20 flagset.BoolVar(&c.KeepAlive, prefix+"http-keep-alive", true, 21 "Specifies if HTTP keep alive is enabled.") 22 23 c.Timeouts.SetupFlags(prefix, flagset) 24 } 25 26 // Timeouts collection of HTTP client timeout values. 27 type Timeouts struct { 28 IdleConnection time.Duration 29 Connect time.Duration 30 TLSHandshake time.Duration 31 ExpectContinue time.Duration 32 ResponseHeader time.Duration 33 } 34 35 // SetupFlags initializes the CLI flags. 36 func (c *Timeouts) SetupFlags(prefix string, flagset *flag.FlagSet) { 37 prefix += "timeout." 38 39 flagset.DurationVar(&c.IdleConnection, prefix+"idle-conn", 90*time.Second, 40 "The `timeout` of idle connects to the remote host.") 41 42 flagset.DurationVar(&c.Connect, prefix+"connect", 30*time.Second, 43 "The `timeout` connecting to the remote host.") 44 45 defTR := http.DefaultTransport.(*http.Transport) 46 47 flagset.DurationVar(&c.TLSHandshake, prefix+"tls", defTR.TLSHandshakeTimeout, 48 "The `timeout` waiting for the TLS handshake to complete.") 49 50 c.ExpectContinue = defTR.ExpectContinueTimeout 51 52 flagset.DurationVar(&c.ResponseHeader, prefix+"response-header", defTR.ResponseHeaderTimeout, 53 "The `timeout` waiting for the TLS handshake to complete.") 54 }