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

Method default_method

src/brpc/builtin/ids_service.cpp:33–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31namespace brpc {
32
33void 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

Callers

nothing calls this directly

Calls 7

id_pool_statusFunction · 0.85
id_statusFunction · 0.85
set_content_typeMethod · 0.80
emptyMethod · 0.45
c_strMethod · 0.45
SetFailedMethod · 0.45
move_toMethod · 0.45

Tested by

no test coverage detected