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/fwd.hpp>
23#include <userver/ugrpc/client/impl/channel_cache.hpp>
24#include <userver/ugrpc/client/impl/client_data.hpp>
25#include <userver/ugrpc/client/middlewares/base.hpp>
27USERVER_NAMESPACE_BEGIN
29namespace ugrpc::impl {
30class StatisticsStorage;
31class CompletionQueuePoolBase;
37struct ClientFactorySettings
final {
40 grpc::InsecureChannelCredentials()};
61struct ClientSettings
final {
86 const dynamic_config::Key<ClientQos>*
client_qos{
nullptr};
100class ClientFactory
final {
103 template <
typename Client>
110 template <
typename Client>
111 Client
MakeClient(
const std::string& client_name,
112 const std::string& endpoint);
116 ClientFactory(ClientFactorySettings&& settings,
117 engine::TaskProcessor& channel_task_processor,
118 MiddlewareFactories mws,
119 ugrpc::impl::CompletionQueuePoolBase& queue,
120 ugrpc::impl::StatisticsStorage& statistics_storage,
122 dynamic_config::Source source);
126 impl::ChannelCache::Token GetChannel(
const std::string& client_name,
127 const std::string& endpoint);
129 impl::ClientDependencies MakeClientDependencies(ClientSettings&& settings);
131 engine::TaskProcessor& channel_task_processor_;
132 MiddlewareFactories mws_;
133 ugrpc::impl::CompletionQueuePoolBase& completion_queues_;
134 impl::ChannelCache channel_cache_;
135 std::unordered_map<std::string, impl::ChannelCache> client_channel_cache_;
136 ugrpc::impl::StatisticsStorage& client_statistics_storage_;
137 const dynamic_config::Source config_source_;
141template <
typename Client>
143 return Client(MakeClientDependencies(std::move(settings)));
146template <
typename Client>
147Client ClientFactory::
MakeClient(
const std::string& client_name,
148 const std::string& endpoint) {
149 ClientSettings settings;
152 return MakeClient<Client>(std::move(settings));