MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
destination.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2020, 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 MYSQLROUTER_DESTINATION_INCLUDED
27#define MYSQLROUTER_DESTINATION_INCLUDED
28
29#include <list> // list
30#include <memory> // unique_ptr
31#include <string> // string
32#include <system_error> // error_code
33
35#include "mysqlrouter/datatypes.h" // ServerMode
37
38/**
39 * Destination to forward client connections to.
40 *
41 * It is used between the DestinationManager implementations and MySQLRouting
42 */
44 public:
48 std::string routing_guidelines_route_name,
49 const std::optional<bool> connection_sharing_allowed = std::nullopt)
50 : dest_(std::move(dest)), server_info_(std::move(server_info)) {
52 std::move(routing_guidelines_route_name);
54 connection_sharing_allowed;
55 }
56
57 Destination() = default;
58 Destination(const Destination &) = default;
59 Destination &operator=(const Destination &) = default;
60 Destination(Destination &&) = default;
62 virtual ~Destination() = default;
63
65 std::optional<bool> connection_sharing_allowed;
66 std::string route_name;
67 };
68
70 return dest_.value();
71 }
72
73 /**
74 * Get server UUID.
75 */
76 const std::string &server_uuid() const { return server_info_.uuid; }
77
78 /**
79 * Get server information.
80 */
82 return server_info_;
83 }
84
85 /**
86 * Get name of the route that was used to reach this destination.
87 *
88 * @return route name
89 */
90 const std::string &route_name() const {
92 }
93
94 /**
95 * Set name of the route that was used to reach this destination.
96 *
97 * @param name route name
98 */
99 void set_route_name(std::string name) {
101 }
102
103 /**
104 * server-mode of the destination.
105 *
106 * may be: unavailable, read-only or read-write.
107 */
108 virtual mysqlrouter::ServerMode server_mode() const;
109
112 }
113
114 /**
115 * Disable connection sharing if sharing prerequisites cannot be met.
116 */
119 }
120
121 private:
122 std::optional<mysql_harness::Destination> dest_;
125};
126
127#endif
Destination to forward client connections to.
Definition: destination.h:43
Destination(const Destination &)=default
const std::string & route_name() const
Get name of the route that was used to reach this destination.
Definition: destination.h:90
std::optional< mysql_harness::Destination > dest_
Definition: destination.h:122
Destination(Destination &&)=default
virtual ~Destination()=default
virtual mysqlrouter::ServerMode server_mode() const
server-mode of the destination.
Definition: destination.cc:81
void disable_connection_sharing()
Disable connection sharing if sharing prerequisites cannot be met.
Definition: destination.h:117
Destination(mysql_harness::Destination dest, routing_guidelines::Server_info server_info, std::string routing_guidelines_route_name, const std::optional< bool > connection_sharing_allowed=std::nullopt)
Definition: destination.h:45
Destination()=default
routing_guidelines::Server_info server_info_
Definition: destination.h:123
Guidelines_route_info guidelines_route_info_
Definition: destination.h:124
const Guidelines_route_info & guidelines_route_info() const
Definition: destination.h:110
const mysql_harness::Destination & destination() const
Definition: destination.h:69
Destination & operator=(Destination &&)=default
Destination & operator=(const Destination &)=default
const std::string & server_uuid() const
Get server UUID.
Definition: destination.h:76
const routing_guidelines::Server_info & get_server_info() const
Get server information.
Definition: destination.h:81
void set_route_name(std::string name)
Set name of the route that was used to reach this destination.
Definition: destination.h:99
Definition: destination.h:95
ServerMode
Definition: datatypes.h:50
Definition: gcs_xcom_synode.h:64
case opt name
Definition: sslopt-case.h:29
Definition: destination.h:64
std::string route_name
Definition: destination.h:66
std::optional< bool > connection_sharing_allowed
Definition: destination.h:65
Information about one server destination.
Definition: routing_guidelines.h:78
std::string uuid
@server_uuid of the server
Definition: routing_guidelines.h:83