-
Notifications
You must be signed in to change notification settings - Fork 197
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
transport: Introduce NewHTTPTransportOptions #1168
transport: Introduce NewHTTPTransportOptions #1168
Conversation
Introduces a new `transport.NewHTTPTransportOptions()` function which accepts an Options struct to be able to customize the `httptransport` without using environment variables Signed-off-by: Marc Lopez Rubio <[email protected]>
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
transport/http.go
Outdated
} | ||
t.SetServerURL(serverURLs...) | ||
t.SetServerURL(opts.ServerURLs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIANM this will panic if HTTPTransportOptions.ServerURLs is empty. This should probably also return an error.
Maybe worth adding a Validate method, like:
func (o HTTPTransportOptions) Validate() error {
if len(o.ServerURLs) == 0 {
// ...
}
if len(o.ServerTimeout) < 0 {
// ...
}
return nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion NewHTTPTransport
and NewHTTPTransportOptions
should deliever the same default values for non-customized options, so also ensure that the same default values for ServerURLs
and ServerTimeout
are set.
Can you please add a test for when using NewHTTPTransportOptions
?
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple of minor things
Signed-off-by: Marc Lopez Rubio <[email protected]>
Description
Introduces a new
transport.NewHTTPTransportOptions()
function whichaccepts an Options struct to be able to customize the
httptransport
without using environment variables