-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add transport response callback #175
base: master
Are you sure you want to change the base?
Conversation
type ctxKey uint8 | ||
|
||
const ( | ||
ctxRespCallbackKey ctxKey = iota + 1 |
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.
Please use an empty struct, as a more connonical way
@@ -287,6 +287,12 @@ func (c *conn) doRequest(ctx context.Context, req *http.Request) (io.ReadCloser, | |||
// response | |||
return nil, newError(string(msg)) | |||
} | |||
|
|||
if err = callCtxRespCallback(ctx, req, resp); err != nil { |
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.
Could we move this callback higher so non 200 calls also get invoced?
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.
an error in callback should not fail the response to the database.
Thanks for your contribution! Added small comments. Nothing Major |
ctxRespCallbackKey ctxKey = iota + 1 | ||
) | ||
|
||
// RespCallback is a transport response callback. |
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.
Could you add a comment when it is invoked and in what cases
) | ||
|
||
// RespCallback is a transport response callback. | ||
type RespCallback func(*http.Request, *http.Response) 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.
RespCallback is short for a response callback, nothing stated about the request. Maybe we should call it TransportCallback
Adding the ability to handle transport response