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
USERVER_NAMESPACE_BEGIN
7
8
namespace
yaml_config
{
9
10
struct
Schema;
11
12
}
// namespace yaml_config
13
14
namespace
components
{
15
16
/// State of the component
17
enum
class
ComponentHealth
{
18
/// component is alive and fine
19
kOk
,
20
/// component in fallback state, but the service keeps working
21
kFallback
,
22
/// component is sick, service can not work without it
23
kFatal
,
24
};
25
26
/// Whether the static config for the component must always be present, or can
27
/// be missing
28
enum
class
ConfigFileMode
{
29
/// component must be setup in config
30
kRequired
,
31
/// component must be not setup in config
32
kNotRequired
33
};
34
35
/// @brief The base class for all components. Don't use it for application
36
/// components, use ComponentBase instead.
37
///
38
/// Only inherited directly by some of the built-in userver components.
39
class
RawComponentBase
{
40
public
:
41
RawComponentBase() =
default
;
42
43
RawComponentBase(
RawComponentBase
&&) =
delete
;
44
45
RawComponentBase(
const
RawComponentBase
&) =
delete
;
46
47
virtual
~RawComponentBase();
48
49
virtual
ComponentHealth
GetComponentHealth()
const
{
50
return
ComponentHealth
::
kOk
;
51
}
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 this to customize the loading of component settings
70
///
71
/// @see @ref select-config-file-mode "Setup config file mode"
72
template
<
typename
Component
>
73
inline
constexpr
auto
kConfigFileMode
=
ConfigFileMode
::
kRequired
;
74
75
}
// namespace components
76
77
USERVER_NAMESPACE_END
userver
components
raw_component_base.hpp
Generated on Thu Sep 5 2024 11:16:33 for userver by
Doxygen
1.10.0