userver: userver/storages/mysql/options.hpp Source File
Loading...
Searching...
No Matches
options.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/storages/mysql/options.hpp
4
5#include <chrono>
6#include <optional>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace storages::mysql {
11
12using TimeoutDuration = std::chrono::milliseconds;
13
14/// A structure to control timeouts for MySQL queries
15///
16/// There is a single parameter, `execute`, which limits the overall time
17/// the driver spends executing a query, which includes:
18/// * connecting to MySQL server, if there are no connections available and
19/// connection pool still has space for new connections;
20/// * waiting for a connection to become idle if there are no idle connections
21/// and connection pool already has reached its max size;
22/// * preparing the statement, if it's absent in statements cache;
23/// * executing the statement;
24/// * fetching all the statement results, if any, and not in cursor mode.
25///
26/// In case of a timeout the client gets an exception and the driver drops the
27/// connection (no further reuse will take place),
28/// otherwise the connection is returned to the pool.
29struct CommandControl final {
30 /// Overall timeout for a statement being executed.
31 TimeoutDuration execute{};
32};
33
34/// @brief storages::mysql::CommandControl that may not be set.
35using OptionalCommandControl = std::optional<CommandControl>;
36
37} // namespace storages::mysql
38
39USERVER_NAMESPACE_END