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

Method Method

test/brpc_grpc_protocol_unittest.cpp:52–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50class MyGrpcService : public ::test::GrpcService {
51public:
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,

Callers 2

CallMethodMethod · 0.80
TEST_FFunction · 0.80

Calls 6

deadline_usMethod · 0.80
gettimeofday_usFunction · 0.70
messageMethod · 0.45
SetFailedMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected