userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
source.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <chrono>
7
#include <string_view>
8
9
#include <
userver/utils/statistics/metric_tag.hpp
>
10
#include <
userver/utils/statistics/metrics_storage.hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
alerts {
15
16
namespace
impl {
17
struct
SourceData {
18
mutable
std::atomic<bool> fired{
false
};
19
std::atomic<std::chrono::steady_clock::time_point> stop_timepoint{{}};
20
21
bool
IsExpired()
const
;
22
};
23
24
void
DumpMetric(utils::statistics::Writer& writer,
const
SourceData& m);
25
}
// namespace impl
26
36
class
Source
final {
37
public
:
38
static
constexpr
std::chrono::seconds kDefaultDuration{120};
39
static
constexpr
std::chrono::hours kInfiniteDuration{24 * 365 * 10};
// In 10 years, someone should notice.
40
43
explicit
Source
(std::string_view name);
44
46
void
FireAlert
(
utils::statistics::MetricsStorage
& storage, std::chrono::seconds duration = kDefaultDuration)
const
;
47
49
void
StopAlertNow
(
utils::statistics::MetricsStorage
& storage)
const
;
50
51
private
:
52
utils::statistics::MetricTag<impl::SourceData>
tag_;
53
};
54
55
}
// namespace alerts
56
57
USERVER_NAMESPACE_END
userver
alerts
source.hpp
Generated on
for userver by
Doxygen
1.17.0