userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
generic_client.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/ugrpc/client/generic_client.hpp
4
/// @brief @copybrief ugrpc::client::GenericClient
5
6
#
include
<
memory
>
7
#
include
<
optional
>
8
#
include
<
string_view
>
9
10
#
include
<
grpcpp
/
support
/
byte_buffer
.
h
>
11
12
#
include
<
userver
/
ugrpc
/
client
/
call_options
.
hpp
>
13
#
include
<
userver
/
ugrpc
/
client
/
generic_options
.
hpp
>
14
#
include
<
userver
/
ugrpc
/
client
/
impl
/
fwd
.
hpp
>
15
#
include
<
userver
/
ugrpc
/
client
/
response_future
.
hpp
>
16
#
include
<
userver
/
ugrpc
/
impl
/
static_service_metadata
.
hpp
>
17
18
USERVER_NAMESPACE_BEGIN
19
20
namespace
ugrpc::client {
21
22
/// @ingroup userver_clients
23
///
24
/// @brief Allows to talk to gRPC services (generic and normal) using dynamic
25
/// method names.
26
///
27
/// Created using @ref ugrpc::client::ClientFactory::MakeClient.
28
///
29
/// `call_name` must be in the format `full.path.to.TheService/MethodName`.
30
/// Note that unlike in base grpc++, there must be no initial `/` character.
31
///
32
/// The API is mainly intended for proxies, where the request-response body is
33
/// passed unchanged, with settings taken solely from the RPC metadata.
34
/// In cases where the code needs to operate on the actual messages,
35
/// serialization of requests and responses is left as an exercise to the user.
36
///
37
/// Middlewares are customizable and are applied as usual, except that no
38
/// message hooks are called, meaning that there won't be any logs of messages
39
/// from the default middleware.
40
///
41
/// There are no per-call-name metrics by default,
42
/// for details see @ref GenericOptions::metrics_call_name.
43
///
44
/// @warning Retry limiters (configured via `retry-throttler` in
45
/// @ref ugrpc::client::CommonComponent) are not supported for GenericClient.
46
/// The setting is ignored, and retry limiting will not be applied to generic
47
/// calls. For retry limiting functionality, use regular typed gRPC clients.
48
///
49
/// ## Example GenericClient usage with known message types
50
///
51
/// @snippet grpc/tests/generic_client_test.cpp sample
52
///
53
/// For a more complete sample, see @ref grpc_generic_api.
54
class
GenericClient
final
{
55
public
:
56
GenericClient(GenericClient&&)
noexcept
;
57
GenericClient& operator=(GenericClient&&)
noexcept
;
58
59
~GenericClient();
60
61
/// Initiate a `single request -> single response` RPC with the given name.
62
ResponseFuture<grpc::ByteBuffer>
AsyncUnaryCall
(
63
std::string_view call_name,
64
const
grpc::ByteBuffer& request,
65
CallOptions
call_options = {},
66
GenericOptions
generic_options = {}
67
)
const
;
68
69
/// Initiate a `single request -> single response` RPC with the given name.
70
grpc::ByteBuffer
UnaryCall
(
71
std::string_view call_name,
72
const
grpc::ByteBuffer& request,
73
CallOptions
call_options = {},
74
GenericOptions
generic_options = {}
75
)
const
;
76
77
/// @cond
78
// For internal use only.
79
explicit
GenericClient(impl::ClientInternals&&);
80
81
// For internal use only.
82
static
std::optional<ugrpc::impl::StaticServiceMetadata> GetMetadata(
utils
::impl::InternalTag) {
83
return
std::nullopt;
84
}
85
/// @endcond
86
87
private
:
88
friend
class
impl::ClientDataAccessor;
89
90
std::unique_ptr<impl::ClientData> client_data_;
91
};
92
93
}
// namespace ugrpc::client
94
95
USERVER_NAMESPACE_END
userver
ugrpc
client
generic_client.hpp
Generated on
for userver by
Doxygen
1.17.0