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
component.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/mysql/component.hpp
4
/// @brief @copybrief storages::mysql::Component
5
6
#
include
<
memory
>
7
8
#
include
<
userver
/
components
/
component_base
.
hpp
>
9
#
include
<
userver
/
utils
/
statistics
/
entry
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
clients::
dns
{
14
class
Component;
15
}
16
17
namespace
storages::
mysql
{
18
class
Cluster;
19
}
20
21
namespace
storages::
mysql
{
22
23
// clang-format off
24
/// @ingroup userver_components
25
///
26
/// @brief MySQL/MariaDB client component
27
///
28
/// Provides access to a MySQL/MariaDB cluster.
29
///
30
/// ## Static configuration example:
31
///
32
/// @snippet samples/mysql_service/static_config.yaml MySQL service sample - static config
33
///
34
/// The component will lookup connection data in secdist.json via its name.
35
///
36
/// ## Secdist format:
37
///
38
/// Connection settings are described as a JSON object `mysql_settings`,
39
/// containing descriptions of MySQL/MariaDB clusters.
40
///
41
/// @snippet samples/mysql_service/tests/conftest.py Mysql service sample - secdist
42
///
43
/// **Important note**: the uMySQL driver does **NOT** perform an automatic
44
/// primary detection and always considers the first host in `hosts` list
45
/// an only primary node in the cluster.
46
///
47
/// ## Static options (more to come)
48
/// Name | Description | Default value
49
/// -------------------------|---------------------------------------------|---------------
50
/// initial_pool_size | initial connection pool size (per host) | 5
51
/// max_pool_size | maximum connection pool size (per host) | 10
52
///
53
// clang-format on
54
class
Component
final
:
public
components
::
ComponentBase
{
55
public
:
56
/// Component constructor
57
Component
(
const
components
::ComponentConfig& config,
const
components
::ComponentContext& context);
58
59
/// Component destructor
60
~
Component
()
override
;
61
62
/// Cluster accessor
63
std::shared_ptr<storages::
mysql
::Cluster>
GetCluster
()
const
;
64
65
static
yaml_config
::Schema GetStaticConfigSchema();
66
67
private
:
68
clients::
dns
::Component& dns_;
69
70
const
std::shared_ptr<storages::
mysql
::Cluster> cluster_;
71
utils
::statistics::Entry statistics_holder_;
72
};
54
class
Component
final
:
public
components
::
ComponentBase
{
…
};
73
74
}
// namespace storages::mysql
75
76
USERVER_NAMESPACE_END
userver
storages
mysql
component.hpp
Generated on Wed Apr 30 2025 15:51:21 for userver by
Doxygen
1.13.2