| 1691 | class BaiduMasterServiceImpl : public brpc::BaiduMasterService { |
| 1692 | public: |
| 1693 | void ProcessRpcRequest(brpc::Controller* cntl, |
| 1694 | const brpc::SerializedRequest* request, |
| 1695 | brpc::SerializedResponse* response, |
| 1696 | ::google::protobuf::Closure* done) override { |
| 1697 | // This object helps you to call done->Run() in RAII style. If you need |
| 1698 | // to process the request asynchronously, pass done_guard.release(). |
| 1699 | brpc::ClosureGuard done_guard(done); |
| 1700 | ASSERT_NE(nullptr, cntl->sampled_request()); |
| 1701 | ASSERT_TRUE(cntl->sampled_request()->meta.has_service_name()); |
| 1702 | ASSERT_EQ(test::EchoService::descriptor()->full_name(), |
| 1703 | cntl->sampled_request()->meta.service_name()); |
| 1704 | ASSERT_TRUE(cntl->sampled_request()->meta.has_method_name()); |
| 1705 | ASSERT_EQ("Echo", cntl->sampled_request()->meta.method_name()); |
| 1706 | brpc::ContentType content_type = cntl->request_content_type(); |
| 1707 | brpc::CompressType compress_type = cntl->request_compress_type(); |
| 1708 | brpc::ChecksumType checksum_type = cntl->request_checksum_type(); |
| 1709 | |
| 1710 | test::EchoRequest echo_request; |
| 1711 | test::EchoResponse echo_response; |
| 1712 | ASSERT_TRUE(brpc::policy::DeserializeRpcMessage( |
| 1713 | request->serialized_data(), *cntl, content_type, compress_type, |
| 1714 | checksum_type, &echo_request)); |
| 1715 | ASSERT_EQ(EXP_REQUEST, echo_request.message()); |
| 1716 | ASSERT_EQ(EXP_REQUEST, cntl->request_attachment().to_string()); |
| 1717 | |
| 1718 | content_type = (brpc::ContentType)_content_type_index; |
| 1719 | compress_type = (brpc::CompressType)_compress_type_index; |
| 1720 | ++_compress_type_index; |
| 1721 | if (_compress_type_index == brpc::COMPRESS_TYPE_LZ4) { |
| 1722 | ++_compress_type_index; |
| 1723 | } |
| 1724 | if (_compress_type_index > brpc::CompressType_MAX) { |
| 1725 | _compress_type_index = brpc::CompressType_MIN; |
| 1726 | |
| 1727 | ++_content_type_index; |
| 1728 | if (_content_type_index > brpc::ContentType_MAX) { |
| 1729 | _content_type_index = brpc::ContentType_MIN; |
| 1730 | } |
| 1731 | } |
| 1732 | |
| 1733 | cntl->set_response_content_type(content_type); |
| 1734 | cntl->set_response_compress_type(compress_type); |
| 1735 | cntl->set_response_checksum_type(checksum_type); |
| 1736 | cntl->response_attachment().append(EXP_RESPONSE); |
| 1737 | echo_response.set_message(EXP_RESPONSE); |
| 1738 | ASSERT_TRUE(brpc::policy::SerializeRpcMessage( |
| 1739 | echo_response, *cntl, content_type, compress_type, checksum_type, |
| 1740 | &response->serialized_data())); |
| 1741 | } |
| 1742 | private: |
| 1743 | int _content_type_index = brpc::ContentType_MIN; |
| 1744 | int _compress_type_index = brpc::CompressType_MIN; |
nothing calls this directly
no test coverage detected