userver
C++ Async Framework
Loading...
Searching...
No Matches
status_codes.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/ugrpc/status_codes.hpp
4
/// @brief Utilities for grpc::StatusCode
5
6
#
include
<
grpcpp
/
support
/
status
.
h
>
7
8
#
include
<
userver
/
formats
/
json_fwd
.
hpp
>
9
#
include
<
userver
/
yaml_config
/
fwd
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
ugrpc {
14
15
/// @brief Convert string to grpc::StatusCode
16
/// @throws std::runtime_error
17
grpc::StatusCode
StatusCodeFromString
(std::string_view str);
18
19
/// @brief Convert grpc::StatusCode to string
20
std::string
ToString
(grpc::StatusCode code)
noexcept
;
21
22
/// @brief Whether a given status code is definitely a server-side error
23
///
24
/// Currently includes:
25
///
26
/// * `UNKNOWN`
27
/// * `UNIMPLEMENTED`
28
/// * `INTERNAL`
29
/// * `UNAVAILABLE`
30
/// * `DATA_LOSS`
31
///
32
/// We intentionally do not include `CANCELLED` and `DEADLINE_EXPIRED` here, because the situation may either be
33
/// considered not erroneous at all (when a client explicitly cancels an RPC; when a client attempts an RPC with a very
34
/// short deadline), or there is no single obvious service to blame (when the collective deadline expires for an RPC
35
/// tree).
36
bool
IsServerError
(grpc::StatusCode code)
noexcept
;
37
38
}
// namespace ugrpc
39
40
namespace
formats
::
parse
{
41
42
/// @ref yaml_config::YamlConfig parsing support for `grpc::StatusCode`.
43
grpc::StatusCode
Parse
(
const
yaml_config
::
YamlConfig
& value,
To
<grpc::StatusCode>);
44
45
/// Support for parsing `grpc::StatusCode` from string. Used for headers and map keys.
46
grpc::StatusCode
Parse
(std::string_view value,
To
<grpc::StatusCode>);
47
48
}
// namespace formats::parse
49
50
namespace
formats
::
serialize
{
51
52
formats
::
json
::Value Serialize(
const
grpc::StatusCode& value,
formats
::
serialize
::
To
<
formats
::
json
::Value>);
53
54
}
55
56
USERVER_NAMESPACE_END
userver
ugrpc
status_codes.hpp
Generated on Mon Oct 6 2025 12:30:50 for userver by
Doxygen
1.13.2