Skip to content
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

improve docs for response handlers #164

Merged
merged 2 commits into from May 11, 2022
Merged

improve docs for response handlers #164

merged 2 commits into from May 11, 2022

Conversation

gavriel-hc
Copy link
Contributor

The new "retryable response handler" functionality can be confusing to use, so this PR

  • removes the description and toy example from the README (to reduce the risk of people using it with minimal consideration)
  • adds some notes about recommended use to the comments on the type

Copy link
Member

@ryanuber ryanuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better, I like it! Just a few suggestions.

client.go Outdated
// If an error is returned, the client's retry policy will be used to determine whether to retry the whole request.
// If an error is returned, the client's retry policy will be used to determine
// whether to retry the whole request (including this handler).
// NOTE: It only runs if the initial part of the request was successful.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"initial part of the request" and "successful" might be hard to follow. I would say:

The ResponseHandlerFunc is called when the HTTP client successfully receives a response and the CheckRetry function indicates that a retry of the base request is not necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also just a nitpick - I think it's fine to just flow these like a normal sentence in the description rather than marking them specifically as NOTE:.

client.go Outdated
// whether to retry the whole request (including this handler).
// NOTE: It only runs if the initial part of the request was successful.
// Make sure to check status codes! Even if the request was "successful" it may have a non-2xx status code.
// NOTE: If there is a response body, users should make sure to close it to avoid a memory leak.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will always be a response body to close when this function is called. That doesn't necessarily mean that the handler has to close it - that could also be done by the caller in certain cases. Maybe:

The response body is not automatically closed. It must be closed either by the ResponseHandlerFunc or by the caller out-of-band. Failure to do so will result in a memory leak.

@gavriel-hc gavriel-hc requested a review from ryanuber May 10, 2022 17:30
Copy link
Member

@ryanuber ryanuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@gavriel-hc gavriel-hc merged commit 493aa4c into master May 11, 2022
@gavriel-hc gavriel-hc deleted the docs branch May 11, 2022 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants