Github   Telegram
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <memory>
7
10#include <userver/server/server.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace components {
16
17// clang-format off
18
73
74// clang-format on
75
76class Server final : public LoggableComponentBase {
77 public:
78 static constexpr std::string_view kName = "server";
79
80 Server(const components::ComponentConfig& component_config,
81 const components::ComponentContext& component_context);
82
83 ~Server() override;
84
85 void OnAllComponentsLoaded() override;
86
87 void OnAllComponentsAreStopping() override;
88
89 const server::Server& GetServer() const;
90
91 server::Server& GetServer();
92
93 void AddHandler(const server::handlers::HttpHandlerBase& handler,
94 engine::TaskProcessor& task_processor);
95
96 static yaml_config::Schema GetStaticConfigSchema();
97
98 private:
99 void WriteStatistics(utils::statistics::Writer& writer);
100
101 std::unique_ptr<server::Server> server_;
102 utils::statistics::Entry server_statistics_holder_;
103 utils::statistics::Entry handler_statistics_holder_;
104};
105
106template <>
107inline constexpr bool kHasValidate<Server> = true;
108
109} // namespace components
110
111USERVER_NAMESPACE_END