MySQL 8.4.2
Source Code Documentation
client.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 ROUTER_SRC_HTTP_INCLUDE_HTTP_CLIENT_CLIENT_H_
27#define ROUTER_SRC_HTTP_INCLUDE_HTTP_CLIENT_CLIENT_H_
28
29#include <list>
30#include <memory>
31#include <string>
32#include <system_error>
33
34#include "my_inttypes.h" // NOLINT(build/include_subdir)
35
37#include "http/base/method.h"
38#include "http/client/request.h"
41
43
44namespace http {
45namespace client {
46
48 public:
51 struct Endpoint {
52 bool is_tls;
53 uint16_t port;
54 std::string host;
55 bool operator==(const Endpoint &other) const {
56 if (other.is_tls != is_tls) return false;
57 if (other.port != port) return false;
58
59 return (other.host == host);
60 }
61 };
62
63 struct Statistics {
64 uint64_t connected{0};
65 uint64_t reused{0};
66 uint64_t connected_tls{0};
67 };
68
69 public:
70 Client(io_context &io_context, TlsClientContext &&tls_context);
71 explicit Client(io_context &io_context);
72
74
75 void async_send_request(Request *request);
76 void send_request(Request *request);
77
78 operator bool() const;
79 int error_code() const;
80 std::string error_message() const;
81 const Statistics &statistics() const;
82
83 private:
85 bool is_connected_{false};
86 std::error_code error_code_;
90 std::unique_ptr<http::base::ConnectionInterface> connection_;
91 std::unique_ptr<CallbacksPrivateImpl> callbacks_;
92 Request *fill_request_by_callback_{nullptr};
94};
95
96} // namespace client
97} // namespace http
98
99#endif // ROUTER_SRC_HTTP_INCLUDE_HTTP_CLIENT_CLIENT_H_
Client TLS Context.
Definition: tls_client_context.h:43
Definition: client.h:47
Endpoint connected_endpoint_
Definition: client.h:87
std::error_code error_code_
Definition: client.h:86
http::base::method::key_type HttpMethodType
Definition: client.h:50
TlsClientContext tls_context_
Definition: client.h:89
std::unique_ptr< http::base::ConnectionInterface > connection_
Definition: client.h:90
Statistics statistics_
Definition: client.h:93
std::unique_ptr< CallbacksPrivateImpl > callbacks_
Definition: client.h:91
io_context & io_context_
Definition: client.h:88
Definition: request.h:39
Definition: io_context.h:61
#define HTTP_CLIENT_EXPORT
Definition: http_client_export.h:15
Some integer typedefs for easier portability.
static bool connected
Definition: mysql.cc:169
const char * host
Definition: mysqladmin.cc:65
int key_type
Definition: method.h:38
Definition: connection.h:56
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
Definition: client.h:51
uint16_t port
Definition: client.h:53
std::string host
Definition: client.h:54
bool operator==(const Endpoint &other) const
Definition: client.h:55
bool is_tls
Definition: client.h:52
Definition: client.h:63