8 #include <common/datatypes/DataSet.h>
10 #include "nebula/client/Connection.h"
19 using ExecuteJsonCallback = std::function<void(std::string &&)>;
25 const std::string &username,
26 const std::string &password,
27 const std::string &timezoneName,
29 : sessionId_(sessionId),
30 conn_(std::move(conn)),
34 timezoneName_(timezoneName),
35 offsetSecs_(offsetSecs) {}
38 : sessionId_(session.sessionId_),
39 conn_(std::move(session.conn_)),
41 username_(std::move(session.username_)),
42 password_(std::move(session.password_)),
43 timezoneName_(std::move(session.timezoneName_)),
44 offsetSecs_(session.offsetSecs_) {
45 session.sessionId_ = -1;
46 session.pool_ =
nullptr;
47 session.offsetSecs_ = 0;
49 void operator=(
Session &&session) {
50 sessionId_ = session.sessionId_;
51 username_ = std::move(session.username_);
52 password_ = std::move(session.password_);
53 timezoneName_ = std::move(session.timezoneName_);
54 offsetSecs_ = session.offsetSecs_;
55 session.sessionId_ = -1;
56 session.pool_ =
nullptr;
57 session.offsetSecs_ = 0;
65 void asyncExecute(
const std::string &stmt, ExecuteCallback cb);
68 const std::unordered_map<std::string, Value> ¶meters);
70 void asyncExecuteWithParameter(
const std::string &stmt,
71 const std::unordered_map<std::string, Value> ¶meters,
74 std::string executeJson(
const std::string &stmt);
76 void asyncExecuteJson(
const std::string &stmt, ExecuteJsonCallback cb);
78 std::string executeJsonWithParameter(
const std::string &stmt,
79 const std::unordered_map<std::string, Value> ¶meters);
81 void asyncExecuteJsonWithParameter(
const std::string &stmt,
82 const std::unordered_map<std::string, Value> ¶meters,
83 ExecuteJsonCallback cb);
87 ErrorCode retryConnect();
92 return sessionId_ > 0;
95 const std::string &timeZoneName()
const {
99 int32_t timeZoneOffsetSecs()
const {
105 return toLocal(data, offsetSecs_);
109 static void toLocal(
DataSet &data, int32_t offsetSecs);
112 int64_t sessionId_{-1};
115 std::string username_;
116 std::string password_;
118 std::string timezoneName_;