MySQL 8.0.39
Source Code Documentation
router_cs_options.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 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_ROUTER_CS_OPTIONS_INCLUDED
27#define METADATA_CACHE_ROUTER_CS_OPTIONS_INCLUDED
28
29#include "cluster_metadata.h"
30
31/** @class RouterClusterSetOptions
32 *
33 * @brief Represents the Router options in v2_cs_router_options view in the
34 * metadata schema
35 */
37 public:
38 /** @brief Pupulate the object by reading the options from the metadata
39 *
40 * @param session mysql server session to read metadata with
41 * @param router_id id of the Router in the metadata
42 *
43 * @returns true if successful, false otherwise
44 */
46 const unsigned router_id);
47
48 /** @brief Get the raw JSON string read from the metadata during the last
49 * read_from_metadata() call
50 */
51 std::string get_string() const { return options_str_; }
52
53 /** @brief Get the target_cluster assigned for a given Router in the metadata
54 *
55 * @param router_id id of the Router in the metadata
56 *
57 * @returns assigned target_cluster if read successful, std::nullopt otherwise
58 */
59 std::optional<mysqlrouter::TargetCluster> get_target_cluster(
60 const unsigned router_id) const;
61
62 /** @brief Get the stats updates ferquency value (in seconds) assigned for a
63 * given Router in the metadata
64 */
66
67 /** @brief Get the get_use_replica_primary_as_rw boolean value assigned for a
68 * given Router in the metadata
69 */
71
72 private:
73 std::string get_router_option_str(const std::string &options,
74 const std::string &name,
75 const std::string &default_value,
76 std::string &out_error) const;
77
78 uint32_t get_router_option_uint(const std::string &options,
79 const std::string &name,
80 const uint32_t &default_value,
81 std::string &out_error) const;
82
83 uint32_t get_router_option_bool(const std::string &options,
84 const std::string &name,
85 const bool &default_value,
86 std::string &out_error) const;
87
88 std::string options_str_;
89};
90
91#endif // METADATA_CACHE_ROUTER_CS_OPTIONS_INCLUDED
Represents the Router options in v2_cs_router_options view in the metadata schema.
Definition: router_cs_options.h:36
std::string get_router_option_str(const std::string &options, const std::string &name, const std::string &default_value, std::string &out_error) const
Definition: router_cs_options.cc:152
uint32_t get_router_option_bool(const std::string &options, const std::string &name, const bool &default_value, std::string &out_error) const
Definition: router_cs_options.cc:210
uint32_t get_router_option_uint(const std::string &options, const std::string &name, const uint32_t &default_value, std::string &out_error) const
Definition: router_cs_options.cc:179
bool get_use_replica_primary_as_rw() const
Get the get_use_replica_primary_as_rw boolean value assigned for a given Router in the metadata.
Definition: router_cs_options.cc:137
std::string options_str_
Definition: router_cs_options.h:88
std::optional< mysqlrouter::TargetCluster > get_target_cluster(const unsigned router_id) const
Get the target_cluster assigned for a given Router in the metadata.
Definition: router_cs_options.cc:65
std::chrono::seconds get_stats_updates_frequency() const
Get the stats updates ferquency value (in seconds) assigned for a given Router in the metadata.
Definition: router_cs_options.cc:120
std::string get_string() const
Get the raw JSON string read from the metadata during the last read_from_metadata() call.
Definition: router_cs_options.h:51
bool read_from_metadata(mysqlrouter::MySQLSession &session, const unsigned router_id)
Pupulate the object by reading the options from the metadata.
Definition: router_cs_options.cc:42
Definition: mysql_session.h:153
Definition: options.cc:49
case opt name
Definition: sslopt-case.h:33
double seconds()
Definition: task.cc:310