MySQL 8.0.39
Source Code Documentation
connection_pool_component.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2021, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQLROUTER_CONNECTION_POOL_COMPONENT_INCLUDED
27#define MYSQLROUTER_CONNECTION_POOL_COMPONENT_INCLUDED
28
29#include <memory> // shared_ptr
30#include <mutex>
31#include <string>
32#include <unordered_map>
33#include <vector>
34
36
37class ConnectionPool;
38
40 public:
41 static ConnectionPoolComponent &get_instance();
42
43 using key_type = std::string;
44
45 // disable copy, as we are a single-instance
47 void operator=(ConnectionPoolComponent const &) = delete;
48
49 // no move either
52
53 template <class... Args>
54 void emplace(Args &&... args) {
55 pools_.emplace(std::forward<Args>(args)...);
56 }
57
58 void erase(const key_type &name);
59
60 void clear();
61
62 std::shared_ptr<ConnectionPool> get(const key_type &name);
63
64 std::vector<std::string> pool_names() const;
65
66 static std::string default_pool_name();
67
68 private:
70
71 std::unordered_map<key_type, std::shared_ptr<ConnectionPool>> pools_;
72};
73
74#endif
Definition: connection_pool_component.h:39
ConnectionPoolComponent(ConnectionPoolComponent &&)=delete
ConnectionPoolComponent(ConnectionPoolComponent const &)=delete
std::unordered_map< key_type, std::shared_ptr< ConnectionPool > > pools_
Definition: connection_pool_component.h:71
void operator=(ConnectionPoolComponent const &)=delete
void operator=(ConnectionPoolComponent &&)=delete
void emplace(Args &&... args)
Definition: connection_pool_component.h:54
std::string key_type
Definition: connection_pool_component.h:43
ConnectionPoolComponent()=default
connection pool of mysql connections.
Definition: connection_pool.h:210
#define CONNECTION_POOL_EXPORT
Definition: connection_pool_export.h:15
int key_type
Definition: http_request.h:50
void get(PSI_field *, PSI_longlong *) noexcept
Definition: pfs_plugin_column_bigint_v1_all_empty.cc:32
static mysql_service_status_t clear(reference_caching_channel channel) noexcept
Definition: component.cc:154
case opt name
Definition: sslopt-case.h:33