MySQL 8.0.40
Source Code Documentation
plugin_config.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 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 METADATA_CACHE_PLUGIN_CONFIG_INCLUDED
27#define METADATA_CACHE_PLUGIN_CONFIG_INCLUDED
28
30
32
33#include <chrono>
34#include <map>
35#include <string>
36#include <vector>
37
39#include "mysql/harness/plugin.h"
42#include "tcp_address.h"
43
44extern "C" {
45extern mysql_harness::Plugin METADATA_CACHE_PLUGIN_EXPORT
47}
48
51 public:
52 /** @brief Constructor
53 *
54 * @param section from configuration file provided as ConfigSection
55 */
57
58 /**
59 * @param option name of the option
60 */
61 std::string get_default(const std::string &option) const override;
62 bool is_required(const std::string &option) const override;
63
64 mutable std::unique_ptr<ClusterMetadataDynamicState>
66 /** @brief MySQL Metadata hosts to connect with */
68 /** @brief User used for authenticating with MySQL Metadata */
69 std::string user;
70 /** @brief TTL used for storing data in the cache */
71 std::chrono::milliseconds ttl;
72 /** @brief TTL used for limiting the lifetime of the rest user authentication
73 * data stored in the metadata */
74 std::chrono::milliseconds auth_cache_ttl;
75 /** @brief Refresh rate of the rest user authentication data stored in the
76 * cache */
77 std::chrono::milliseconds auth_cache_refresh_interval;
78 /** @brief Name of the Cluster this Router instance was bootstrapped to use.
79 */
80 std::string cluster_name;
81 /** @brief connect_timeout The time in seconds after which trying to connect
82 * to metadata server timeouts */
83 unsigned int connect_timeout;
84 /** @brief read_timeout The time in seconds after which read from metadata
85 * server timeouts */
86 unsigned int read_timeout;
87 /** @brief memory in kilobytes allocated for thread's stack */
88 unsigned int thread_stack_size;
89 /** @brief Whether we should listen to GR notifications from the cluster
90 * nodes. */
92 /** @brief Type of the cluster this configuration was bootstrap against. */
94 /** @brief Id of the router in the metadata. */
95 unsigned int router_id;
96
97 /** @brief Gets (Group Replication ID for GR cluster or cluster_id for
98 * ReplicaSet cluster) if preset in the dynamic configuration.
99 *
100 * @note If there is no dynamic configuration (backward compatibility) it
101 * returns empty string.
102 */
103 std::string get_cluster_type_specific_id() const;
104
105 std::string get_clusterset_id() const;
106
107 /** @brief Gets last know ReplicaSet cluster metadata view_id stored in the
108 * dynamic state file . */
109 uint64_t get_view_id() const;
110
111 private:
112 /** @brief Gets a list of metadata servers.
113 *
114 *
115 * Throws std::invalid_argument on errors.
116 *
117 * @param section Instance of ConfigSection
118 * @param default_port Use this port when none was provided
119 * @return std::vector<mysql_harness::TCPAddress>
120 */
121 std::vector<mysql_harness::TCPAddress> get_metadata_servers(
122 const mysql_harness::ConfigSection *section, uint16_t default_port) const;
123
125 const mysql_harness::ConfigSection *section);
126
127 std::unique_ptr<ClusterMetadataDynamicState> get_dynamic_state(
128 const mysql_harness::ConfigSection *section);
129};
130
131#endif // METADATA_CACHE_PLUGIN_CONFIG_INCLUDED
Definition: plugin_config.h:50
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:74
std::string user
User used for authenticating with MySQL Metadata.
Definition: plugin_config.h:69
unsigned int connect_timeout
connect_timeout The time in seconds after which trying to connect to metadata server timeouts
Definition: plugin_config.h:83
std::chrono::milliseconds auth_cache_refresh_interval
Refresh rate of the rest user authentication data stored in the cache.
Definition: plugin_config.h:77
unsigned int router_id
Id of the router in the metadata.
Definition: plugin_config.h:95
bool use_gr_notifications
Whether we should listen to GR notifications from the cluster nodes.
Definition: plugin_config.h:91
const metadata_cache::metadata_servers_list_t metadata_servers_addresses
MySQL Metadata hosts to connect with.
Definition: plugin_config.h:67
std::unique_ptr< ClusterMetadataDynamicState > metadata_cache_dynamic_state
Definition: plugin_config.h:65
std::string cluster_name
Name of the Cluster this Router instance was bootstrapped to use.
Definition: plugin_config.h:80
mysqlrouter::ClusterType cluster_type
Type of the cluster this configuration was bootstrap against.
Definition: plugin_config.h:93
std::chrono::milliseconds ttl
TTL used for storing data in the cache.
Definition: plugin_config.h:71
unsigned int read_timeout
read_timeout The time in seconds after which read from metadata server timeouts
Definition: plugin_config.h:86
unsigned int thread_stack_size
memory in kilobytes allocated for thread's stack
Definition: plugin_config.h:88
mysqlrouter::ClusterType get_cluster_type(const mysql_harness::ConfigSection *section)
Retrieve and manage plugin configuration.
Definition: plugin_config.h:62
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:141
static stdx::expected< std::string, std::error_code > get_clusterset_id(mysqlrouter::MySQLSession &session, const mysqlrouter::TargetCluster &target_cluster)
Definition: cluster_metadata_gr.cc:1127
mysql_harness::Plugin METADATA_CACHE_PLUGIN_EXPORT harness_plugin_metadata_cache
Definition: metadata_cache_plugin.cc:300
#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:146
ClusterType
Definition: cluster_metadata.h:141