MCPcopy Create free account
hub / github.com/apache/brpc / Echo

Method Echo

test/brpc_server_unittest.cpp:127–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 EchoServiceImpl() : count(0) {}
126 virtual ~EchoServiceImpl() { g_delete = true; }
127 virtual void Echo(google::protobuf::RpcController* cntl_base,
128 const test::EchoRequest* request,
129 test::EchoResponse* response,
130 google::protobuf::Closure* done) {
131 brpc::ClosureGuard done_guard(done);
132 brpc::Controller* cntl = (brpc::Controller*)cntl_base;
133 count.fetch_add(1, butil::memory_order_relaxed);
134 EXPECT_EQ(EXP_REQUEST, request->message());
135 response->set_message(EXP_RESPONSE);
136 if (request->sleep_us() > 0) {
137 LOG(INFO) << "Sleep " << request->sleep_us() << " us, protocol="
138 << cntl->request_protocol();
139 bthread_usleep(request->sleep_us());
140 } else {
141 LOG(INFO) << "No sleep, protocol=" << cntl->request_protocol();
142 }
143 if (cntl->has_request_user_fields()) {
144 ASSERT_TRUE(!cntl->request_user_fields()->empty());
145 std::string* val = cntl->request_user_fields()->seek(EXP_USER_FIELD_KEY);
146 ASSERT_TRUE(val != NULL);
147 ASSERT_EQ(*val, EXP_USER_FIELD_VALUE);
148 cntl->response_user_fields()->insert(EXP_USER_FIELD_KEY, EXP_USER_FIELD_VALUE);
149 }
150 }
151
152 virtual void ComboEcho(google::protobuf::RpcController*,
153 const test::ComboRequest* request,

Callers

nothing calls this directly

Calls 10

bthread_usleepFunction · 0.85
fetch_addMethod · 0.80
request_protocolMethod · 0.80
request_user_fieldsMethod · 0.80
response_user_fieldsMethod · 0.80
messageMethod · 0.45
emptyMethod · 0.45
seekMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected