Commit 23afa52c authored by wangxuefeng's avatar wangxuefeng

Fix white space issue.

parent c85ce64a
...@@ -63,17 +63,17 @@ int main(int argc, char* argv[]) { ...@@ -63,17 +63,17 @@ int main(int argc, char* argv[]) {
brpc::ThriftBinaryMessage response; brpc::ThriftBinaryMessage response;
brpc::Controller cntl; brpc::Controller cntl;
// Thrift Req // Thrift Req
example::EchoRequest thrift_request; example::EchoRequest thrift_request;
thrift_request.data = "hello"; thrift_request.data = "hello";
std::string function_name = "Echo"; std::string function_name = "Echo";
int32_t seqid = 0; int32_t seqid = 0;
if (!serilize_thrift_server_message<example::EchoService_Echo_pargs>(thrift_request, function_name, seqid, &request)) { if (!serilize_thrift_server_message<example::EchoService_Echo_pargs>(thrift_request, function_name, seqid, &request)) {
LOG(ERROR) << "serilize_thrift_server_message error!"; LOG(ERROR) << "serilize_thrift_server_message error!";
continue; continue;
} }
cntl.set_log_id(log_id ++); // set by user cntl.set_log_id(log_id ++); // set by user
...@@ -88,20 +88,20 @@ int main(int argc, char* argv[]) { ...@@ -88,20 +88,20 @@ int main(int argc, char* argv[]) {
g_latency_recorder << cntl.latency_us(); g_latency_recorder << cntl.latency_us();
} }
example::EchoResponse thrift_response; example::EchoResponse thrift_response;
if (!deserilize_thrift_server_message<example::EchoService_Echo_presult>(response, &function_name, &seqid, &thrift_response)) { if (!deserilize_thrift_server_message<example::EchoService_Echo_presult>(response, &function_name, &seqid, &thrift_response)) {
LOG(ERROR) << "deserilize_thrift_server_message error!"; LOG(ERROR) << "deserilize_thrift_server_message error!";
continue; continue;
} }
LOG(INFO) << "Thrift function_name: " << function_name LOG(INFO) << "Thrift function_name: " << function_name
<< "Thrift Res data: " << thrift_response.data; << "Thrift Res data: " << thrift_response.data;
LOG_EVERY_SECOND(INFO) LOG_EVERY_SECOND(INFO)
<< "Sending thrift requests at qps=" << g_latency_recorder.qps(1) << "Sending thrift requests at qps=" << g_latency_recorder.qps(1)
<< " latency=" << g_latency_recorder.latency(1); << " latency=" << g_latency_recorder.latency(1);
sleep(1); sleep(1);
} }
LOG(INFO) << "EchoClient is going to quit"; LOG(INFO) << "EchoClient is going to quit";
......
...@@ -52,30 +52,30 @@ public: ...@@ -52,30 +52,30 @@ public:
} }
example::EchoRequest thrift_request; example::EchoRequest thrift_request;
std::string function_name; std::string function_name;
int32_t seqid; int32_t seqid;
// //
if (!serilize_thrift_client_message<example::EchoService_Echo_args>(request, if (!serilize_thrift_client_message<example::EchoService_Echo_args>(request,
&thrift_request, &function_name, &seqid)) { &thrift_request, &function_name, &seqid)) {
cntl->CloseConnection("Close connection due to serilize thrift client reuqest error!"); cntl->CloseConnection("Close connection due to serilize thrift client reuqest error!");
LOG(ERROR) << "serilize thrift client reuqest error!"; LOG(ERROR) << "serilize thrift client reuqest error!";
return; return;
} }
LOG(INFO) << "RPC funcname: " << function_name LOG(INFO) << "RPC funcname: " << function_name
<< "thrift request data: " << thrift_request.data; << "thrift request data: " << thrift_request.data;
example::EchoResponse thrift_response; example::EchoResponse thrift_response;
// Proc RPC , just append a simple string // Proc RPC , just append a simple string
thrift_response.data = thrift_request.data + " world"; thrift_response.data = thrift_request.data + " world";
if (!deserilize_thrift_client_message<example::EchoService_Echo_result>(thrift_response, if (!deserilize_thrift_client_message<example::EchoService_Echo_result>(thrift_response,
function_name, seqid, response)) { function_name, seqid, response)) {
cntl->CloseConnection("Close connection due to deserilize thrift client response error!"); cntl->CloseConnection("Close connection due to deserilize thrift client response error!");
LOG(ERROR) << "deserilize thrift client response error!"; LOG(ERROR) << "deserilize thrift client response error!";
return; return;
} }
LOG(INFO) << "success process thrift request in brpc"; LOG(INFO) << "success process thrift request in brpc";
} }
......
...@@ -32,11 +32,11 @@ int main(int argc, char **argv) { ...@@ -32,11 +32,11 @@ int main(int argc, char **argv) {
google::ParseCommandLineFlags(&argc, &argv, true); google::ParseCommandLineFlags(&argc, &argv, true);
boost::shared_ptr<apache::thrift::transport::TSocket> socket( 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( 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( boost::shared_ptr<apache::thrift::protocol::TProtocol> protocol(
new apache::thrift::protocol::TBinaryProtocol(transport)); new apache::thrift::protocol::TBinaryProtocol(transport));
example::EchoServiceClient client(protocol); example::EchoServiceClient client(protocol);
transport->open(); transport->open();
......
...@@ -31,13 +31,13 @@ DEFINE_int32(port, 8019, "Port of server"); ...@@ -31,13 +31,13 @@ DEFINE_int32(port, 8019, "Port of server");
class EchoServiceHandler : virtual public example::EchoServiceIf { class EchoServiceHandler : virtual public example::EchoServiceIf {
public: 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. // Process request, just attach a simple string.
res.data = req.data + " world"; res.data = req.data + " world";
return; return;
} }
}; };
...@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) { ...@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
apache::thrift::concurrency::PosixThreadFactory::NORMAL, 1, false)); apache::thrift::concurrency::PosixThreadFactory::NORMAL, 1, false));
boost::shared_ptr<apache::thrift::server::TProcessor> processor( 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( boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocol_factory(
new apache::thrift::protocol::TBinaryProtocolFactory()); new apache::thrift::protocol::TBinaryProtocolFactory());
boost::shared_ptr<apache::thrift::transport::TTransportFactory> transport_factory( boost::shared_ptr<apache::thrift::transport::TTransportFactory> transport_factory(
...@@ -68,5 +68,5 @@ int main(int argc, char *argv[]) { ...@@ -68,5 +68,5 @@ int main(int argc, char *argv[]) {
protocol_factory, FLAGS_port, thread_mgr); protocol_factory, FLAGS_port, thread_mgr);
server.serve(); server.serve();
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment