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::optional<std::uint32_t> retries{std::nullopt};
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 std::string trace_id{};
29};
30
31struct QuerySettings final {
32 std::optional<bool> keep_in_query_cache{std::nullopt};
33 std::optional<NYdb::NTable::ECollectQueryStatsMode> collect_query_stats{
34 std::nullopt};
35};
36
37} // namespace ydb
38
39namespace formats::parse {
40
41ydb::OperationSettings Parse(const yaml_config::YamlConfig& config,
42 To<ydb::OperationSettings>);
43
44} // namespace formats::parse
45
46USERVER_NAMESPACE_END