userver: userver/grpc-reflection/reflection_service_component.hpp Source File
Loading...
Searching...
No Matches
reflection_service_component.hpp
1#pragma once
2
3#include <string_view>
4
5#include <userver/components/component_config.hpp>
6#include <userver/components/component_context.hpp>
7#include <userver/ugrpc/server/server.hpp>
8#include <userver/ugrpc/server/service_component_base.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12/// @brief Top namespace for grpc-reflection library
13///
14/// For more information see @ref grpc-reflection_library.
15namespace grpc_reflection {
16
17class ProtoServerReflection;
18
19class ReflectionServiceComponent final : public ugrpc::server::ServiceComponentBase {
20public:
21 static constexpr std::string_view kName = "grpc-reflection-service";
22
23 ReflectionServiceComponent(const components::ComponentConfig& config, const components::ComponentContext& context);
24
25 ~ReflectionServiceComponent();
26
27private:
28 void OnAllComponentsLoaded() override;
29
30 components::ComponentHealth GetComponentHealth() const override;
31
32 void AddService(std::string_view service_name);
33
34 std::unique_ptr<grpc_reflection::ProtoServerReflection> service_;
35 ugrpc::server::Server& ugrpc_server_;
36 std::atomic<bool> ready_{false};
37};
38
39} // namespace grpc_reflection
40
41USERVER_NAMESPACE_END