| 62 | } |
| 63 | ~TrackMeServiceImpl() {} |
| 64 | void TrackMe(google::protobuf::RpcController* cntl_base, |
| 65 | const brpc::TrackMeRequest* request, |
| 66 | brpc::TrackMeResponse* response, |
| 67 | google::protobuf::Closure* done) { |
| 68 | brpc::ClosureGuard done_guard(done); |
| 69 | brpc::Controller* cntl = (brpc::Controller*)cntl_base; |
| 70 | // Set to OK by default. |
| 71 | response->set_severity(brpc::TrackMeOK); |
| 72 | // Check if the version is affected by bugs if client set it. |
| 73 | if (request->has_rpc_version()) { |
| 74 | _bugs->find(request->rpc_version(), response); |
| 75 | } |
| 76 | response->set_new_interval(FLAGS_reporting_interval); |
| 77 | butil::EndPoint server_addr; |
| 78 | CHECK_EQ(0, butil::str2endpoint(request->server_addr().c_str(), &server_addr)); |
| 79 | // NOTE(gejun): The ip reported is inaccessible in many cases, use |
| 80 | // remote_side instead right now. |
| 81 | server_addr.ip = cntl->remote_side().ip; |
| 82 | LOG(INFO) << "Pinged by " << server_addr << " (r" |
| 83 | << request->rpc_version() << ")"; |
| 84 | } |
| 85 | |
| 86 | private: |
| 87 | BugsLoader* _bugs; |
no test coverage detected