userver: userver/ydb/settings.hpp Source File
Loading...
Searching...
No Matches
settings.hpp
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <optional>
6#include <string_view>
7
8#include <ydb-cpp-sdk/client/table/query_stats/stats.h>
9
10#include <userver/yaml_config/fwd.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace ydb {
15
16enum class TransactionMode { kSerializableRW, kOnlineRO, kStaleRO };
17
18struct OperationSettings final {
19 std::uint32_t retries{0};
20
21 // https://docs.yandex-team.ru/ydb-tech/best_practices/timeouts#operational
22 std::chrono::milliseconds operation_timeout_ms{0};
23 std::chrono::milliseconds cancel_after_ms{0};
24 std::chrono::milliseconds client_timeout_ms{0};
25 std::optional<TransactionMode> tx_mode{std::nullopt};
26 std::chrono::milliseconds get_session_timeout_ms{0};
27
28 // @cond
29 std::string_view trace_id{};
30 // @endcond
31};
32
33struct QuerySettings final {
34 std::optional<bool> keep_in_query_cache{std::nullopt};
35 std::optional<NYdb::NTable::ECollectQueryStatsMode> collect_query_stats{
36 std::nullopt};
37};
38
39} // namespace ydb
40
41namespace formats::parse {
42
43ydb::OperationSettings Parse(const yaml_config::YamlConfig& config,
44 To<ydb::OperationSettings>);
45
46} // namespace formats::parse
47
48USERVER_NAMESPACE_END