Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS handshake timeout override #30

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ type Client struct {
}

type ClientConfig struct {
Email string
Token string
Timeout time.Duration
Retries int
API *url.URL
Proxy *url.URL
Email string
Token string
Timeout time.Duration
TLSHandshakeTimeout time.Duration
Retries int
API *url.URL
Proxy *url.URL

Logger interface{}
}
Expand Down Expand Up @@ -62,6 +63,10 @@ func NewClient(config ClientConfig) *Client {
DisableCompression: false,
}

if config.TLSHandshakeTimeout.Seconds() > 0 {
transport.TLSHandshakeTimeout = config.TLSHandshakeTimeout
}

retryClient := retryablehttp.NewClient()
retryClient.HTTPClient.Transport = transport
retryClient.RetryWaitMin = config.Timeout
Expand Down
36 changes: 21 additions & 15 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ import (

// Config describes the libkflow configuration.
type Config struct {
email string
token string
capture Capture
proxy *url.URL
api *url.URL
flow *url.URL
metrics *url.URL
sample int
timeout time.Duration
retries int
logger interface{}
program string
version string
registry go_metrics.Registry
useInternalErrors bool
email string
token string
capture Capture
proxy *url.URL
api *url.URL
flow *url.URL
metrics *url.URL
sample int
timeout time.Duration
tlsHandshakeTimeout time.Duration
retries int
logger interface{}
program string
version string
registry go_metrics.Registry
useInternalErrors bool

metricsPrefix string
metricsInterval time.Duration
Expand Down Expand Up @@ -93,6 +94,11 @@ func (c *Config) SetTimeout(timeout time.Duration) {
c.timeout = timeout
}

// SetTLSHandshakeTimeout sets the TLSHandshakeTimeout on the http client's Transport
func (c *Config) SetTLSHandshakeTimeout(timeout time.Duration) {
c.tlsHandshakeTimeout = timeout
}

// SetRetries sets the number of times to try HTTP requests.
func (c *Config) SetRetries(retries int) {
c.retries = retries
Expand Down
Loading