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

Add transport response callback #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

egnd
Copy link

@egnd egnd commented Jan 23, 2024

Adding the ability to handle transport response

type ctxKey uint8

const (
ctxRespCallbackKey ctxKey = iota + 1
Copy link
Collaborator

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 {
Copy link
Collaborator

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?

Copy link
Collaborator

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.

@DoubleDi
Copy link
Collaborator

DoubleDi commented Feb 2, 2024

Thanks for your contribution! Added small comments. Nothing Major

ctxRespCallbackKey ctxKey = iota + 1
)

// RespCallback is a transport response callback.
Copy link
Collaborator

@DoubleDi DoubleDi Feb 2, 2024

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
Copy link
Collaborator

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

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