userver: userver/ugrpc/client/common_component.hpp Source File
Loading...
Searching...
No Matches
common_component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/ugrpc/client/common_component.hpp
4/// @brief @copybrief ugrpc::client::CommonComponent
5
6#include <optional>
7
8#include <userver/components/component_base.hpp>
9#include <userver/engine/task/task_processor_fwd.hpp>
10
11#include <userver/ugrpc/client/impl/completion_queue_pool.hpp>
12#include <userver/ugrpc/impl/completion_queue_pool_base.hpp>
13#include <userver/ugrpc/impl/statistics_storage.hpp>
14
15USERVER_NAMESPACE_BEGIN
16
17namespace ugrpc::client {
18
19// clang-format off
20
21/// @ingroup userver_components
22///
23/// @brief Contains common machinery that's required for all ugrpc clients
24///
25/// ## Static options:
26/// The component name for static config is `"grpc-client-common"`.
27///
28/// Name | Description | Default value
29/// ---- | ----------- | -------------
30/// blocking-task-processor | the task processor for blocking channel creation | -
31/// native-log-level | min log level for the native gRPC library | 'error'
32///
33/// @see ugrpc::client::ClientFactoryComponent
34
35// clang-format on
36class CommonComponent final : public components::ComponentBase {
37public:
38 /// @ingroup userver_component_names
39 /// @brief The default name of ugrpc::client::CommonComponent
40 static constexpr std::string_view kName = "grpc-client-common";
41
42 CommonComponent(const components::ComponentConfig& config, const components::ComponentContext& context);
43 ~CommonComponent() override;
44
45 static yaml_config::Schema GetStaticConfigSchema();
46
47private:
48 friend class ClientFactoryComponent;
49
50 engine::TaskProcessor& blocking_task_processor_;
51 std::optional<impl::CompletionQueuePool> client_completion_queues_;
52 ugrpc::impl::CompletionQueuePoolBase& completion_queues_;
53 ugrpc::impl::StatisticsStorage client_statistics_storage_;
54};
55
56} // namespace ugrpc::client
57
58template <>
59inline constexpr bool components::kHasValidate<ugrpc::client::CommonComponent> = true;
60
61USERVER_NAMESPACE_END