| 69 | } |
| 70 | |
| 71 | void MemoryService::default_method(::google::protobuf::RpcController* cntl_base, |
| 72 | const ::brpc::MemoryRequest*, |
| 73 | ::brpc::MemoryResponse*, |
| 74 | ::google::protobuf::Closure* done) { |
| 75 | ClosureGuard done_guard(done); |
| 76 | auto cntl = static_cast<Controller*>(cntl_base); |
| 77 | cntl->http_response().set_content_type("text/plain"); |
| 78 | butil::IOBuf& resp = cntl->response_attachment(); |
| 79 | |
| 80 | if (IsTCMallocEnabled()) { |
| 81 | butil::IOBufBuilder os; |
| 82 | get_tcmalloc_memory_info(resp); |
| 83 | } else if (HasJemalloc()) { |
| 84 | // support ip:port/memory?opts=Ja |
| 85 | get_jemalloc_memory_info(cntl); |
| 86 | } else { |
| 87 | resp.append("tcmalloc or jemalloc is not enabled"); |
| 88 | cntl->http_response().set_status_code(HTTP_STATUS_FORBIDDEN); |
| 89 | return; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | } // namespace brpc |
nothing calls this directly
no test coverage detected