github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/pkg/proxy/transport/options.go (about)

     1  package transport
     2  
     3  import (
     4  	"time"
     5  )
     6  
     7  // Option represents the transport options
     8  type Option func(*transport)
     9  
    10  // WithInsecureSkipVerify sets tls config insecure skip verify
    11  func WithInsecureSkipVerify(value bool) Option {
    12  	return func(t *transport) {
    13  		t.insecureSkipVerify = value
    14  	}
    15  }
    16  
    17  // WithDialTimeout sets the dial context timeout
    18  func WithDialTimeout(d time.Duration) Option {
    19  	return func(t *transport) {
    20  		t.dialTimeout = d
    21  	}
    22  }
    23  
    24  // WithResponseHeaderTimeout sets the response header timeout
    25  func WithResponseHeaderTimeout(d time.Duration) Option {
    26  	return func(t *transport) {
    27  		t.responseHeaderTimeout = d
    28  	}
    29  }
    30  
    31  // WithIdleConnTimeout sets the maximum amount of time an idle
    32  // (keep-alive) connection will remain idle before closing
    33  // itself.
    34  func WithIdleConnTimeout(d time.Duration) Option {
    35  	return func(t *transport) {
    36  		t.idleConnTimeout = d
    37  	}
    38  }
    39  
    40  // WithIdleConnPurgeTicker purges idle connections on every interval if set
    41  // this is done to prevent permanent keep-alive on connections with high ops
    42  func WithIdleConnPurgeTicker(ticker *time.Ticker) Option {
    43  	return func(t *transport) {
    44  		t.idleConnPurgeTicker = ticker
    45  	}
    46  }