userver
C++ Async Framework
Loading...
Searching...
No Matches
dsn.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/postgres/dsn.hpp
4
/// @brief DSN manipulation helpers
5
6
#
include
<
string
>
7
#
include
<
vector
>
8
9
#
include
<
userver
/
clients
/
dns
/
resolver_fwd
.
hpp
>
10
#
include
<
userver
/
engine
/
deadline
.
hpp
>
11
#
include
<
userver
/
utils
/
strong_typedef
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
storages
::
postgres
{
16
17
using
Dsn
= USERVER_NAMESPACE::
utils
::
NonLoggable
<
class
DsnTag,
std
::
string
>;
18
using
DsnList
=
std
::
vector
<
Dsn
>;
19
20
DsnList SplitByHost(
const
Dsn& dsn);
21
22
/// Create a string `<user>@<host>:<port>/<dbname>` of a single-host DSN
23
/// or escape all the punctuation with _ for test
24
std::string
MakeDsnNick
(
const
Dsn& dsn,
bool
escape);
25
26
struct
DsnOptions
{
27
std::string host;
28
std::string port;
29
std::string dbname;
30
};
31
32
/// Read options from a DSN
33
/// First unique option is used if found, otherwise default is taken
34
DsnOptions
OptionsFromDsn
(
const
Dsn& dsn);
35
36
/// Return `<host>[:<port>]` string for a single-host DSN
37
std::string
GetHostPort
(
const
Dsn& dsn);
38
39
/// Return DSN string without 'password' field
40
std::string
DsnCutPassword
(
const
Dsn& dsn);
41
/// Return DSN string with password contents masked
42
std::string
DsnMaskPassword
(
const
Dsn& dsn);
43
44
std::string EscapeHostName(
const
std::string& hostname,
char
escape_char =
'_'
);
45
46
/// Return DSN string with hosts resolved as hostaddr values
47
/// If given DSN has no host or already contains hostaddr, does nothing
48
Dsn
ResolveDsnHostaddrs
(
const
Dsn
&
dsn
,
clients
::
dns
::
Resolver
&
resolver
,
49
engine
::
Deadline
deadline
);
50
51
}
// namespace storages::postgres
52
53
USERVER_NAMESPACE_END
userver
storages
postgres
dsn.hpp
Generated on Wed May 15 2024 22:28:41 for userver by
Doxygen
1.10.0