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