Go to the documentation of this file.
8 #ifndef FCF_DEVMGR_COMMON_DB_INTERFACE_HPP_
9 #define FCF_DEVMGR_COMMON_DB_INTERFACE_HPP_
14 #pragma GCC diagnostic push
15 #pragma GCC diagnostic ignored "-Wpedantic"
17 #include <sw/redis++/redis++.h>
19 #pragma GCC diagnostic pop
22 #include <utils/bat/dbInterface.hpp>
23 #include <utils/bat/logger.hpp>
50 const std::string& db_endpoint,
51 const timeval& db_timeout);
55 const std::string& state,
56 const std::string& substate);
57 void BatchSet(
const utils::bat::DbVector& vec);
59 void Set(
const std::string& key,
67 std::string m_db_endpoint;
69 bool m_connected{
false};
70 std::unique_ptr<::sw::redis::Redis> m_runtime_db;
72 log4cplus::Logger m_logger;
77 std::ostringstream os;
81 LOG4CPLUS_DEBUG(m_logger, fmt::format(
"Writing attribute <{}> ...", m_prefix+key));
82 m_runtime_db->set(m_prefix+key, os.str());
83 LOG4CPLUS_DEBUG(m_logger, fmt::format(
"Writing attribute <{}> finished !", key));
84 }
catch (const ::sw::redis::Error& err) {
85 LOG4CPLUS_ERROR(m_logger, fmt::format(
"Problems writing attribute <{}>: <> !",
87 throw std::runtime_error (fmt::format(
"Problems writing attribute <{}>: <> !", key,
94 #endif // FCF_DEVMGR_COMMON_DB_INTERFACE_HPP_
const int64_t REDIS_WAIT_TIMEOUT_MS
Definition: dbInterface.hpp:33
const std::size_t REDIS_CONNECTION_POOL_SIZE
Definition: dbInterface.hpp:29
const int64_t REDIS_CONNECTION_POOL_CONN_LIFETIME_MS
Definition: dbInterface.hpp:31
void SetStates(const std::string &prefix, const std::string &state, const std::string &substate)
Definition: dbInterface.cpp:75
Definition: actionMgr.cpp:29
Definition: dbInterface.hpp:42
bool IsConnected() const
Definition: dbInterface.hpp:53
DbInterface(const DbInterface &)=delete
Disable copy constructor.
const int64_t REDIS_SOCKET_TIMEOUT_MS
Definition: dbInterface.hpp:37
void Set(const std::string &key, const T &value)
Definition: dbInterface.hpp:76
void BatchSet(const utils::bat::DbVector &vec)
Definition: dbInterface.cpp:93
DbInterface(const std::string &prefix, const std::string &db_endpoint, const timeval &db_timeout)
Definition: dbInterface.cpp:24
DbInterface & operator=(const DbInterface &)=delete
Disable assignment operator.