| 191 | } |
| 192 | |
| 193 | void 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 | |
| 218 | static butil::atomic<int> g_thread_count(0); |
| 219 |
nothing calls this directly
no test coverage detected