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