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

No way to parse proxies / http transport with hystrix client? #102

Open
JonathanSlowwe opened this issue Jan 1, 2021 · 1 comment
Open

Comments

@JonathanSlowwe
Copy link

This is my hystrix client:


client := hystrix.NewClient(
	hystrix.WithHTTPTimeout(1*time.Millisecond),
	hystrix.WithCommandName("request"),
	hystrix.WithHystrixTimeout(10*time.Millisecond),
	hystrix.WithMaxConcurrentRequests(600),
	hystrix.WithErrorPercentThreshold(20),
)

I cant seem a way to parse in proxies so it sends requests from different IP addresses.
This is how I would do it in net/http:


proxy := "http://" + selectProxy
proxyURL, _ := url.Parse(proxy)
transport := &http.Transport{Proxy: http.ProxyURL(proxyURL)}

client := &http.Client{Transport: transport, Timeout: 5 * time.Second}


Any help or tips to parse in the http transport/ dial or proxies with the hystrix client would be appreciated.

@markphelps
Copy link

Couldn't you use the Custom HTTP client functionality like so?

type myHTTPClient struct {
	client http.Client
}

func (c *myHTTPClient) Do(request *http.Request) (*http.Response, error) {
	return c.client.Do(request)
}

proxy := "http://" + selectProxy
proxyURL, _ := url.Parse(proxy)
transport := &http.Transport{Proxy: http.ProxyURL(proxyURL)}

httpclient.NewClient(httpclient.WithHTTPClient(&myHTTPClient{client: &http.Client{Transport: transport, Timeout: 5 * time.Second}}))

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

No branches or pull requests

2 participants