userver: userver/storages/mongo/pool_config.hpp Source File
Loading...
Searching...
No Matches
pool_config.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <chrono>
7#include <cstddef>
8#include <optional>
9#include <string>
10
13
14USERVER_NAMESPACE_BEGIN
15
16namespace storages::mongo {
17
23
27struct PoolSettings final {
29 static constexpr size_t kDefaultInitialSize = 16;
31 static constexpr size_t kDefaultMaxSize = 128;
33 static constexpr size_t kDefaultIdleLimit = 64;
35 static constexpr size_t kDefaultConnectingLimit = 8;
36
46
48 std::optional<std::chrono::seconds> max_connection_lifetime;
49
51 void Validate(const std::string& pool_id) const;
52};
53
55
57struct PoolConfig final {
58 enum class DriverImpl {
59 kMongoCDriver,
60 };
61
63 static constexpr auto kDefaultConnTimeout = std::chrono::seconds{2};
65 static constexpr auto kDefaultSoTimeout = std::chrono::seconds{10};
67 static constexpr auto kDefaultQueueTimeout = std::chrono::seconds{1};
69 static constexpr auto kDefaultMaintenancePeriod = std::chrono::seconds{15};
71 static constexpr char kDefaultAppName[] = "userver";
72
74 void Validate(const std::string& pool_id) const;
75
77 std::chrono::milliseconds conn_timeout = kDefaultConnTimeout;
79 std::chrono::milliseconds so_timeout = kDefaultSoTimeout;
81 std::chrono::milliseconds queue_timeout = kDefaultQueueTimeout;
85 std::optional<std::chrono::milliseconds> local_threshold{};
87 std::chrono::milliseconds maintenance_period = kDefaultMaintenancePeriod;
88
92 std::optional<std::chrono::seconds> max_replication_lag;
93
95 DriverImpl driver_impl = DriverImpl::kMongoCDriver;
96
99
101 congestion_control::v2::LinearController::StaticConfig cc_config;
102
104 // Congestion-control subscriptions remain enabled for both sources.
105 enum class PoolSettingsSource {
106 kConfig,
107 kExternal,
108 };
109 PoolSettingsSource pool_settings_source = PoolSettingsSource::kConfig;
111};
112
113PoolConfig Parse(const yaml_config::YamlConfig& config, formats::parse::To<PoolConfig>);
114
115} // namespace storages::mongo
116
117USERVER_NAMESPACE_END