userver
C++ Async Framework
Loading...
Searching...
No Matches
client_settings.hpp
1
#
pragma
once
2
3
#
include
<
cstddef
>
4
#
include
<
optional
>
5
#
include
<
string
>
6
#
include
<
unordered_map
>
7
#
include
<
vector
>
8
9
#
include
<
userver
/
components
/
component_config
.
hpp
>
10
#
include
<
userver
/
crypto
/
certificate
.
hpp
>
11
#
include
<
userver
/
crypto
/
private_key
.
hpp
>
12
#
include
<
userver
/
formats
/
json_fwd
.
hpp
>
13
14
USERVER_NAMESPACE_BEGIN
15
16
namespace
urabbitmq {
17
18
struct
EndpointInfo
final
{
19
/// RabbitMQ node address (either FQDN or ip)
20
std::string
host
=
"localhost"
;
21
22
/// Port to connect to
23
uint16_t
port
= 5672;
24
};
25
26
struct
ClientCertSettings
{
27
crypto
::
Certificate
cert;
28
crypto
::
PrivateKey
key;
29
};
30
31
struct
TlsSettings
{
32
std::optional<
ClientCertSettings
> client_cert_settings;
33
std::vector<crypto::Certificate> ca_certs;
34
bool
verify_host =
true
;
35
};
36
37
struct
AuthSettings
final
{
38
/// Login to use
39
std::string
login
=
"guest"
;
40
41
/// Password to use
42
std::string
password
=
"guest"
;
43
44
/// RabbitMQs vhost
45
std::string
vhost
=
"/"
;
46
47
/// TLS
48
std::optional<
TlsSettings
>
tls_settings
;
49
};
50
51
struct
RabbitEndpoints
final
{
52
/// Auth settings
53
AuthSettings
auth
{};
54
55
/// Endpoints to connect to
56
std
::
vector
<
EndpointInfo
>
endpoints
{};
57
};
58
59
struct
PoolSettings
final
{
60
/// Library will try to maintain at least this amount of connections.
61
/// Note that every consumer takes a connection for himself and this limit
62
/// doesn't account that
63
size_t
min_pool_size
= 5;
64
65
/// Library will maintain at most this amount of connections.
66
/// Note that every consumer takes a connection for himself and this limit
67
/// doesn't account that
68
size_t
max_pool_size
= 10;
69
70
/// A per-connection limit for concurrent requests waiting
71
/// for response from the broker.
72
/// Note: increasing this allows one to potentially increase throughput,
73
/// but in case of a connection-wide error
74
/// (tcp error/protocol error/write timeout) leads to a errors burst:
75
/// all outstanding request will fails at once
76
size_t
max_in_flight_requests
= 5;
77
};
78
79
class
TestsHelper;
80
struct
ClientSettings
final
{
81
/// Per-host connections pool settings
82
PoolSettings
pool_settings
{};
83
84
/// Endpoints settings
85
RabbitEndpoints
endpoints
{};
86
87
/// Whether to use TLS for connections
88
bool
use_secure_connection
=
true
;
89
90
ClientSettings(
const
components
::ComponentConfig& config,
const
RabbitEndpoints& rabbit_endpoints);
91
92
private
:
93
friend
class
TestsHelper;
94
ClientSettings();
95
};
96
97
class
RabbitEndpointsMulti
final
{
98
public
:
99
RabbitEndpointsMulti(
const
formats
::
json
::Value& doc);
100
101
const
RabbitEndpoints& Get(
const
std::string& name)
const
;
102
103
private
:
104
std::unordered_map<std::string, RabbitEndpoints> endpoints_;
105
};
106
107
}
// namespace urabbitmq
108
109
USERVER_NAMESPACE_END
userver
urabbitmq
client_settings.hpp
Generated on Wed Dec 4 2024 18:49:13 for userver by
Doxygen
1.10.0