MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
destination_endpoint.h
Go to the documentation of this file.
1/*
2 Copyright (c) 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 MYSQL_HARNESS_DESTINATION_ENDPOINT_INCLUDED
27#define MYSQL_HARNESS_DESTINATION_ENDPOINT_INCLUDED
28
29#include "harness_export.h"
30
31#include <variant>
32
35
36namespace mysql_harness {
37
38class HARNESS_EXPORT DestinationEndpoint {
39 public:
42
43 explicit DestinationEndpoint() : ep_(TcpType()) {}
44 explicit DestinationEndpoint(TcpType ep) : ep_(std::move(ep)) {}
45 explicit DestinationEndpoint(LocalType ep) : ep_(std::move(ep)) {}
46
47 bool is_tcp() const { return std::holds_alternative<TcpType>(ep_); }
48 bool is_local() const { return !is_tcp(); }
49
50 TcpType &as_tcp() { return std::get<TcpType>(ep_); }
51 const TcpType &as_tcp() const { return std::get<TcpType>(ep_); }
52
53 LocalType &as_local() { return std::get<LocalType>(ep_); }
54 const LocalType &as_local() const { return std::get<LocalType>(ep_); }
55
56 std::string str() const;
57
58 private:
59 std::variant<TcpType, LocalType> ep_;
60};
61
62} // namespace mysql_harness
63
64#endif
local::basic_endpoint< stream_protocol > endpoint
Definition: local.h:303
Definition: destination_endpoint.h:38
DestinationEndpoint()
Definition: destination_endpoint.h:43
TcpType & as_tcp()
Definition: destination_endpoint.h:50
const TcpType & as_tcp() const
Definition: destination_endpoint.h:51
bool is_local() const
Definition: destination_endpoint.h:48
std::variant< TcpType, LocalType > ep_
Definition: destination_endpoint.h:59
DestinationEndpoint(TcpType ep)
Definition: destination_endpoint.h:44
LocalType & as_local()
Definition: destination_endpoint.h:53
DestinationEndpoint(LocalType ep)
Definition: destination_endpoint.h:45
bool is_tcp() const
Definition: destination_endpoint.h:47
const LocalType & as_local() const
Definition: destination_endpoint.h:54
Definition: internet.h:678
basic_endpoint< tcp > endpoint
Definition: internet.h:1157
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1117
Definition: common.h:44
Definition: gcs_xcom_synode.h:64