MySQL 9.3.0
Source Code Documentation
mysql_rest_service_plugin_config.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2021, 2025, 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 ROUTER_SRC_REST_MRS_SRC_REST_MRS_CONFIG_H_
27#define ROUTER_SRC_REST_MRS_SRC_REST_MRS_CONFIG_H_
28
29#include <algorithm>
30#include <string>
31
37
39#include "mrs/configuration.h"
40
42 public:
43 void operator()(const char *variable);
44};
45
46namespace mrs {
47
50 public:
54 template <typename T>
56
57 const std::string k_option_metadata_refresh = "metadata_refresh_interval";
58
59 public:
60 explicit PluginConfig(const ConfigSection *section,
61 const std::vector<std::string> &routing_sections,
62 const std::string &router_name);
63
65 std::set<std::string> get_waiting_for_routing_plugins();
66
67 bool is_required(std::string_view option) const override;
68 std::string get_default(std::string_view option) const override;
69
70 private:
72 public:
73 void operator()(const char *) {}
74 };
75
76 template <typename ErrorReport = NoReporting>
77 static std::string get_keyring_value(const std::string &user,
78 const char *attr) {
79 try {
81 throw std::runtime_error("Keyring not running");
82 return mysql_harness::get_keyring()->fetch(user.c_str(), attr);
83
84 } catch (const std::exception &e) {
85 ErrorReport()(user.c_str());
86 throw std::runtime_error(std::string("Could not fetch value for '") +
87 user + "' from the keyring: " + e.what());
88 }
89 }
90};
91
92} // namespace mrs
93
94#endif // ROUTER_SRC_REST_MRS_SRC_REST_MRS_CONFIG_H_
Definition: mysql_rest_service_plugin_config.h:41
void operator()(const char *variable)
Definition: configuration.h:47
Definition: mysql_rest_service_plugin_config.h:71
void operator()(const char *)
Definition: mysql_rest_service_plugin_config.h:73
Definition: mysql_rest_service_plugin_config.h:49
std::set< std::string > get_waiting_for_routing_plugins()
Definition: mysql_rest_service_plugin_config.cc:328
PluginConfig(const ConfigSection *section, const std::vector< std::string > &routing_sections, const std::string &router_name)
Definition: mysql_rest_service_plugin_config.cc:280
static std::string get_keyring_value(const std::string &user, const char *attr)
Definition: mysql_rest_service_plugin_config.h:77
const std::string k_option_metadata_refresh
Definition: mysql_rest_service_plugin_config.h:57
bool is_required(std::string_view option) const override
Returns whether the given option is required.
Definition: mysql_rest_service_plugin_config.cc:365
std::string get_default(std::string_view option) const override
Gets the default for the given option.
Definition: mysql_rest_service_plugin_config.cc:373
bool init_runtime_configuration()
Definition: mysql_rest_service_plugin_config.cc:337
Retrieve and manage plugin configuration.
Definition: plugin_config.h:62
Configuration section.
Definition: config_parser.h:141
Definition: config_option.h:203
Definition: config_option.h:112
virtual std::string fetch(const std::string &uid, const std::string &attribute) const =0
Retrieves attribute value from an entry.
Definition: config_option.h:156
mysql_harness::StringOption StringOption
Definition: http_auth_backend_plugin.cc:65
char * user
Definition: mysqladmin.cc:67
Definition: authorize_manager.h:48
HARNESS_EXPORT Keyring * get_keyring() noexcept
Gets a previously initialized singleton instance of the keyring.
Definition: keyring_manager.cc:212
DurationOption< std::chrono::seconds > SecondsOption
Definition: config_option.h:227