gojek / heimdall

An enhanced HTTP client for Go
http://gojek.tech
Apache License 2.0
2.63k stars 214 forks source link

Functional Options support #31

Closed italolelis closed 6 years ago

italolelis commented 6 years ago

Hello,

Thank you a lot for this amazing library, it's really useful and well thought. How would you feel about supporting function options? Something like this:

hystrixClient := heimdall.NewHystrixHTTPClient(
    timeout,
    heimdall.WithCommandName("MyCommand"),
    heimdall.WithHystrixTimeout(1100),
    heimdall.WithMaxConcurrentRequests(100),
    heimdall.WithErrorPercentThreshold(25),
    heimdall.WithSleepWindow(10),
    heimdall.WithRequestVolumeThreshold(10),
    heimdall.WithHystrixRetryCount(2),
    heimdall.WithHystrixRetrier(heimdall.NewRetrier(heimdall.NewConstantBackoff(10, 5))),
)

Is this something you'd like to see in the lib? If yes I can send a PR with it.

Thanks again!

rShetty commented 6 years ago

Hey @italolelis I think it makes sense. Can you go ahead with the PR

italolelis commented 6 years ago

Closing this issue as #33 is already merged 🎉