-
Notifications
You must be signed in to change notification settings - Fork 654
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
sofa-pbrpc cookie #81
Open
zd-double
wants to merge
14
commits into
baidu:master
Choose a base branch
from
zd-double:baidu-branch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,322
−20
Open
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8209820
add rpc cookie
zd-double 0b5c186
add rpc cookie
zd-double 1afbaad
add rpc cookie
zd-double eacf6ef
remove client_http.sh
zd-double 17bb28f
delete test code
zd-double 8acb2db
remove test code
zd-double b87a47d
update serializer
zd-double 0b75c92
change implementation of rpc cookie
zd-double a4e17b0
change implementation of rpc cookie
zd-double b942f9b
update the interface about attachment in rpc controller
zd-double df163b7
merge Makefile
zd-double 9aeb14c
improve the interfaces about cookie
zd-double 4fcca08
remove redundant func
zd-double 3ca5c48
improve implementation of append attach buffer
zd-double File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,12 @@ | |
// Author: [email protected] (Qin Zuoyan) | ||
|
||
#include <sofa/pbrpc/pbrpc.h> | ||
#include <sofa/pbrpc/plugin/cookie/rpc_cookie.h> | ||
#include "echo_service.pb.h" | ||
|
||
typedef sofa::pbrpc::shared_ptr<sofa::pbrpc::Cookie> CookiePtr; | ||
sofa::pbrpc::RpcCookieManager cookie_manager; | ||
|
||
// Using global RpcClient object can help share resources such as threads and buffers. | ||
sofa::pbrpc::RpcClient g_rpc_client; | ||
|
||
|
@@ -21,6 +25,11 @@ int main() | |
// Prepare parameters. | ||
sofa::pbrpc::RpcController* cntl = new sofa::pbrpc::RpcController(); | ||
cntl->SetTimeout(3000); | ||
CookiePtr cookie(new sofa::pbrpc::Cookie(&cookie_manager)); | ||
cookie->Load(); | ||
cookie->Set("type", "sync"); | ||
cookie->Set("logid", "123456"); | ||
cntl->SetRequestAttachment(cookie.get()); | ||
sofa::pbrpc::test::EchoRequest* request = | ||
new sofa::pbrpc::test::EchoRequest(); | ||
request->set_message("Hello from qinzuoyan01"); | ||
|
@@ -50,6 +59,14 @@ int main() | |
else | ||
{ | ||
SLOG(NOTICE, "request succeed: %s", response->message().c_str()); | ||
cookie.reset(new sofa::pbrpc::Cookie(&cookie_manager)); | ||
if (cntl->GetResponseAttachment(cookie.get())) | ||
{ | ||
std::string version; | ||
cookie->Get("version", version); | ||
SLOG(NOTICE, "cookie version=%s", version.c_str()); | ||
cookie->Store(); | ||
} | ||
} | ||
|
||
// Destroy objects. | ||
|
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
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
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
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
Oops, something went wrong.
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.
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.
这个接口是否有必要