userver
C++ Async Framework
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
/
loggable_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
::
LoggableComponentBase
{
55
public
:
56
/// Component constructor
57
Component
(
const
components
::ComponentConfig& config,
58
const
components
::ComponentContext& context);
59
60
/// Component destructor
61
~
Component
()
override
;
62
63
/// Cluster accessor
64
std::shared_ptr<
storages
::
mysql
::Cluster>
GetCluster
()
const
;
65
66
static
yaml_config
::Schema GetStaticConfigSchema();
67
68
private
:
69
clients::dns::Component& dns_;
70
71
const
std::shared_ptr<
storages
::
mysql
::Cluster> cluster_;
72
utils::statistics::Entry statistics_holder_;
73
};
74
75
}
// namespace storages::mysql
76
77
USERVER_NAMESPACE_END
userver
storages
mysql
component.hpp
Generated on Wed May 15 2024 22:17:11 for userver by
Doxygen
1.10.0