MySQL 26.7.0
Source Code Documentation
classic_connect.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 2026, 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 ROUTING_SRC_PROCESSORS_SESSION_CLASSIC_CONNECT_H_
27#define ROUTING_SRC_PROCESSORS_SESSION_CLASSIC_CONNECT_H_
28
29#include <chrono>
31#include "destination.h" // DestinationManager
38
40 public:
43 std::function<void(const classic_protocol::message::server::Error &err)>
44 on_error,
45 TraceEvent *parent_event)
46 : Processor(conn),
47 io_ctx_{conn->client_conn().connection()->io_ctx()},
48 on_error_(std::move(on_error)),
49 parent_event_(parent_event) {}
50
52
53 enum class Stage {
55 Resolve,
61 Connect,
64
65 Error,
66 Done,
67 };
68
70
72 [[nodiscard]] Stage stage() const { return stage_; }
73
74 std::optional<std::string_view> diagnostic_stage_name() const override;
75
76 bool is_destination_good(const mysql_harness::Destination &dest) const;
77
78 private:
90
93
95
97
100
101 std::unique_ptr<Destination> destination_{nullptr};
102
103 std::vector<mysql_harness::DestinationEndpoint> endpoints_;
104 std::vector<mysql_harness::DestinationEndpoint>::iterator endpoints_it_;
105
106 bool all_quarantined_{false};
107 std::error_code destination_ec_;
108
109 // stack of errors.
110 std::vector<std::pair<std::string, std::error_code>> connect_errors_;
111
112 std::function<void(const classic_protocol::message::server::Error &err)>
114
115 std::chrono::steady_clock::time_point connect_started_;
116
121};
122
123#endif // ROUTING_SRC_PROCESSORS_SESSION_CLASSIC_CONNECT_H_
const MysqlRoutingClassicConnectionBase * connection() const
Definition: processor.h:82
Definition: classic_connect.h:39
stdx::expected< Processor::Result, std::error_code > init_endpoint()
Definition: classic_connect.cc:314
std::chrono::steady_clock::time_point connect_started_
Definition: classic_connect.h:115
std::optional< std::string_view > diagnostic_stage_name() const override
stage name of a staged processor.
Definition: classic_connect.cc:1127
stdx::expected< Processor::Result, std::error_code > error()
Definition: classic_connect.cc:1059
Stage
Definition: classic_connect.h:53
stdx::expected< Processor::Result, std::error_code > connect_finish()
Definition: classic_connect.cc:797
TraceEvent * trace_event_socket_from_pool_
Definition: classic_connect.h:120
mysql_harness::DestinationEndpoint server_endpoint_
Definition: classic_connect.h:99
std::unique_ptr< Destination > destination_
Definition: classic_connect.h:101
bool is_destination_good(const mysql_harness::Destination &dest) const
Definition: classic_connect.cc:928
stdx::expected< Processor::Result, std::error_code > init_destination()
Definition: classic_connect.cc:129
stdx::expected< Processor::Result, std::error_code > resolve()
Definition: classic_connect.cc:217
TraceEvent * trace_event_connect_
Definition: classic_connect.h:118
std::function< void(const classic_protocol::message::server::Error &err)> on_error_
Definition: classic_connect.h:113
stdx::expected< Processor::Result, std::error_code > from_pool()
Definition: classic_connect.cc:392
std::vector< mysql_harness::DestinationEndpoint >::iterator endpoints_it_
Definition: classic_connect.h:104
Stage stage_
Definition: classic_connect.h:94
std::vector< mysql_harness::DestinationEndpoint > endpoints_
Definition: classic_connect.h:103
bool all_quarantined_
Definition: classic_connect.h:106
void stage(Stage stage)
Definition: classic_connect.h:71
ConnectProcessor(MysqlRoutingClassicConnectionBase *conn, std::function< void(const classic_protocol::message::server::Error &err)> on_error, TraceEvent *parent_event)
Definition: classic_connect.h:41
std::vector< std::pair< std::string, std::error_code > > connect_errors_
Definition: classic_connect.h:110
stdx::expected< Processor::Result, std::error_code > connected()
Definition: classic_connect.cc:1020
net::io_context & io_ctx_
Definition: classic_connect.h:96
stdx::expected< Processor::Result, std::error_code > init_connect()
Definition: classic_connect.cc:324
TraceEvent * parent_event_
Definition: classic_connect.h:117
Stage stage() const
Definition: classic_connect.h:72
stdx::expected< Processor::Result, std::error_code > next_destination()
Definition: classic_connect.cc:946
stdx::expected< Processor::Result, std::error_code > process() override
Definition: classic_connect.cc:55
TraceEvent * trace_event_socket_connect_
Definition: classic_connect.h:119
std::error_code destination_ec_
Definition: classic_connect.h:107
net::ip::tcp::resolver resolver_
Definition: classic_connect.h:98
void assign_server_side_connection_after_pool(ConnectionPool::ServerSideConnection server_conn)
Definition: classic_connect.cc:361
stdx::expected< Processor::Result, std::error_code > next_endpoint()
Definition: classic_connect.cc:885
stdx::expected< Processor::Result, std::error_code > connect()
Definition: classic_connect.cc:581
Definition: classic_connection_base.h:57
a processor base class with helper functions.
Definition: processor.h:109
Definition: destination_endpoint.h:38
Definition: destination.h:95
Definition: io_context.h:61
Definition: internet.h:608
TCP protocol.
Definition: internet.h:1155
Definition: expected.h:286
borrowable::message::server::Error< false > Error
Definition: classic_protocol_message.h:1411
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:943
Define std::hash<Gtid>.
Definition: gtid.h:355
Definition: trace_span.h:35