-
Notifications
You must be signed in to change notification settings - Fork 237
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
Update service_dependency.go to accept a context.Context #293
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@stmcallister let me know what you think of these methods not including the
*http.Response
. As far as I can tell there isn't a need for the consumer to have the response.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.
I believe I included
*http.Response
so that folks could get information about the Response, status codes and messages, etc. But, it sounds like the context will provide some of this functionality?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.
@stmcallister Not the
context
, I think the newAPIError
type we created will take care of that. Since that should contain all errors in the JSON response, as well as the HTTP status code. If the call returns anil
error value, consumers should assume it's a2xx
response code. If theerror
value is non-nil, then they can assume it was>299
and inspect the actual error if they really want to know.The way the
*http.Response
support is implemented today consumers could only get the status code and HTTP headers, but they cannot read the HTTP response body. By default thehttp.Response.Body
can only be read once, which we do indecodeJSON
. Attempts to read it again by callers would result in anio.EOF
error, and so the*http.Response
we return today isn't very useful, especially because there don't appear to be any documented HTTP response headers that consumers would care about.We could fix that bug and make the
*http.Response
useful for consumers, but since there are no documented response headers and we handle the HTTP status code (for failures) in theAPIError
type, I think we should lean-away from returning the*http.Response
and potentially include its removal in our breaking changes inv1.5
, since the returned*http.Response
never fully worked.I'm tracking the removal here: #305
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.
Ah, okay. That makes sense. Thanks for the explanation.