userver: userver/components/state.hpp Source File
Loading...
Searching...
No Matches
state.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/components/state.hpp
4/// @brief @copybrief components::State
5
6#include <string_view>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace components {
11
12class ComponentContext;
13
14namespace impl {
15class ComponentContextImpl;
16}
17
18/// State of components that is usable after the components constructor.
19///
20/// @see components::ComponentContext
21class State final {
22 public:
23 explicit State(const ComponentContext& cc) noexcept;
24
25 /// @returns true if one of the components is in fatal state and can not
26 /// work. A component is in fatal state if the
27 /// components::ComponentHealth::kFatal value is returned from the overridden
28 /// components::LoggableComponentBase::GetComponentHealth().
30
31 /// @returns true if component with name `component_name` depends
32 /// (directly or transitively) on a component with name `dependency`.
33 ///
34 /// Component with name `component_name` should be loaded.
35 bool HasDependencyOn(std::string_view component_name,
36 std::string_view dependency) const;
37
38 private:
39 const impl::ComponentContextImpl& impl_;
40};
41
42} // namespace components
43
44USERVER_NAMESPACE_END