| 31 | namespace brpc { |
| 32 | |
| 33 | void IdsService::default_method(::google::protobuf::RpcController* cntl_base, |
| 34 | const ::brpc::IdsRequest*, |
| 35 | ::brpc::IdsResponse*, |
| 36 | ::google::protobuf::Closure* done) { |
| 37 | ClosureGuard done_guard(done); |
| 38 | Controller *cntl = static_cast<Controller*>(cntl_base); |
| 39 | cntl->http_response().set_content_type("text/plain"); |
| 40 | butil::IOBufBuilder os; |
| 41 | const std::string& constraint = cntl->http_request().unresolved_path(); |
| 42 | |
| 43 | if (constraint.empty()) { |
| 44 | os << "# Use /ids/<call_id>\n"; |
| 45 | bthread::id_pool_status(os); |
| 46 | } else { |
| 47 | char* endptr = NULL; |
| 48 | bthread_id_t id = { strtoull(constraint.c_str(), &endptr, 10) }; |
| 49 | if (*endptr == '\0' || *endptr == '/') { |
| 50 | bthread::id_status(id, os); |
| 51 | } else { |
| 52 | cntl->SetFailed(ENOMETHOD, "path=%s is not a bthread_id", |
| 53 | constraint.c_str()); |
| 54 | return; |
| 55 | } |
| 56 | } |
| 57 | os.move_to(cntl->response_attachment()); |
| 58 | } |
| 59 | |
| 60 | } // namespace brpc |
nothing calls this directly
no test coverage detected