MySQL 8.3.0
Source Code Documentation
plugin_config.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef METADATA_CACHE_PLUGIN_CONFIG_INCLUDED
26#define METADATA_CACHE_PLUGIN_CONFIG_INCLUDED
27
29
31
32#include <chrono>
33#include <map>
34#include <string>
35#include <vector>
36
38#include "mysql/harness/plugin.h"
41#include "tcp_address.h"
42
43extern "C" {
44extern mysql_harness::Plugin METADATA_CACHE_PLUGIN_EXPORT
46}
47
50 public:
51 /** @brief Constructor
52 *
53 * @param section from configuration file provided as ConfigSection
54 */
56
57 /**
58 * @param option name of the option
59 */
60 std::string get_default(const std::string &option) const override;
61 bool is_required(const std::string &option) const override;
62
63 mutable std::unique_ptr<ClusterMetadataDynamicState>
65 /** @brief MySQL Metadata hosts to connect with */
67 /** @brief User used for authenticating with MySQL Metadata */
68 std::string user;
69 /** @brief TTL used for storing data in the cache */
70 std::chrono::milliseconds ttl;
71 /** @brief TTL used for limiting the lifetime of the rest user authentication
72 * data stored in the metadata */
73 std::chrono::milliseconds auth_cache_ttl;
74 /** @brief Refresh rate of the rest user authentication data stored in the
75 * cache */
76 std::chrono::milliseconds auth_cache_refresh_interval;
77 /** @brief Name of the Cluster this Router instance was bootstrapped to use.
78 */
79 std::string cluster_name;
80 /** @brief connect_timeout The time in seconds after which trying to connect
81 * to metadata server timeouts */
82 unsigned int connect_timeout;
83 /** @brief read_timeout The time in seconds after which read from metadata
84 * server timeouts */
85 unsigned int read_timeout;
86 /** @brief memory in kilobytes allocated for thread's stack */
87 unsigned int thread_stack_size;
88 /** @brief Whether we should listen to GR notifications from the cluster
89 * nodes. */
91 /** @brief Type of the cluster this configuration was bootstrap against. */
93 /** @brief Id of the router in the metadata. */
94 unsigned int router_id;
95
96 /** @brief Gets (Group Replication ID for GR cluster or cluster_id for
97 * ReplicaSet cluster) if preset in the dynamic configuration.
98 *
99 * @note If there is no dynamic configuration (backward compatibility) it
100 * returns empty string.
101 */
102 std::string get_cluster_type_specific_id() const;
103
104 std::string get_clusterset_id() const;
105
106 /** @brief Gets last know ReplicaSet cluster metadata view_id stored in the
107 * dynamic state file . */
108 uint64_t get_view_id() const;
109
110 private:
111 /** @brief Gets a list of metadata servers.
112 *
113 *
114 * Throws std::invalid_argument on errors.
115 *
116 * @param section Instance of ConfigSection
117 * @param default_port Use this port when none was provided
118 * @return std::vector<mysql_harness::TCPAddress>
119 */
120 std::vector<mysql_harness::TCPAddress> get_metadata_servers(
121 const mysql_harness::ConfigSection *section, uint16_t default_port) const;
122
124 const mysql_harness::ConfigSection *section);
125
126 std::unique_ptr<ClusterMetadataDynamicState> get_dynamic_state(
127 const mysql_harness::ConfigSection *section);
128};
129
130#endif // METADATA_CACHE_PLUGIN_CONFIG_INCLUDED
Definition: plugin_config.h:49
std::chrono::milliseconds auth_cache_ttl
TTL used for limiting the lifetime of the rest user authentication data stored in the metadata.
Definition: plugin_config.h:73
std::string user
User used for authenticating with MySQL Metadata.
Definition: plugin_config.h:68
unsigned int connect_timeout
connect_timeout The time in seconds after which trying to connect to metadata server timeouts
Definition: plugin_config.h:82
std::chrono::milliseconds auth_cache_refresh_interval
Refresh rate of the rest user authentication data stored in the cache.
Definition: plugin_config.h:76
unsigned int router_id
Id of the router in the metadata.
Definition: plugin_config.h:94
bool use_gr_notifications
Whether we should listen to GR notifications from the cluster nodes.
Definition: plugin_config.h:90
const metadata_cache::metadata_servers_list_t metadata_servers_addresses
MySQL Metadata hosts to connect with.
Definition: plugin_config.h:66
std::unique_ptr< ClusterMetadataDynamicState > metadata_cache_dynamic_state
Definition: plugin_config.h:64
std::string cluster_name
Name of the Cluster this Router instance was bootstrapped to use.
Definition: plugin_config.h:79
mysqlrouter::ClusterType cluster_type
Type of the cluster this configuration was bootstrap against.
Definition: plugin_config.h:92
std::chrono::milliseconds ttl
TTL used for storing data in the cache.
Definition: plugin_config.h:70
unsigned int read_timeout
read_timeout The time in seconds after which read from metadata server timeouts
Definition: plugin_config.h:85
unsigned int thread_stack_size
memory in kilobytes allocated for thread's stack
Definition: plugin_config.h:87
mysqlrouter::ClusterType get_cluster_type(const mysql_harness::ConfigSection *section)
Retrieve and manage plugin configuration.
Definition: plugin_config.h:61
virtual bool is_required(const std::string &option) const =0
Returns whether the given option is required.
virtual std::string get_default(const std::string &option) const =0
Gets the default for the given option.
Configuration section.
Definition: config_parser.h:140
static stdx::expected< std::string, std::error_code > get_clusterset_id(mysqlrouter::MySQLSession &session, const mysqlrouter::TargetCluster &target_cluster)
Definition: cluster_metadata_gr.cc:1187
mysql_harness::Plugin METADATA_CACHE_PLUGIN_EXPORT harness_plugin_metadata_cache
Definition: metadata_cache_plugin.cc:303
#define METADATA_CACHE_PLUGIN_EXPORT
Definition: metadata_cache_plugin_export.h:15
std::vector< metadata_server_t > metadata_servers_list_t
Definition: metadata_cache_datatypes.h:145
ClusterType
Definition: cluster_metadata.h:141