-
Notifications
You must be signed in to change notification settings - Fork 240
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
Conversation
This also updates the new methods to not return the `*http.Response`, as it doesn't seem needed. Updates #267
} | ||
|
||
// ListBusinessServiceDependenciesWithContext lists dependencies of a business service. | ||
func (c *Client) ListBusinessServiceDependenciesWithContext(ctx context.Context, businessServiceID string) (*ListServiceDependencies, error) { |
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 new APIError
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 a nil
error value, consumers should assume it's a 2xx
response code. If the error
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 the http.Response.Body
can only be read once, which we do in decodeJSON
. Attempts to read it again by callers would result in an io.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 the APIError
type, I think we should lean-away from returning the *http.Response
and potentially include its removal in our breaking changes in v1.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.
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.
Looks good! 👍
This also updates the new methods to not return the
*http.Response
, as itdoesn't seem needed.
Updates #267