MySQL 8.0.37
Source Code Documentation
forwarding_processor.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2023, 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 ROUTING_CLASSIC_FORWARDING_PROCESSOR_INCLUDED
27#define ROUTING_CLASSIC_FORWARDING_PROCESSOR_INCLUDED
28
29#include "processor.h"
30
31/**
32 * a processor base class with helper functions.
33 */
35 public:
36 using Processor::Processor;
37
38 protected:
39 /**
40 * forward the current packet from the server-side to the client-side.
41 *
42 * use 'noflush' if the next message is from the server side too to allow
43 * merging of multiple server-side packets into one "send-to-client".
44 *
45 * Useful for resultsets which is split into multiple packets.
46 *
47 * Pushes a ServerToClientForwarder to the processor-stack.
48 *
49 * @param noflush if true, it isn't required to wait until the packet is sent
50 * to the client.
51 */
53 bool noflush = false);
54
55 /**
56 * forward the current packet from the client-side to the server-side.
57 *
58 * Pushes a ClientToServerForwarder to the processor-stack.
59 *
60 * @param noflush if true, it isn't required to wait until the packet is sent
61 * to the server.
62 */
64 bool noflush = false);
65
66 /**
67 * move the server connection to the pool.
68 */
70
71 /**
72 * reconnect a socket.
73 *
74 * pushes a ConnectProcessor on the processor stack.
75 *
76 * when finished, a socket is established.
77 *
78 * @retval Result::Again on success.
79 */
81
82 /**
83 * reconnect a mysql classic connection.
84 *
85 * pushes a LazyConnector on the processor stack.
86 *
87 * when finished, a mysql connection is authenticated.
88 */
90
91 /**
92 * handle error-code of a failed receive() from the server-socket and check
93 * the status of the client socket.
94 */
97
98 /**
99 * send a Error msg based on the reconnect_error().
100 *
101 * @retval Result::SendToClient on success.
102 */
104 Channel *src_channel, ClassicProtocolState *src_protocol);
105
106 /**
107 * set the reconnect error.
108 *
109 * may be called from handlers.
110 */
112 reconnect_error_ = std::move(err);
113 }
114
115 /**
116 * get the reconnect error.
117 */
119 return reconnect_error_;
120 }
121
122 private:
123 /**
124 * reconnect error set by lazy_reconnect_start().
125 */
127};
128
129#endif
SSL aware socket buffers.
Definition: channel.h:64
protocol state of a classic protocol connection.
Definition: classic_connection_base.h:52
a processor base class with helper functions.
Definition: forwarding_processor.h:34
void reconnect_error(classic_protocol::message::server::Error err)
set the reconnect error.
Definition: forwarding_processor.h:111
classic_protocol::message::server::Error reconnect_error() const
get the reconnect error.
Definition: forwarding_processor.h:118
stdx::expected< Processor::Result, std::error_code > mysql_reconnect_start()
reconnect a mysql classic connection.
Definition: forwarding_processor.cc:125
stdx::expected< Processor::Result, std::error_code > socket_reconnect_start()
reconnect a socket.
Definition: forwarding_processor.cc:115
stdx::expected< bool, std::error_code > pool_server_connection()
move the server connection to the pool.
Definition: forwarding_processor.cc:82
stdx::expected< Result, std::error_code > forward_client_to_server(bool noflush=false)
forward the current packet from the client-side to the server-side.
Definition: forwarding_processor.cc:48
stdx::expected< Processor::Result, std::error_code > reconnect_send_error_msg(Channel *src_channel, ClassicProtocolState *src_protocol)
send a Error msg based on the reconnect_error().
Definition: forwarding_processor.cc:164
classic_protocol::message::server::Error reconnect_error_
reconnect error set by lazy_reconnect_start().
Definition: forwarding_processor.h:126
stdx::expected< Result, std::error_code > forward_server_to_client(bool noflush=false)
forward the current packet from the server-side to the client-side.
Definition: forwarding_processor.cc:40
stdx::expected< Result, std::error_code > recv_server_failed_and_check_client_socket(std::error_code ec)
handle error-code of a failed receive() from the server-socket and check the status of the client soc...
Definition: forwarding_processor.cc:136
a processor base class with helper functions.
Definition: processor.h:89
Definition: expected.h:944
borrowable::message::server::Error< false > Error
Definition: classic_protocol_message.h:1399
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:910