7 #include <common/datatypes/DataSet.h>
13 #include "nebula/client/Config.h"
14 #include "nebula/client/ConnectionPool.h"
15 #include "nebula/client/Session.h"
20 std::string username_;
21 std::string password_;
22 std::vector<std::string> addrs_;
23 std::string spaceName_;
25 std::uint32_t timeout_{0};
29 std::uint32_t idleTime_{0};
30 std::uint32_t maxSize_{10};
32 std::uint32_t minSize_{1};
42 : config_(std::move(pool.config_)), pool_(std::move(pool.pool_)) {}
54 const std::unordered_map<std::string, Value> ¶meters);
56 std::string executeJson(
const std::string &stmt);
58 std::string executeJsonWithParameter(
const std::string &stmt,
59 const std::unordered_map<std::string, Value> ¶meters);
62 std::pair<Session, bool> getIdleSession() {
63 std::lock_guard<std::mutex> l(m_);
64 if (idleSessions_.empty()) {
65 return std::make_pair(
Session(),
false);
67 auto session = std::move(idleSessions_.front());
68 idleSessions_.pop_front();
69 return std::make_pair(std::move(session),
true);
72 void giveBack(
Session &&session) {
73 std::lock_guard<std::mutex> l(m_);
74 idleSessions_.emplace_back(std::move(session));
78 std::unique_ptr<ConnectionPool> pool_;
81 std::list<Session> idleSessions_;