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

Method handle_response

tools/rpc_press/rpc_press_impl.cpp:193–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193void RpcPress::handle_response(brpc::Controller* cntl,
194 Message* request,
195 Message* response,
196 int64_t start_time){
197 if (!cntl->Failed()){
198 int64_t rpc_call_time_us = butil::cpuwide_time_us() - start_time;
199 _latency_recorder << rpc_call_time_us;
200
201 if (_output_json) {
202 std::string response_json;
203 std::string error;
204 if (!json2pb::ProtoMessageToJson(*response, &response_json, &error)) {
205 LOG(WARNING) << "Fail to convert to json: " << error;
206 }
207 fprintf(_output_json, "%s\n", response_json.c_str());
208 }
209 } else {
210 LOG(WARNING) << "error_code=" << cntl->ErrorCode() << ", "
211 << cntl->ErrorText();
212 _error_count << 1;
213 }
214 delete response;
215 delete cntl;
216}
217
218static butil::atomic<int> g_thread_count(0);
219

Callers

nothing calls this directly

Calls 6

cpuwide_time_usFunction · 0.85
ErrorCodeMethod · 0.80
ErrorTextMethod · 0.80
ProtoMessageToJsonFunction · 0.50
FailedMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected