9#include <unordered_map>
12#include <grpcpp/completion_queue.h>
13#include <grpcpp/security/credentials.h>
14#include <grpcpp/support/channel_arguments.h>
16#include <userver/dynamic_config/source.hpp>
17#include <userver/engine/task/task_processor_fwd.hpp>
18#include <userver/logging/level.hpp>
19#include <userver/storages/secdist/secdist.hpp>
20#include <userver/testsuite/grpc_control.hpp>
22#include <userver/ugrpc/client/client_factory_settings.hpp>
23#include <userver/ugrpc/client/fwd.hpp>
24#include <userver/ugrpc/client/impl/channel_cache.hpp>
25#include <userver/ugrpc/client/middlewares/base.hpp>
27USERVER_NAMESPACE_BEGIN
29namespace ugrpc::impl {
30class StatisticsStorage;
31class CompletionQueuePoolBase;
37struct ClientSettings
final {
62 const dynamic_config::Key<ClientQos>*
client_qos{
nullptr};
80class ClientFactory
final {
83 template <
typename Client>
90 template <
typename Client>
91 Client
MakeClient(
const std::string& client_name,
const std::string& endpoint);
96 ClientFactorySettings&& settings,
97 engine::TaskProcessor& channel_task_processor,
98 MiddlewareFactories mws,
99 ugrpc::impl::CompletionQueuePoolBase& queue,
100 ugrpc::impl::StatisticsStorage& statistics_storage,
102 dynamic_config::Source source
107 impl::ChannelCache::Token GetChannel(
const std::string& client_name,
const std::string& endpoint);
109 impl::ClientDependencies MakeClientDependencies(ClientSettings&& settings);
111 ClientFactorySettings settings_;
112 engine::TaskProcessor& channel_task_processor_;
113 MiddlewareFactories mws_;
114 ugrpc::impl::CompletionQueuePoolBase& completion_queues_;
115 impl::ChannelCache channel_cache_;
116 std::unordered_map<std::string, impl::ChannelCache> client_channel_cache_;
117 ugrpc::impl::StatisticsStorage& client_statistics_storage_;
118 const dynamic_config::Source config_source_;
122template <
typename Client>
124 return Client(MakeClientDependencies(std::move(settings)));
127template <
typename Client>
128Client ClientFactory::
MakeClient(
const std::string& client_name,
const std::string& endpoint) {
129 ClientSettings settings;
132 return MakeClient<Client>(std::move(settings));