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
{
return
ComponentHealth
::
kOk
; }
50
51
virtual
void
OnLoadingCancelled() {}
52
53
virtual
void
OnAllComponentsLoaded() {}
54
55
virtual
void
OnAllComponentsAreStopping() {}
56
57
static
yaml_config
::Schema GetStaticConfigSchema();
58
};
59
60
/// Specialize it for typename Component to validate static config against
61
/// schema from Component::GetStaticConfigSchema
62
///
63
/// @see @ref static-configs-validation "Static configs validation"
64
template
<
typename
Component
>
65
inline
constexpr
bool
kHasValidate
=
false
;
66
67
/// Specialize this to customize the loading of component settings
68
///
69
/// @see @ref select-config-file-mode "Setup config file mode"
70
template
<
typename
Component
>
71
inline
constexpr
auto
kConfigFileMode
=
ConfigFileMode
::
kRequired
;
72
73
}
// namespace components
74
75
USERVER_NAMESPACE_END
userver
components
raw_component_base.hpp
Generated on Wed Dec 4 2024 18:42:04 for userver by
Doxygen
1.10.0