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

Refactoring: move all http.Transport configuration parameter parsing into one place #4624

Open
GiedriusS opened this issue Sep 1, 2021 · 9 comments

Comments

@GiedriusS
Copy link
Member

GiedriusS commented Sep 1, 2021

These are all functions/structs for configuring the same thing:

func DefaultTransport(config Config) *http.Transport {

func DefaultTransport(c HTTPConfig) *http.Transport {

func DefaultTransport(config Config) *http.Transport {

Another place being added: #4623

Move them into one struct. This probably belongs in exthttp.

@heysujal
Copy link

heysujal commented Sep 1, 2021

@GiedriusS I would like to fix this issue. Please guide me how can I get started , I am new to this project.

@GiedriusS
Copy link
Member Author

All of these functions and structs can be joined into one and we can use them everywhere consistently. Please let me know if you have any specific questions.

@4molybdenum2
Copy link
Contributor

So will replacing the NewTransport() function in exhttp with something like this help?

func NewTransport(config HTTPConfig) *http.Transport {
	return &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		DialContext: (&net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
			DualStack: true,
		}).DialContext,

		MaxIdleConns:          config.MaxIdleConns,
		MaxIdleConnsPerHost:   config.MaxIdleConnsPerHost,
		IdleConnTimeout:       time.Duration(config.IdleConnTimeout),
		MaxConnsPerHost:       config.MaxConnsPerHost,
		TLSHandshakeTimeout:   time.Duration(config.TLSHandshakeTimeout),
		ExpectContinueTimeout: time.Duration(config.ExpectContinueTimeout),
		ResponseHeaderTimeout: time.Duration(config.ResponseHeaderTimeout),
		DisableCompression:	config.DisableCompression,
		TLSClientConfig:	&tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
	}
}

@Namanl2001
Copy link
Contributor

Namanl2001 commented Sep 10, 2021

So will replacing the NewTransport() function in exhttp with something like this help?

@4molybdenum2 I think replacing NewTransport() would not be helpful as it serves a different purpose, rather you can try creating a new func DefaultTransport() in exhttp, may be with the same return values as you proposed above, in the comment :)

@4molybdenum2
Copy link
Contributor

Ok, will check this out, maybe make a PR...

@stale
Copy link

stale bot commented Apr 17, 2022

Hello 👋 Looks like there was no activity on this issue for the last two months.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity in the next two weeks, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Apr 17, 2022
@GiedriusS GiedriusS removed the stale label Apr 17, 2022
@bwplotka
Copy link
Member

AC:

  • There is only single HTTPConfig struct that can be unmarshalled from YAML in the consistent way.
  • There is only single reused helper for creating Transport from this HTTPConfig
  • We don't break Cortex deps

@SrushtiSapkale
Copy link
Contributor

I am working on this issue🙌

@NishantBansal2003
Copy link
Contributor

Hey @saswatamcode,This issue can be closed with reference to the above merged PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants