lintel 0.2.0
Loading...
Searching...
No Matches
ConnectionPoolRegistry.h
Go to the documentation of this file.
1#ifndef LINTEL_CONNECTIONPOOLREGISTRY_H
2#define LINTEL_CONNECTIONPOOLREGISTRY_H
3
4#include <cstddef>
5#include <map>
6#include <memory>
7#include <mutex>
8#include <string>
9#include <vector>
10
12
13namespace lintel {
14namespace db {
34 {
35 public:
38
43 void registerPool(std::string name, std::shared_ptr<ConnectionPool> pool);
44
50 [[nodiscard]] std::shared_ptr<ConnectionPool> poolOf(const std::string &name) const;
51
54 [[nodiscard]] bool hasPool(const std::string &name) const;
55
57 void clear();
58
60 [[nodiscard]] bool empty() const;
61
63 [[nodiscard]] std::size_t size() const;
64
66 [[nodiscard]] std::vector<std::string> names() const;
67
68 private:
69 ConnectionPoolRegistry() = default;
70
71 mutable std::mutex m_mutex;
72 std::map<std::string, std::shared_ptr<ConnectionPool>> m_pools;
73 };
74}// namespace db
75
76}// namespace lintel
77#endif// LINTEL_CONNECTIONPOOLREGISTRY_H
Definition ConnectionPoolRegistry.h:34
static ConnectionPoolRegistry & instance()
std::shared_ptr< ConnectionPool > poolOf(const std::string &name) const
bool hasPool(const std::string &name) const
std::vector< std::string > names() const
void registerPool(std::string name, std::shared_ptr< ConnectionPool > pool)
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9