userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
pool.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <memory>
7
#include <string>
8
#include <vector>
9
10
#include <
userver/clients/dns/resolver_fwd.hpp
>
11
#include <
userver/dynamic_config/fwd.hpp
>
12
#include <
userver/formats/bson/value.hpp
>
13
#include <
userver/storages/mongo/collection.hpp
>
14
#include <
userver/storages/mongo/cursor.hpp
>
15
#include <
userver/storages/mongo/operations.hpp
>
16
#include <
userver/storages/mongo/pool_config.hpp
>
17
#include <
userver/storages/mongo/transaction.hpp
>
18
#include <
userver/utils/statistics/fwd.hpp
>
19
#include <
userver/utils/zstring_view.hpp
>
20
21
USERVER_NAMESPACE_BEGIN
22
23
namespace
storages::mongo
{
24
25
namespace
impl {
26
class
PoolImpl;
27
}
// namespace impl
28
40
class
Pool {
41
public
:
42
Pool(Pool&&)
noexcept
;
43
Pool& operator=(Pool&&)
noexcept
;
44
~Pool();
45
47
bool
HasCollection
(
utils::zstring_view
name)
const
;
48
50
Collection
GetCollection
(std::string name)
const
;
51
54
void
DropDatabase
();
55
57
std::vector<std::string>
ListCollectionNames
()
const
;
58
60
void
Ping
();
61
66
Transaction
BeginTransaction
()
const
;
67
79
template
<
typename
... Options>
80
Cursor
Aggregate
(
formats::bson::Value
pipeline, Options&&...
options
);
81
84
Cursor
Execute(
const
operations::Aggregate
&);
86
88
// For internal use only
89
Pool(
90
std::string
id
,
91
const
std::string& uri,
92
const
PoolConfig
& pool_config,
93
clients::dns::Resolver
* dns_resolver,
94
dynamic_config::Source
config_source
95
);
96
97
// Writes pool statistics
98
friend
void
DumpMetric(
utils::statistics::Writer
& writer,
const
Pool& pool);
99
100
friend
std::shared_ptr<impl::PoolImpl> GetPoolImpl(
const
Pool& pool) {
return
pool.impl_; }
101
102
// Sets new dynamic pool settings
103
void
SetPoolSettings(
const
PoolSettings
& pool_settings);
104
105
void
SetConnectionString(
const
std::string& connection_string);
107
108
private
:
109
std::shared_ptr<impl::PoolImpl> impl_;
110
};
111
112
using
PoolPtr = std::shared_ptr<Pool>;
113
114
template
<
typename
... Options>
115
Cursor
Pool::Aggregate
(
formats::bson::Value
pipeline, Options&&...
options
) {
116
operations::Aggregate
aggregate(std::move(pipeline));
117
(aggregate.SetOption(std::forward<Options>(
options
)), ...);
118
return
Execute(aggregate);
119
}
120
121
}
// namespace storages::mongo
122
123
USERVER_NAMESPACE_END
userver
storages
mongo
pool.hpp
Generated on
for userver by
Doxygen
1.17.0