userver: components::State Class Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
components::State Class Referencefinal

#include <userver/components/state.hpp>

Detailed Description

A view of the components' state that is usable after the components are constructed and until all the components are destroyed.

See also
components::ComponentContext

Definition at line 104 of file state.hpp.

Public Member Functions

 State (const ComponentContext &cc) noexcept
 
bool IsAnyComponentInFatalState () const
 
ServiceLifetimeStage GetServiceLifetimeStage () const
 
bool HasDependencyOn (std::string_view component_name, std::string_view dependency) const
 
std::unordered_set< std::string_view > GetAllDependencies (std::string_view component_name) const
 

Member Function Documentation

◆ GetAllDependencies()

std::unordered_set< std::string_view > components::State::GetAllDependencies ( std::string_view component_name) const
Returns
all the components that component_name depends on directly or transitively.

Component with name component_name should be loaded. Components construction should finish before any call to this function is made. The result should now outlive the all the components destruction.

◆ GetServiceLifetimeStage()

ServiceLifetimeStage components::State::GetServiceLifetimeStage ( ) const
Returns
the current service lifetime stage.
See also
components::ServiceLifetimeStage

◆ HasDependencyOn()

bool components::State::HasDependencyOn ( std::string_view component_name,
std::string_view dependency ) const
Returns
true if component with name component_name depends (directly or transitively) on a component with name dependency.

Component with name component_name should be loaded. Components construction should finish before any call to this function is made.

Note that GetAllDependencies usually is more effective, if you are planning multiple calls for the same component name.

◆ IsAnyComponentInFatalState()

bool components::State::IsAnyComponentInFatalState ( ) const
Returns
true if one of the components is in fatal state and can not work. A component is in fatal state if the components::ComponentHealth::kFatal value is returned from the overridden components::ComponentBase::GetComponentHealth().

The documentation for this class was generated from the following file: