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/impl/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::impl::ComponentBase {
31 public:
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,
37 const components::ComponentContext& context);
38
39 Storage& GetStorage() const;
40
41 private:
42 mutable Storage storage_;
43};
44
45} // namespace alerts
46
47template <>
48inline constexpr bool components::kHasValidate<alerts::StorageComponent> = true;
49
50template <>
51inline constexpr auto components::kConfigFileMode<alerts::StorageComponent> =
53
54USERVER_NAMESPACE_END