userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
client_factory.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <optional>
7
#include <string>
8
#include <utility>
9
10
#include <
userver/dynamic_config/source.hpp
>
11
#include <
userver/engine/task/task_processor_fwd.hpp
>
12
13
#include <userver/concurrent/impl/striped_read_indicator.hpp>
14
#include <
userver/ugrpc/client/client_factory_settings.hpp
>
15
#include <
userver/ugrpc/client/client_settings.hpp
>
16
#include <
userver/ugrpc/client/fwd.hpp
>
17
#include <userver/ugrpc/client/impl/client_internals.hpp>
18
#include <userver/ugrpc/client/impl/client_qos_errors_reporter.hpp>
19
#include <
userver/ugrpc/client/middlewares/pipeline.hpp
>
20
#include <userver/ugrpc/impl/static_service_metadata.hpp>
21
22
USERVER_NAMESPACE_BEGIN
23
24
namespace
ugrpc::impl {
25
class
StatisticsStorage;
26
class
CompletionQueuePoolBase;
27
}
// namespace ugrpc::impl
28
29
namespace
ugrpc::client
{
30
42
class
ClientFactory
final {
43
public
:
45
template
<
typename
Client>
46
Client
MakeClient
(
ClientSettings
&& client_settings);
47
52
template
<
typename
Client>
53
Client
MakeClient
(
const
std::string& client_name,
const
std::string& endpoint);
54
56
// For internal use only.
57
ClientFactory
(
58
ClientFactorySettings
&& client_factory_settings,
59
engine::TaskProcessor& channel_task_processor,
60
impl::MiddlewarePipelineCreator& middleware_pipeline_creator,
61
ugrpc::impl::CompletionQueuePoolBase& completion_queues,
62
ugrpc::impl::StatisticsStorage& statistics_storage,
63
utils::statistics::MetricsStorage
& metrics_storage,
64
testsuite::GrpcControl
& testsuite_grpc,
65
dynamic_config::Source
config_source
66
);
68
69
~ClientFactory
();
70
71
private
:
72
impl::ClientInternals MakeClientInternals(
73
ClientSettings
&& client_settings,
74
std::optional<ugrpc::impl::StaticServiceMetadata>
meta
75
);
76
77
// Ensures that all clients created by this factory are destroyed before
78
// the factory itself. If any client outlives the factory, the program
79
// will abort with a stacktrace in the factory's destructor.
80
concurrent::impl::StripedReadIndicator alive_clients_indicator_;
81
82
ClientFactorySettings
client_factory_settings_;
83
engine::TaskProcessor& channel_task_processor_;
84
impl::MiddlewarePipelineCreator& middleware_pipeline_creator_;
85
ugrpc::impl::CompletionQueuePoolBase& completion_queues_;
86
ugrpc::impl::StatisticsStorage& client_statistics_storage_;
87
impl::ClientQosErrorsReporter client_qos_errors_reporter_;
88
const
dynamic_config::Source
config_source_;
89
testsuite::GrpcControl
& testsuite_grpc_;
90
};
91
92
template
<
typename
Client>
93
Client
ClientFactory::MakeClient
(
ClientSettings
&& client_settings) {
94
return
Client(MakeClientInternals(std::move(client_settings), Client::GetMetadata(utils::impl::InternalTag{})));
95
}
96
97
template
<
typename
Client>
98
Client
ClientFactory::MakeClient
(
const
std::string& client_name,
const
std::string& endpoint) {
99
ClientSettings
client_settings;
100
client_settings.
client_name
= client_name;
101
client_settings.
endpoint
= endpoint;
102
return
MakeClient<Client>
(std::move(client_settings));
103
}
104
105
}
// namespace ugrpc::client
106
107
USERVER_NAMESPACE_END
userver
ugrpc
client
client_factory.hpp
Generated on
for userver by
Doxygen
1.17.0