You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem with the Timeout field on the ovh.Client struct. While it may be convenient for simple use case, it introduces an unexpected behaviour: it always overrides the http.Client.Timeout, with a default values of 3 minutes (when using the ovh.Client "constructor").
For example, with the following code, despite creating a client with a 30s timeout, the actual timeout will be of 3 minutes.
type MyClient struct {
ovh.Client
// other fields
}
// Here I only want to expose httpClient because this is a great abstraction and one that is
// conventionally use to allows users of a library to customize everything regarding the HTTP stuff.
func NewClient(httpClient http.Client) *MyClient {
client := ovh.NewClient(...)
client.Client = httpClient
// This is weird
if httpClient.Timeout {
client.Timeout = httpClient.Timeout
}
// other stuff
// ...
return client
}
I feel like ovh.Client.Timeout creates more problems that it solves. So in case of a potential v2 (because removing the field would be a breaking chance), I think this field should be removed.
The text was updated successfully, but these errors were encountered:
Hello,
I have a problem with the Timeout field on the
ovh.Client
struct. While it may be convenient for simple use case, it introduces an unexpected behaviour: it always overrides thehttp.Client.Timeout
, with a default values of 3 minutes (when using the ovh.Client "constructor").For example, with the following code, despite creating a client with a 30s timeout, the actual timeout will be of 3 minutes.
Now let's say, I want to wrap
ovh.Client
.I feel like
ovh.Client.Timeout
creates more problems that it solves. So in case of a potential v2 (because removing the field would be a breaking chance), I think this field should be removed.The text was updated successfully, but these errors were encountered: