userver: userver/ugrpc/client/qos.hpp Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
qos.hpp
1#pragma once
2
3/// @file userver/ugrpc/client/qos.hpp
4/// @brief @copybrief ugrpc::client::Qos
5
6#include <chrono>
7#include <optional>
8
9#include <userver/formats/json_fwd.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace ugrpc::client {
14
15/// @brief Per-RPC quality-of-service config. Taken from
16/// @ref ugrpc::client::ClientQos. Can also be passed to ugrpc client methods
17/// manually.
18struct Qos final {
19 /// @brief The maximum number of RPC attempts, including the original attempt.
20 /// If set must be minimum 1.
21 /// If `std::nullopt`, default grpc++ retry configuration is used.
22 ///
23 /// See also [the official gRPC docs on retries](https://grpc.io/docs/guides/retry/).
24 std::optional<int> attempts;
25
26 /// @brief An upper bound on the deadline applied to the entire RPC.
27 /// If `std::nullopt`, no static deadline is applied, which is reasonable
28 /// for streaming RPCs.
29 ///
30 /// @ref scripts/docs/en/userver/deadline_propagation.md "Deadline propagation",
31 /// when enabled, also puts an upper bound on the RPC deadline.
32 ///
33 /// @note The problem of "dead servers" is typically solved using
34 /// [keepalive pings](https://github.com/grpc/grpc/blob/master/doc/keepalive.md),
35 /// not using timeouts.
36 std::optional<std::chrono::milliseconds> timeout;
37};
38
39bool operator==(const Qos& lhs, const Qos& rhs) noexcept;
40
41Qos Parse(const formats::json::Value& value, formats::parse::To<Qos>);
42
43formats::json::Value Serialize(const Qos& qos, formats::serialize::To<formats::json::Value>);
44
45std::optional<std::uint32_t> GetAttempts(const Qos& qos);
46
47std::optional<std::chrono::milliseconds> GetTotalTimeout(const Qos& qos);
48
49} // namespace ugrpc::client
50
51USERVER_NAMESPACE_END