MySQL 8.4.2
Source Code Documentation
builtin_plugins.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018, 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 MYSQL_HARNESS_BUILTIN_PLUGINS_INCLUDED
27#define MYSQL_HARNESS_BUILTIN_PLUGINS_INCLUDED
28
29#include "mysql/harness/plugin.h"
30
31#include "harness_export.h"
32
33#include <map>
34#include <string>
35
36namespace mysql_harness {
37
38/**
39 * @brief Singleton class implementing registry of the built-in MySQLRouter
40 * plugins.
41 *
42 * Built-in plugin is statically linked to the harness library (does not have
43 * dedicated .so or .dll file) but implements the same API as the external
44 * plugin (init(), start(), etc.) that is called by the Loader.
45 */
46class HARNESS_EXPORT BuiltinPlugins {
47 public:
48 /**
49 * @brief Gets the singleton instance.
50 */
51 static BuiltinPlugins &instance();
52
53 /**
54 * It's a singleton so we disable copying.
55 */
56 BuiltinPlugins(const BuiltinPlugins &) = delete;
58
59 /**
60 * Stores the information about a single built-in plugin.
61 */
62 struct PluginInfo {
63 /**
64 * pointer to the plugin struct (used by the Loader to run init(),
65 * start(), etc on the plugin)
66 */
68
69 /** if true the plugin should ALWAYS be loaded even if it does not have
70 * its section in the configuration
71 */
73 };
74
75 using PluginsMap = std::map<std::string, PluginInfo>;
76
77 /** @brief Checks if there is a built-in plugin with a specified name
78 *
79 * @param plugin_name plugin name to check
80 * @return true if there is a built-in plugin with a given name in the
81 * registry, false otherwise
82 */
83 bool has(const std::string &plugin_name) noexcept;
84
85 /** @brief Returns the map containing information about all built-in plugins
86 * in the registry
87 *
88 * @return map containing information about all built-in plugins in the
89 * registry
90 */
91 const PluginsMap *get() noexcept { return &plugins_; }
92
93 /** @brief Returns pointer to the Plugin struct for the plugin with
94 * selected name
95 *
96 * @throw std::out_of_range if there is no info about the plugin with a given
97 * name.
98 *
99 * @param plugin_name name of the plugin queried for the Plugin struct
100 * @return Plugin struct for the plugin with selected name
101 */
102 Plugin *get_plugin(const std::string &plugin_name) {
103 return plugins_.at(plugin_name).plugin;
104 }
105
106 /**
107 * add plugin to the built in plugins.
108 */
109 void add(std::string name, PluginInfo plugin_info);
110
111 private:
114};
115
116} // namespace mysql_harness
117
118#endif
Kerberos Client Authentication Plugin
Definition: auth_kerberos_client_plugin.cc:250
Singleton class implementing registry of the built-in MySQLRouter plugins.
Definition: builtin_plugins.h:46
BuiltinPlugins & operator=(const BuiltinPlugins &)=delete
Plugin * get_plugin(const std::string &plugin_name)
Returns pointer to the Plugin struct for the plugin with selected name.
Definition: builtin_plugins.h:102
const PluginsMap * get() noexcept
Returns the map containing information about all built-in plugins in the registry.
Definition: builtin_plugins.h:91
PluginsMap plugins_
Definition: builtin_plugins.h:113
std::map< std::string, PluginInfo > PluginsMap
Definition: builtin_plugins.h:75
BuiltinPlugins(const BuiltinPlugins &)=delete
It's a singleton so we disable copying.
bool has(const Container &c, Value &&val)
Definition: generic.h:97
Definition: common.h:42
static MYSQL_PLUGIN plugin_info
Definition: rewriter_plugin.cc:89
LEX_CSTRING * plugin_name(st_plugin_int **ref)
Definition: sql_plugin_ref.h:95
case opt name
Definition: sslopt-case.h:29
Stores the information about a single built-in plugin.
Definition: builtin_plugins.h:62
Plugin * plugin
pointer to the plugin struct (used by the Loader to run init(), start(), etc on the plugin)
Definition: builtin_plugins.h:67
bool always_load
if true the plugin should ALWAYS be loaded even if it does not have its section in the configuration
Definition: builtin_plugins.h:72