Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
23afa52c
Commit
23afa52c
authored
Nov 06, 2017
by
wangxuefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix white space issue.
parent
c85ce64a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
48 deletions
+48
-48
client.cpp
example/thrift_extension_c++/client.cpp
+20
-20
server.cpp
example/thrift_extension_c++/server.cpp
+18
-18
thrift_client.cpp
example/thrift_extension_c++/thrift_client.cpp
+3
-3
thrift_server.cpp
example/thrift_extension_c++/thrift_server.cpp
+7
-7
No files found.
example/thrift_extension_c++/client.cpp
View file @
23afa52c
...
...
@@ -63,17 +63,17 @@ int main(int argc, char* argv[]) {
brpc
::
ThriftBinaryMessage
response
;
brpc
::
Controller
cntl
;
// Thrift Req
example
::
EchoRequest
thrift_request
;
thrift_request
.
data
=
"hello"
;
std
::
string
function_name
=
"Echo"
;
int32_t
seqid
=
0
;
if
(
!
serilize_thrift_server_message
<
example
::
EchoService_Echo_pargs
>
(
thrift_request
,
function_name
,
seqid
,
&
request
))
{
LOG
(
ERROR
)
<<
"serilize_thrift_server_message error!"
;
continue
;
}
// Thrift Req
example
::
EchoRequest
thrift_request
;
thrift_request
.
data
=
"hello"
;
std
::
string
function_name
=
"Echo"
;
int32_t
seqid
=
0
;
if
(
!
serilize_thrift_server_message
<
example
::
EchoService_Echo_pargs
>
(
thrift_request
,
function_name
,
seqid
,
&
request
))
{
LOG
(
ERROR
)
<<
"serilize_thrift_server_message error!"
;
continue
;
}
cntl
.
set_log_id
(
log_id
++
);
// set by user
...
...
@@ -88,20 +88,20 @@ int main(int argc, char* argv[]) {
g_latency_recorder
<<
cntl
.
latency_us
();
}
example
::
EchoResponse
thrift_response
;
if
(
!
deserilize_thrift_server_message
<
example
::
EchoService_Echo_presult
>
(
response
,
&
function_name
,
&
seqid
,
&
thrift_response
))
{
LOG
(
ERROR
)
<<
"deserilize_thrift_server_message error!"
;
continue
;
}
example
::
EchoResponse
thrift_response
;
if
(
!
deserilize_thrift_server_message
<
example
::
EchoService_Echo_presult
>
(
response
,
&
function_name
,
&
seqid
,
&
thrift_response
))
{
LOG
(
ERROR
)
<<
"deserilize_thrift_server_message error!"
;
continue
;
}
LOG
(
INFO
)
<<
"Thrift function_name: "
<<
function_name
<<
"Thrift Res data: "
<<
thrift_response
.
data
;
LOG
(
INFO
)
<<
"Thrift function_name: "
<<
function_name
<<
"Thrift Res data: "
<<
thrift_response
.
data
;
LOG_EVERY_SECOND
(
INFO
)
<<
"Sending thrift requests at qps="
<<
g_latency_recorder
.
qps
(
1
)
<<
" latency="
<<
g_latency_recorder
.
latency
(
1
);
sleep
(
1
);
sleep
(
1
);
}
LOG
(
INFO
)
<<
"EchoClient is going to quit"
;
...
...
example/thrift_extension_c++/server.cpp
View file @
23afa52c
...
...
@@ -52,30 +52,30 @@ public:
}
example
::
EchoRequest
thrift_request
;
std
::
string
function_name
;
int32_t
seqid
;
//
if
(
!
serilize_thrift_client_message
<
example
::
EchoService_Echo_args
>
(
request
,
&
thrift_request
,
&
function_name
,
&
seqid
))
{
cntl
->
CloseConnection
(
"Close connection due to serilize thrift client reuqest error!"
);
LOG
(
ERROR
)
<<
"serilize thrift client reuqest error!"
;
std
::
string
function_name
;
int32_t
seqid
;
//
if
(
!
serilize_thrift_client_message
<
example
::
EchoService_Echo_args
>
(
request
,
&
thrift_request
,
&
function_name
,
&
seqid
))
{
cntl
->
CloseConnection
(
"Close connection due to serilize thrift client reuqest error!"
);
LOG
(
ERROR
)
<<
"serilize thrift client reuqest error!"
;
return
;
}
}
LOG
(
INFO
)
<<
"RPC funcname: "
<<
function_name
<<
"thrift request data: "
<<
thrift_request
.
data
;
LOG
(
INFO
)
<<
"RPC funcname: "
<<
function_name
<<
"thrift request data: "
<<
thrift_request
.
data
;
example
::
EchoResponse
thrift_response
;
// Proc RPC , just append a simple string
example
::
EchoResponse
thrift_response
;
// Proc RPC , just append a simple string
thrift_response
.
data
=
thrift_request
.
data
+
" world"
;
if
(
!
deserilize_thrift_client_message
<
example
::
EchoService_Echo_result
>
(
thrift_response
,
function_name
,
seqid
,
response
))
{
cntl
->
CloseConnection
(
"Close connection due to deserilize thrift client response error!"
);
LOG
(
ERROR
)
<<
"deserilize thrift client response error!"
;
if
(
!
deserilize_thrift_client_message
<
example
::
EchoService_Echo_result
>
(
thrift_response
,
function_name
,
seqid
,
response
))
{
cntl
->
CloseConnection
(
"Close connection due to deserilize thrift client response error!"
);
LOG
(
ERROR
)
<<
"deserilize thrift client response error!"
;
return
;
}
}
LOG
(
INFO
)
<<
"success process thrift request in brpc"
;
}
...
...
example/thrift_extension_c++/thrift_client.cpp
View file @
23afa52c
...
...
@@ -32,11 +32,11 @@ int main(int argc, char **argv) {
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
boost
::
shared_ptr
<
apache
::
thrift
::
transport
::
TSocket
>
socket
(
new
apache
::
thrift
::
transport
::
TSocket
(
FLAGS_server
,
FLAGS_port
));
new
apache
::
thrift
::
transport
::
TSocket
(
FLAGS_server
,
FLAGS_port
));
boost
::
shared_ptr
<
apache
::
thrift
::
transport
::
TTransport
>
transport
(
new
apache
::
thrift
::
transport
::
TFramedTransport
(
socket
));
new
apache
::
thrift
::
transport
::
TFramedTransport
(
socket
));
boost
::
shared_ptr
<
apache
::
thrift
::
protocol
::
TProtocol
>
protocol
(
new
apache
::
thrift
::
protocol
::
TBinaryProtocol
(
transport
));
new
apache
::
thrift
::
protocol
::
TBinaryProtocol
(
transport
));
example
::
EchoServiceClient
client
(
protocol
);
transport
->
open
();
...
...
example/thrift_extension_c++/thrift_server.cpp
View file @
23afa52c
...
...
@@ -31,13 +31,13 @@ DEFINE_int32(port, 8019, "Port of server");
class
EchoServiceHandler
:
virtual
public
example
::
EchoServiceIf
{
public
:
EchoServiceHandler
()
{}
EchoServiceHandler
()
{}
void
Echo
(
example
::
EchoResponse
&
res
,
const
example
::
EchoRequest
&
req
)
{
void
Echo
(
example
::
EchoResponse
&
res
,
const
example
::
EchoRequest
&
req
)
{
// Process request, just attach a simple string.
res
.
data
=
req
.
data
+
" world"
;
return
;
}
res
.
data
=
req
.
data
+
" world"
;
return
;
}
};
...
...
@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
apache
::
thrift
::
concurrency
::
PosixThreadFactory
::
NORMAL
,
1
,
false
));
boost
::
shared_ptr
<
apache
::
thrift
::
server
::
TProcessor
>
processor
(
new
example
::
EchoServiceProcessor
(
handler
));
new
example
::
EchoServiceProcessor
(
handler
));
boost
::
shared_ptr
<
apache
::
thrift
::
protocol
::
TProtocolFactory
>
protocol_factory
(
new
apache
::
thrift
::
protocol
::
TBinaryProtocolFactory
());
boost
::
shared_ptr
<
apache
::
thrift
::
transport
::
TTransportFactory
>
transport_factory
(
...
...
@@ -68,5 +68,5 @@ int main(int argc, char *argv[]) {
protocol_factory
,
FLAGS_port
,
thread_mgr
);
server
.
serve
();
return
0
;
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment