MySQL 9.7.0
Source Code Documentation
registry.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2026, 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 MYSQL_HARNESS_RESOLVER_REGISTRY_H_
27#define MYSQL_HARNESS_RESOLVER_REGISTRY_H_
28
29#include <array>
30#include <memory>
31#include <shared_mutex>
32
33#include "harness_export.h"
35
36namespace mysql_harness {
37namespace resolver {
38
39class HARNESS_EXPORT Registry final {
40 public:
41 static Registry &get_instance();
42
43 void set(CachePolicy policy, std::shared_ptr<ResolverInterface> resolver);
44 std::shared_ptr<ResolverInterface> get(CachePolicy policy) const;
45
46 void clear();
47 void clear(CachePolicy policy);
48
49 private:
50 Registry();
51 ~Registry() = default;
52
53 mutable std::shared_mutex mutex_;
54 std::array<std::shared_ptr<ResolverInterface>, 3> resolvers_{};
55 std::shared_ptr<ResolverInterface> default_resolver_;
56 std::shared_ptr<ResolverInterface> default_forwarder_;
57};
58
59} // namespace resolver
60} // namespace mysql_harness
61
62#endif // MYSQL_HARNESS_RESOLVER_REGISTRY_H_
Definition: registry.h:39
std::shared_ptr< ResolverInterface > default_resolver_
Definition: registry.h:55
std::shared_ptr< ResolverInterface > default_forwarder_
Definition: registry.h:56
std::shared_mutex mutex_
Definition: registry.h:53
static mysql_service_status_t get(THD **thd) noexcept
Definition: mysql_current_thread_reader_all_empty.cc:31
CachePolicy
Definition: common.h:40
Definition: common.h:44
static mysql_service_status_t clear(reference_caching_channel channel) noexcept
Definition: component.cc:146
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2888