|
Covalent Bond
0.0.1-alpha
'covalent bond' is a data middle office. As a 2022-2023 Fall SWE final project.
|
Go to the documentation of this file.
12 #ifndef __SERVER_CB_VIRTUAL_DEVICE_HPP_
13 #define __SERVER_CB_VIRTUAL_DEVICE_HPP_
21 #if defined(__unix__) && defined(__clang__)
25 #include "../../pch.hpp"
27 #include <workflow/MySQLResult.h>
28 #include <workflow/WFMySQLConnection.h>
29 #include <workflow/WFRedisServer.h>
30 #include <workflow/WFTaskFactory.h>
49 cbVirtualDevice(
const std::string& _port,
const std::string& _host,
const std::string& _userName,
50 const std::string& _passWord,
const std::string& _charSet,
81 const std::string& _userName,
const std::string& _passWord,
82 const std::string& _charSet,
const std::string& _dataBaseName);
101 cbMySqlDevice(int32_t _idx,
const std::string& _port,
const std::string& _host,
102 const std::string& _userName,
const std::string& _passWord,
103 const std::string& _dataBaseName,
const std::string& _charSet =
"")
104 :
cbVirtualDevice(_port, _host, _userName, _passWord, _charSet, _dataBaseName,
107 m_conn =
new WFMySQLConnection(_idx);
111 std::stringstream ss;
112 ss <<
"mysql://" << _userName <<
":" << _passWord <<
"@" << _host <<
":" << _port <<
"/"
114 if (!_charSet.empty()) {
115 ss <<
"?character_set=" << _charSet <<
"&character_set_results=" << _charSet;
144 std::vector<WFMySQLTask*>
sequentialQuery(const std::vector<std::
string>& q,
152 static
void execMain(WFMySQLTask* t);
160 static
void execMain(const std::vector<WFMySQLTask*>& t);
181 cbRedisDevice(int32_t idx,
const std::string& _port,
const std::string& _host,
182 const std::string& _userName,
const std::string& _passWord, int32_t dbnum,
204 WFRedisTask* set(const std::vector<std::
string>& params,
205 const
redis_callback& callback_func =
nullptr,
void* usrData =
nullptr,
206 int32_t retryTimes = 3);
217 WFRedisTask* get(const std::vector<std::
string>& params,
218 const
redis_callback& callback_func =
nullptr,
void* usrData =
nullptr,
219 int32_t retryTimes = 3);
230 WFRedisTask* exists(const std::vector<std::
string>& params,
231 const
redis_callback& callback_func =
nullptr,
void* usrData =
nullptr,
232 int32_t retryTimes = 3);
240 static
void execMain(WFRedisTask* task);
243 bool m_isSSL = false;
267 for (
auto& item : m_mySqlPool) {
268 if (item.second.second) {
delete item.second.first; }
270 for (
auto& item : m_redisPool) {
271 if (item.second.second) {
delete item.second.first; }
273 for (
auto& item : m_kafkaPool) {
274 if (item.second.second) {
delete item.second.first; }
282 void removeMySqlDevice(int32_t idx);
283 void removeRedisDevice(int32_t idx);
284 void removeKafkaDevice(int32_t idx);
302 #endif //! __SERVER_CB_VIRTUAL_DEVICE_HPP_
std::function< void(WFMySQLTask *)> mysql_callback
_WIN32
~cbVirtualDeviceManager()
cbVirtualDevice()=default
cbMySqlDevice(int32_t _idx, const std::string &_port, const std::string &_host, const std::string &_userName, const std::string &_passWord, const std::string &_dataBaseName, const std::string &_charSet="")
std::map< int32_t, std::pair< cbKafkaDevice *, bool > > m_kafkaPool
! index, {pointer, visibility}
virtual void updateUrl()=0
static int32_t m_numsKafka
virtualDeviceType deviceType
std::function< void(WFRedisTask *)> redis_callback
std::map< int32_t, std::pair< cbMySqlDevice *, bool > > m_mySqlPool
WFMySQLConnection * m_conn
cbVirtualDevice(const std::string &_port, const std::string &_host, const std::string &_userName, const std::string &_passWord, const std::string &_charSet, const std::string _dataBaseName, const virtualDeviceType &v)
void updateUrl() override final
cbRedisDevice(int32_t idx, const std::string &_port, const std::string &_host, const std::string &_userName, const std::string &_passWord, int32_t dbnum, bool isSsl=false)
static void execMain(WFMySQLTask *t)
User should not use this function. All task should be added to graph node in order to execute all tas...
cbMySqlDevice(int32_t _idx)
cbRedisDevice(int32_t idx)
void reloadConnection(const std::string &_port, const std::string &_host, const std::string &_userName, const std::string &_passWord, const std::string &_charSet, const std::string &_dataBaseName)
std::vector< WFMySQLTask * > sequentialQuery(const std::vector< std::string > &q, const std::vector< mysql_callback > &callback_func)
int32_t getIdx()
Get the Idx object.
static int32_t m_numsRedis
std::map< int32_t, std::pair< cbRedisDevice *, bool > > m_redisPool
! index, {pointer, visibility}
WFMySQLTask * query(const std::string &q, const mysql_callback &callback_func=nullptr)
static int32_t m_numsMySql