userver
C++ Async Framework
Toggle main menu visibility
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
pool_config.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/mongo/pool_config.hpp
4
/// @brief @copybrief storages::mongo::PoolConfig
5
6
#
include
<
chrono
>
7
#
include
<
cstddef
>
8
#
include
<
optional
>
9
#
include
<
string
>
10
11
#
include
<
userver
/
components
/
component_fwd
.
hpp
>
12
#
include
<
userver
/
congestion_control
/
controllers
/
linear
.
hpp
>
13
14
USERVER_NAMESPACE_BEGIN
15
16
namespace
storages::mongo {
17
18
enum
class
StatsVerbosity
{
19
kTerse
,
///< Only pool stats and read/write overalls by collection
20
kFull
,
///< Stats with separate metrics per operation type and label
21
kNone
,
///< No stats at all
22
};
18
enum
class
StatsVerbosity
{
…
};
23
24
/// @brief Mongo connection pool options
25
///
26
/// Dynamic option @ref MONGO_CONNECTION_POOL_SETTINGS
27
struct
PoolSettings
final
{
28
/// Default initial connection count
29
static
constexpr
size_t
kDefaultInitialSize
= 16;
30
/// Default total connections limit
31
static
constexpr
size_t
kDefaultMaxSize
= 128;
32
/// Default idle connections limit
33
static
constexpr
size_t
kDefaultIdleLimit
= 64;
34
/// Default establishing connections limit
35
static
constexpr
size_t
kDefaultConnectingLimit
= 8;
36
37
/// Initial connection count
38
size_t
initial_size
=
kDefaultInitialSize
;
39
/// Total connections limit
40
size_t
max_size
=
kDefaultMaxSize
;
41
/// Idle connections limit
42
size_t
idle_limit
=
kDefaultIdleLimit
;
43
/// Establishing connections limit
44
size_t
connecting_limit
=
kDefaultConnectingLimit
;
45
46
/// @throws InvalidConfigException if pool settings are invalid
47
void
Validate
(
const
std::string& pool_id)
const
;
48
};
27
struct
PoolSettings
final
{
…
};
49
50
PoolSettings Parse(
const
yaml_config
::
YamlConfig
& config,
formats
::
parse
::
To
<PoolSettings>);
51
52
/// MongoDB connection pool configuration
53
struct
PoolConfig
final
{
54
enum
class
DriverImpl {
55
kMongoCDriver,
56
};
57
58
/// Default connection timeout
59
static
constexpr
auto
kDefaultConnTimeout
= std::chrono::seconds{2};
60
/// Default socket timeout
61
static
constexpr
auto
kDefaultSoTimeout
= std::chrono::seconds{10};
62
/// Default connection queue timeout
63
static
constexpr
auto
kDefaultQueueTimeout
= std::chrono::seconds{1};
64
/// Default pool maintenance period
65
static
constexpr
auto
kDefaultMaintenancePeriod
= std::chrono::seconds{15};
66
/// Default application name
67
static
constexpr
char
kDefaultAppName
[] =
"userver"
;
68
69
/// @throws InvalidConfigException if the config is invalid
70
void
Validate
(
const
std::string& pool_id)
const
;
71
72
/// Connection (I/O) timeout
73
std::chrono::milliseconds
conn_timeout
=
kDefaultConnTimeout
;
74
/// Socket (I/O) timeout
75
std::chrono::milliseconds
so_timeout
=
kDefaultSoTimeout
;
76
/// Connection queue wait time
77
std::chrono::milliseconds
queue_timeout
=
kDefaultQueueTimeout
;
78
/// settings for connections pool
79
PoolSettings
pool_settings
{};
80
/// Instance selection latency window override
81
std::optional<std::chrono::milliseconds>
local_threshold
{};
82
/// Pool maintenance period
83
std::chrono::milliseconds
maintenance_period
=
kDefaultMaintenancePeriod
;
84
85
/// Application name (sent to server)
86
std::string
app_name
=
kDefaultAppName
;
87
/// Default max replication lag for the pool
88
std::optional<std::chrono::seconds>
max_replication_lag
;
89
90
/// Driver implementation to use
91
DriverImpl
driver_impl
= DriverImpl::kMongoCDriver;
92
93
/// Whether to write detailed stats
94
StatsVerbosity
stats_verbosity
=
StatsVerbosity
::
kTerse
;
95
96
/// Congestion control config
97
congestion_control::
v2
::LinearController::StaticConfig
cc_config
;
98
};
53
struct
PoolConfig
final
{
…
};
99
100
PoolConfig Parse(
const
yaml_config
::
YamlConfig
& config,
formats
::
parse
::
To
<PoolConfig>);
101
102
}
// namespace storages::mongo
103
104
USERVER_NAMESPACE_END
userver
storages
mongo
pool_config.hpp
Generated on Thu Apr 24 2025 12:20:38 for userver by
Doxygen
1.13.2