userver
C++ Async Framework
Loading...
Searching...
No Matches
raw_component_base.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/components/raw_component_base.hpp
4
/// @brief @copybrief components::RawComponentBase
5
6
#
include
<
type_traits
>
7
8
USERVER_NAMESPACE_BEGIN
9
10
namespace
yaml_config {
11
12
struct
Schema;
13
14
}
// namespace yaml_config
15
16
namespace
components
{
17
18
/// State of the component
19
enum
class
ComponentHealth
{
20
/// component is alive and fine
21
kOk
,
22
/// component in fallback state, but the service keeps working
23
kFallback
,
24
/// component is sick, service can not work without it
25
kFatal
,
26
};
27
28
/// Whether the static config for the component must always be present, or can
29
/// be missing
30
enum
class
ConfigFileMode
{
31
/// component must be setup in config
32
kRequired
,
33
/// component must be not setup in config
34
kNotRequired
35
};
36
37
/// @brief The base class for all components. Don't use it for application
38
/// components, use ComponentBase instead.
39
///
40
/// Only inherited directly by some of the built-in userver components.
41
class
RawComponentBase
{
42
public
:
43
RawComponentBase() =
default
;
44
45
RawComponentBase(
RawComponentBase
&&) =
delete
;
46
47
RawComponentBase(
const
RawComponentBase
&) =
delete
;
48
49
virtual
~RawComponentBase();
50
51
virtual
ComponentHealth
GetComponentHealth()
const
{
return
ComponentHealth
::
kOk
; }
52
53
virtual
void
OnLoadingCancelled() {}
54
55
virtual
void
OnAllComponentsLoaded() {}
56
57
virtual
void
OnAllComponentsAreStopping() {}
58
59
static
yaml_config::Schema GetStaticConfigSchema();
60
};
61
62
/// Specialize it for typename Component to validate static config against
63
/// schema from Component::GetStaticConfigSchema
64
///
65
/// @see @ref static-configs-validation "Static configs validation"
66
template
<
typename
Component
>
67
inline
constexpr
bool
kHasValidate
=
false
;
68
69
/// Specialize it for typename Component to skip validation of static config against
70
/// schema from Component::GetStaticConfigSchema
71
///
72
/// @see @ref static-configs-validation "Static configs validation"
73
template
<
typename
Component
>
74
inline
constexpr
bool
kForceNoValidation
=
false
;
75
76
namespace
impl {
77
78
template
<
typename
Component>
79
inline
constexpr
auto
kDefaultConfigFileMode = ConfigFileMode::kRequired;
80
81
template
<
typename
Component>
82
requires
requires
{ Component::kConfigFileMode; }
83
inline
constexpr
auto
kDefaultConfigFileMode<Component> = Component::kConfigFileMode;
84
}
// namespace impl
85
86
/// Specialize this to customize the loading of component settings
87
///
88
/// @see @ref select-config-file-mode "Setup config file mode"
89
template
<
typename
Component
>
90
inline
constexpr
auto
kConfigFileMode
=
impl
::
kDefaultConfigFileMode
<
Component
>;
91
92
}
// namespace components
93
94
USERVER_NAMESPACE_END
userver
components
raw_component_base.hpp
Generated on Mon May 4 2026 12:03:04 for userver by
Doxygen
1.13.2