-
Notifications
You must be signed in to change notification settings - Fork 4k
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
send response之后,request/response对象析构之前执行一些自定义逻辑 #2328
Merged
Merged
Conversation
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
yockie
changed the title
response返回之后,request/response析构之前执行一些自定义逻辑
send response之后,request/response析构之前执行一些自定义逻辑
Jul 25, 2023
yockie
changed the title
send response之后,request/response析构之前执行一些自定义逻辑
send response之后,request/response对象析构之前执行一些自定义逻辑
Jul 25, 2023
wwbmmm
reviewed
Jul 26, 2023
另外,补充一下单测吧 |
done |
之前单测写的不对,已经修改了,本地跑通了 |
wwbmmm
reviewed
Aug 2, 2023
LGTM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What problem does this PR solve?
1.我们的场景希望将响应时间减少到最小,所以希望将一些类似数据上报的耗时操作(是的,特别耗时)放在response返回之后、request/response析构之前做
2.本pr借鉴了 #1433 ,看这个pr一直没合入且测试发现有些问题&不太满足我们的需要,所以另提一个。 #1433 的问题主要是:
(1)太多无关topic的改动
(2)仅在SendRpcResponse成功时才调用call_after_rpc_resp函数,失败时没有调用(我们需要无论成功或失败都要调用)
(3)定义的after_resp_fn_t不包含controller指针,我们需要拿到controller对象(进而拿到session data指针,所以声明为非const指针)
3.同样在目前在常用的 baidu_std/http/http2 协议上支持。其他协议未开发。
4.将Controller与req、res的析构顺序进行了修改,依赖关系应该是controller依赖req、res,所以应该先析构controller,后析构req、res
麻烦maintainers看看有什么不妥之处~