userver: userver/alerts/component.hpp Source File
Loading...
Searching...
No Matches
component.hpp
1#pragma once
2
3/// @file userver/alert/component.hpp
4/// @brief @copybrief alert::Component
5
6#include <userver/components/component_fwd.hpp>
7#include <userver/components/raw_component_base.hpp>
8
9#include <userver/alerts/storage.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13/// @brief Alerts management
14namespace alerts {
15
16// clang-format off
17
18/// @ingroup userver_components
19///
20/// @brief Component that keeps an alert::Storage storage for
21/// fired alerts.
22///
23/// The component does **not** have any options for service config.
24///
25/// ## Static configuration example:
26///
27/// @snippet components/common_component_list_test.cpp Sample statistics storage component config
28
29// clang-format on
30class StorageComponent final : public components::RawComponentBase {
31public:
32 /// @ingroup userver_component_names
33 /// @brief The default name of alert::StorageComponent component
34 static constexpr std::string_view kName = "alerts-storage";
35
36 StorageComponent(const components::ComponentConfig& config, const components::ComponentContext& context);
37
38 Storage& GetStorage() const;
39
40private:
41 mutable Storage storage_;
42};
43
44} // namespace alerts
45
46template <>
47inline constexpr bool components::kHasValidate<alerts::StorageComponent> = true;
48
49template <>
50inline constexpr auto components::kConfigFileMode<alerts::StorageComponent> = ConfigFileMode::kNotRequired;
51
52USERVER_NAMESPACE_END