userver: userver/grpc-reflection/reflection_service_component.hpp Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
reflection_service_component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/grpc-reflection/reflection_service_component.hpp
4/// @brief @copybrief grpc_reflection::ReflectionServiceComponent
5
6#include <string_view>
7
8#include <userver/components/component_config.hpp>
9#include <userver/components/component_context.hpp>
10#include <userver/ugrpc/server/server.hpp>
11#include <userver/ugrpc/server/service_component_base.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15/// @brief Top namespace for grpc-reflection library
16///
17/// For more information see @ref scripts/docs/en/userver/libraries/grpc-reflection.md.
18namespace grpc_reflection {
19
20class ProtoServerReflection;
21
22class ReflectionServiceComponent final : public ugrpc::server::ServiceComponentBase {
23public:
24 static constexpr std::string_view kName = "grpc-reflection-service";
25
26 ReflectionServiceComponent(const components::ComponentConfig& config, const components::ComponentContext& context);
27
28 ~ReflectionServiceComponent() override;
29
30private:
31 void OnAllComponentsLoaded() override;
32
33 components::ComponentHealth GetComponentHealth() const override;
34
35 void AddService(std::string_view service_name);
36
37 std::unique_ptr<grpc_reflection::ProtoServerReflection> service_;
38 ugrpc::server::Server& ugrpc_server_;
39 std::atomic<bool> ready_{false};
40};
41
42} // namespace grpc_reflection
43
44USERVER_NAMESPACE_END