-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Proposal to make http response structs public #571
Comments
Per that issue, these are internals and I don't think we should encourage users to depend on them and then break when we make changes. |
These structs in the client aren't really internals, they are the struct
representation of the API, which has some compatibility guarantees. As it
stands now everyone (including this client) copy/pastes the structs, since
this is a client library I don't see why we can't expose them.
…On Wed, May 8, 2019, 1:28 AM Brian Brazil ***@***.***> wrote:
Per that issue, these are internals and I don't think we should encourage
users to depend on them and then break when we make changes.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#571 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMLPHOMDW2UYA6I2VZ5JSLPUKFLJANCNFSM4HLOC6GQ>
.
|
The API has some guarantees, those structs are internals and do not. |
What are the guarantees on the API? From my understanding its the (1) response codes and (2) response bodies. These structs are just the go representation of the response body. I can understand that you wouldn't want to have clients importing the structs used in the server directly, but I don't see a reason that you wouldn't want to expose them from the go client (since it is doing the same thing). |
If client_golang wants to make them public that's a different thing, however I'd hope we'd isolate users of this package from those details. |
This issue is only about client_golang; @krasi-georgiev thoughts? |
Would you mind giving some code example to illustrate the problem and how it will be solved by exposing these structs? |
Sure, the common issue is that a variety of other services need these structs so we all end up copy/pasting. A few examples: |
Thanks. I am quite influenced by the talk from William Kenedy which advocates that importing a package should be strictly for its functionality and never for its types. |
If the types were exported these other systems wouldn't need to redefine the structs. So instead of having local struct definitions (which all have to be copied etc.) they could simply import them.
In general I'd agree with this, but in this particular case the functionality we are looking for is handling the responses from the HTTP endpoint -- which in go is done by tags in structs. Especially when you look at things like |
I also see the big benefit for this, but the fact that at the end the users will still import the package just for these exported structs and not for its functionality will cause an additional dependency and limit portability. It is the same as the problem described in this part of the talk which has proven to be a bad idea long term. The benefits of avoiding duplicating types in different packages are great, but isolation and portability is a better argument to keep these unexported I think. Of course I might be wrong so happy to read more opinions. |
With six weeks of no opinions added here, I'm closing this, as both @krasi-georgiev and @brian-brazil are seeing the trade-off as being better to not export the structs. Whoever wants to add something new to the debate, please follow up. |
Reference upstream issue: prometheus/prometheus#3615
TLDR; these http structs are currently private, people use them in a lot of packages -- it would be great if we exposed them so others who want to do their own projects don't have to copy/paste the structs from the prometheus/prometheus project.
Thoughts?
The text was updated successfully, but these errors were encountered: