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
36
#include "
http/base/connection_interface.h
"
37
#include "
http/base/method.h
"
38
#include "
http/client/request.h
"
39
#include "
mysql/harness/net_ts/internet.h
"
40
#include "
mysql/harness/tls_client_context.h
"
41
42
#include "
mysqlrouter/http_client_export.h
"
43
44
namespace
http
{
45
namespace
client {
46
47
class
HTTP_CLIENT_EXPORT
Client
{
48
public
:
49
using
io_context
=
net::io_context
;
50
using
HttpMethodType
=
http::base::method::key_type
;
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
73
~Client
();
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
:
84
class
CallbacksPrivateImpl
;
85
bool
is_connected_{
false
};
86
std::error_code
error_code_
;
87
Endpoint
connected_endpoint_
;
88
io_context
&
io_context_
;
89
TlsClientContext
tls_context_
;
90
std::unique_ptr<http::base::ConnectionInterface>
connection_
;
91
std::unique_ptr<CallbacksPrivateImpl>
callbacks_
;
92
Request
*fill_request_by_callback_{
nullptr
};
93
Statistics
statistics_
;
94
};
95
96
}
// namespace client
97
}
// namespace http
98
99
#endif
// ROUTER_SRC_HTTP_INCLUDE_HTTP_CLIENT_CLIENT_H_
TlsClientContext
Client TLS Context.
Definition:
tls_client_context.h:43
http::client::Client::CallbacksPrivateImpl
Definition:
client.cc:171
http::client::Client
Definition:
client.h:47
http::client::Client::connected_endpoint_
Endpoint connected_endpoint_
Definition:
client.h:87
http::client::Client::error_code_
std::error_code error_code_
Definition:
client.h:86
http::client::Client::HttpMethodType
http::base::method::key_type HttpMethodType
Definition:
client.h:50
http::client::Client::tls_context_
TlsClientContext tls_context_
Definition:
client.h:89
http::client::Client::connection_
std::unique_ptr< http::base::ConnectionInterface > connection_
Definition:
client.h:90
http::client::Client::statistics_
Statistics statistics_
Definition:
client.h:93
http::client::Client::callbacks_
std::unique_ptr< CallbacksPrivateImpl > callbacks_
Definition:
client.h:91
http::client::Client::~Client
~Client()
http::client::Client::io_context_
io_context & io_context_
Definition:
client.h:88
http::client::Request
Definition:
request.h:39
net::io_context
Definition:
io_context.h:61
connection_interface.h
http_client_export.h
HTTP_CLIENT_EXPORT
#define HTTP_CLIENT_EXPORT
Definition:
http_client_export.h:15
request.h
internet.h
method.h
my_inttypes.h
Some integer typedefs for easier portability.
connected
static bool connected
Definition:
mysql.cc:169
host
const char * host
Definition:
mysqladmin.cc:65
http::base::method::key_type
int key_type
Definition:
method.h:38
http
Definition:
connection.h:56
port
required uint64 port
Definition:
replication_asynchronous_connection_failover.proto:33
http::client::Client::Endpoint
Definition:
client.h:51
http::client::Client::Endpoint::port
uint16_t port
Definition:
client.h:53
http::client::Client::Endpoint::host
std::string host
Definition:
client.h:54
http::client::Client::Endpoint::operator==
bool operator==(const Endpoint &other) const
Definition:
client.h:55
http::client::Client::Endpoint::is_tls
bool is_tls
Definition:
client.h:52
http::client::Client::Statistics
Definition:
client.h:63
tls_client_context.h
router
src
http
include
http
client
client.h
Generated by
1.9.2