| 50 | class MyGrpcService : public ::test::GrpcService { |
| 51 | public: |
| 52 | void Method(::google::protobuf::RpcController* cntl_base, |
| 53 | const ::test::GrpcRequest* req, |
| 54 | ::test::GrpcResponse* res, |
| 55 | ::google::protobuf::Closure* done) { |
| 56 | brpc::Controller* cntl = |
| 57 | static_cast<brpc::Controller*>(cntl_base); |
| 58 | brpc::ClosureGuard done_guard(done); |
| 59 | |
| 60 | EXPECT_EQ(g_req, req->message()); |
| 61 | if (req->gzip()) { |
| 62 | cntl->set_response_compress_type(brpc::COMPRESS_TYPE_GZIP); |
| 63 | } |
| 64 | res->set_message(g_prefix + req->message()); |
| 65 | |
| 66 | if (req->return_error()) { |
| 67 | cntl->SetFailed(brpc::EINTERNAL, "%s", g_prefix.c_str()); |
| 68 | return; |
| 69 | } |
| 70 | if (req->has_timeout_us()) { |
| 71 | if (req->timeout_us() < 0) { |
| 72 | EXPECT_EQ(-1, cntl->deadline_us()); |
| 73 | } else { |
| 74 | EXPECT_NEAR(cntl->deadline_us(), |
| 75 | butil::gettimeofday_us() + req->timeout_us(), 5000); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | void MethodTimeOut(::google::protobuf::RpcController* cntl_base, |
| 81 | const ::test::GrpcRequest* req, |
no test coverage detected