userver: userver/server/handlers/jemalloc.hpp Source File
Loading...
Searching...
No Matches
jemalloc.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/handlers/jemalloc.hpp
4/// @brief @copybrief server::handlers::Jemalloc
5
6#include <userver/server/handlers/http_handler_base.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace server::handlers {
11
12// clang-format off
13
14/// @ingroup userver_components userver_http_handlers
15///
16/// @brief Handler that controls the jemalloc allocator.
17///
18/// The component has no service configuration except the
19/// @ref userver_http_handlers "common handler options".
20///
21/// ## Static configuration example:
22///
23/// @snippet components/common_server_component_list_test.cpp Sample handler jemalloc component config
24///
25/// ## Schema
26/// Set an URL path argument `command` to one of the following values:
27/// * `stat` - to get jemalloc stats
28/// * `enable` - to start memory profiling
29/// * `disable` - to stop memory profiling
30/// * `dump` - to get jemalloc profiling dump
31
32// clang-format on
33
34class Jemalloc final : public HttpHandlerBase {
35 public:
36 Jemalloc(const components::ComponentConfig&,
37 const components::ComponentContext&);
38
39 /// @ingroup userver_component_names
40 /// @brief The default name of server::handlers::Jemalloc
41 static constexpr std::string_view kName = "handler-jemalloc";
42
43 std::string HandleRequestThrow(const http::HttpRequest&,
44 request::RequestContext&) const override;
45
46 static yaml_config::Schema GetStaticConfigSchema();
47};
48
49} // namespace server::handlers
50
51template <>
52inline constexpr bool components::kHasValidate<server::handlers::Jemalloc> =
53 true;
54
55USERVER_NAMESPACE_END