| 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, |
nothing calls this directly
no test coverage detected