userver
C++ Async Framework
Toggle main menu visibility
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
stream.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/ugrpc/server/stream.hpp
4
/// @brief Server streaming interfaces
5
6
USERVER_NAMESPACE_BEGIN
7
8
namespace
ugrpc::server {
9
10
/// @brief Interface to read client's requests.
11
///
12
/// This class is not thread-safe.
13
///
14
/// If any method throws, further methods must not be called on the same stream.
15
template
<
class
Request>
16
class
Reader
{
17
public
:
18
/// @cond
19
virtual
~Reader() =
default
;
20
/// @endcond
21
22
/// @brief Await and read the next incoming message
23
/// @param request where to put the request on success
24
/// @returns `true` on success, `false` on end-of-input
25
/// @throws ugrpc::server::RpcError on an RPC error
26
[[
nodiscard
]]
virtual
bool
Read
(Request& request) = 0;
27
};
16
class
Reader
{
…
};
28
29
/// @brief Interface to write server's responses.
30
///
31
/// This class is not thread-safe.
32
///
33
/// If any method throws, further methods must not be called on the same stream.
34
template
<
class
Response>
35
class
Writer
{
36
public
:
37
/// @cond
38
virtual
~Writer() =
default
;
39
/// @endcond
40
41
/// @brief Write the next outgoing message
42
/// @param response the next message to write
43
/// @throws ugrpc::server::RpcError on an RPC error
44
/// @throws std::exception (internal) on error from middlewares
45
virtual
void
Write
(Response& response) = 0;
46
47
/// @brief Write the next outgoing message
48
/// @param response the next message to write
49
/// @throws ugrpc::server::RpcError on an RPC error
50
/// @throws std::exception (internal) on error from middlewares
51
virtual
void
Write
(Response&& response) = 0;
52
};
35
class
Writer
{
…
};
53
54
/// @brief Interface to both read and write messages.
55
///
56
/// If any method throws, further methods must not be called on the same stream.
57
///
58
/// This class allows the following concurrent calls:
59
///
60
/// - `Read`;
61
/// - `Write`
62
///
63
/// and there can only be one Read and one Write in flight at a time.
64
///
65
/// If any method throws, further methods must not be called on the same stream.
66
template
<
class
Request,
class
Response>
67
class
ReaderWriter
:
public
Reader
<Request>,
public
Writer
<Response> {};
68
69
}
// namespace ugrpc::server
70
71
USERVER_NAMESPACE_END
userver
ugrpc
server
stream.hpp
Generated on Wed Apr 30 2025 15:56:30 for userver by
Doxygen
1.13.2