Documentation ¶
Index ¶
- type ClientConfig
- type ClientOption
- func WithAllowHTTP(allow bool) ClientOption
- func WithClientDisableKeepAlive(disable bool) ClientOption
- func WithDialTimeout(timeout time.Duration) ClientOption
- func WithDialer(d network.Dialer) ClientOption
- func WithMaxHeaderListSize(maxHeaderListSize uint32) ClientOption
- func WithMaxIdempotentCallAttempts(n int) ClientOption
- func WithMaxIdleConnDuration(d time.Duration) ClientOption
- func WithPingTimeout(pt time.Duration) ClientOption
- func WithReadIdleTimeout(readIdleTimeout time.Duration) ClientOption
- func WithRetryConfig(opts ...retry.Option) ClientOption
- func WithStrictMaxConcurrentStreams(strictMaxConcurrentStreams bool) ClientOption
- func WithTLSConfig(tlsConfig *tls.Config) ClientOption
- func WithWriteByteTimeout(writeByteTimeout time.Duration) ClientOption
- type Config
- type Option
- func WithDisableKeepAlive(disableKeepAlive bool) Option
- func WithIdleTimeout(t time.Duration) Option
- func WithMaxConcurrentStreams(n uint32) Option
- func WithMaxReadFrameSize(n uint32) Option
- func WithMaxUploadBufferPerConnection(n int32) Option
- func WithMaxUploadBufferPerStream(n int32) Option
- func WithPermitProhibitedCipherSuites(permitProhibitedChipherSuites bool) Option
- func WithReadTimeout(t time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientConfig ¶
type ClientConfig struct { // MaxHeaderListSize is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to // send in the initial settings frame. It is how many bytes // of response headers are allowed. Unlike the http2 spec, zero here // means to use a default limit (currently 10MB). If you actually // want to advertise an unlimited value to the peer, Transport // interprets the highest possible value here (0xffffffff or 1<<32-1) // to mean no limit. MaxHeaderListSize uint32 // AllowHTTP, if true, permits HTTP/2 requests using the insecure, // plain-text "http" scheme. Note that this does not enable h2c support. AllowHTTP bool // ReadIdleTimeout is the timeout after which a health check using ping // frame will be carried out if no frame is received on the connection. // Note that a ping response will is considered a received frame, so if // there is no other traffic on the connection, the health check will // be performed every ReadIdleTimeout interval. // If zero, no health check is performed. ReadIdleTimeout time.Duration // PingTimeout is the timeout after which the connection will be closed // if a response to Ping is not received. // Defaults to 15s. PingTimeout time.Duration // WriteByteTimeout is the timeout after which the connection will be // closed no data can be written to it. The timeout begins when data is // available to write, and is extended whenever any bytes are written. WriteByteTimeout time.Duration // StrictMaxConcurrentStreams controls whether the server's // SETTINGS_MAX_CONCURRENT_STREAMS should be respected // globally. If false, new TCP connections are created to the // server as needed to keep each under the per-connection // SETTINGS_MAX_CONCURRENT_STREAMS limit. If true, the // server's SETTINGS_MAX_CONCURRENT_STREAMS is interpreted as // a global limit and callers of RoundTrip block when needed, // waiting for their turn. StrictMaxConcurrentStreams bool // Default Dialer is used if not set. Dialer network.Dialer // Timeout for establishing new connections to hosts. // // Default DialTimeout is used if not set. DialTimeout time.Duration // Whether to use TLS (aka SSL or HTTPS) for host connections. // Optional TLS config. TLSConfig *tls.Config // Idle keep-alive connections are closed after this duration. // // By default idle connections are closed // after DefaultMaxIdleConnDuration. MaxIdleConnDuration time.Duration // All configurations related to retry RetryConfig *retry.Config // RetryIf controls whether a retry should be attempted after an error. // // By default will use isIdempotent function RetryIf client.RetryIfFunc // Connection will close after each request when set this to true. DisableKeepAlive bool }
ClientConfig All configurations related to retry
func NewClientConfig ¶
func NewClientConfig(opts ...ClientOption) *ClientConfig
func (*ClientConfig) Apply ¶
func (o *ClientConfig) Apply(opts []ClientOption)
type ClientOption ¶
type ClientOption struct {
F func(o *ClientConfig)
}
ClientOption is the only struct that can be used to set HTTP2 ClientConfig.
func WithAllowHTTP ¶
func WithAllowHTTP(allow bool) ClientOption
WithAllowHTTP is used to set whether to allow http.
If enabled, client will use h2c mode.
func WithClientDisableKeepAlive ¶
func WithClientDisableKeepAlive(disable bool) ClientOption
WithClientDisableKeepAlive is used to set whether to disable keep alive.
func WithDialTimeout ¶
func WithDialTimeout(timeout time.Duration) ClientOption
WithDialTimeout is used to set dial timeout.
func WithMaxHeaderListSize ¶
func WithMaxHeaderListSize(maxHeaderListSize uint32) ClientOption
WithMaxHeaderListSize sets max header list size.
func WithMaxIdempotentCallAttempts ¶
func WithMaxIdempotentCallAttempts(n int) ClientOption
WithMaxIdempotentCallAttempts sets maximum number of attempts for idempotent calls.
func WithMaxIdleConnDuration ¶
func WithMaxIdleConnDuration(d time.Duration) ClientOption
WithMaxIdleConnDuration is used to set max idle connection duration.
func WithPingTimeout ¶
func WithPingTimeout(pt time.Duration) ClientOption
WithPingTimeout is used to set the timeout after which the connection will be closed if a response to Ping is not received.
func WithReadIdleTimeout ¶
func WithReadIdleTimeout(readIdleTimeout time.Duration) ClientOption
WithReadIdleTimeout is used to set the timeout after which a health check using ping frame will be carried out if no frame is received on the connection.
func WithRetryConfig ¶
func WithRetryConfig(opts ...retry.Option) ClientOption
WithRetryConfig sets client retry config
func WithStrictMaxConcurrentStreams ¶
func WithStrictMaxConcurrentStreams(strictMaxConcurrentStreams bool) ClientOption
WithStrictMaxConcurrentStreams is used to controls whether the server's SETTINGS_MAX_CONCURRENT_STREAMS should be respected globally.
func WithTLSConfig ¶
func WithTLSConfig(tlsConfig *tls.Config) ClientOption
WithTLSConfig is used to set tls config.
func WithWriteByteTimeout ¶
func WithWriteByteTimeout(writeByteTimeout time.Duration) ClientOption
WithWriteByteTimeout is used to set the timeout after which the connection will be closed no data can be written to it.
type Config ¶
type Config struct { DisableKeepalive bool EnableTrace bool ReadTimeout time.Duration // MaxHandlers limits the number of http.Handler ServeHTTP goroutines // which may run at a time over all connections. // Negative or zero no limit. // TODO: implement MaxHandlers int // MaxConcurrentStreams optionally specifies the number of // concurrent streams that each client may have open at a // time. This is unrelated to the number of http.Handler goroutines // which may be active globally, which is MaxHandlers. // If zero, MaxConcurrentStreams defaults to at least 100, per // the HTTP/2 spec's recommendations. MaxConcurrentStreams uint32 // MaxReadFrameSize optionally specifies the largest frame // this server is willing to read. A valid value is between // 16k and 16M, inclusive. If zero or otherwise invalid, a // default value is used. MaxReadFrameSize uint32 // PermitProhibitedCipherSuites, if true, permits the use of // cipher suites prohibited by the HTTP/2 spec. PermitProhibitedCipherSuites bool // IdleTimeout specifies how long until idle clients should be // closed with a GOAWAY frame. PING frames are not considered // activity for the purposes of IdleTimeout. IdleTimeout time.Duration // MaxUploadBufferPerConnection is the size of the initial flow // control window for each connections. The HTTP/2 spec does not // allow this to be smaller than 65535 or larger than 2^32-1. // If the value is outside this range, a default value will be // used instead. MaxUploadBufferPerConnection int32 // MaxUploadBufferPerStream is the size of the initial flow control // window for each stream. The HTTP/2 spec does not allow this to // be larger than 2^32-1. If the value is zero or larger than the // maximum, a default value will be used instead. MaxUploadBufferPerStream int32 }
type Option ¶
type Option struct {
F func(o *Config)
}
Option is the only struct that can be used to set HTTP2 Config.
func WithDisableKeepAlive ¶
WithDisableKeepAlive is used to set whether disableKeepAlive.
func WithIdleTimeout ¶ added in v0.1.3
WithIdleTimeout is used to set idle timeout.
func WithMaxConcurrentStreams ¶ added in v0.1.3
WithMaxConcurrentStreams is used to set the max concurrent streams.
func WithMaxReadFrameSize ¶ added in v0.1.3
WithMaxReadFrameSize is used to set the max read frame size.
func WithMaxUploadBufferPerConnection ¶ added in v0.1.3
WithMaxUploadBufferPerConnection is used to set max upload buffer per connection.
func WithMaxUploadBufferPerStream ¶ added in v0.1.3
WithMaxUploadBufferPerStream is used to set max upload buffer per stream.
func WithPermitProhibitedCipherSuites ¶ added in v0.1.3
WithPermitProhibitedCipherSuites is used to set whether permit prohibited chipher suites.
func WithReadTimeout ¶
WithReadTimeout is used to set the read timeout.