#ifndef DATABASE_SERVICE_HPP #define DATABASE_SERVICE_HPP #include #include #include #include #include #include #include class DatabaseService { public: static DatabaseService& getInstance(boost::asio::io_context& io_context, std::size_t pool_size); void asyncSetKey(const std::string& key, const std::string& value, std::function callback); void asyncGetKey(const std::string& key, std::function callback); //we could use a varient here for the result private: DatabaseService(boost::asio::io_context& io_context, std::size_t pool_size = 4); ~DatabaseService(); DatabaseService(DatabaseService const&); void operator=(DatabaseService const&); std::shared_ptr getConnection(); boost::asio::io_context& io_context_; std::size_t pool_size_; std::vector> connection_pool_; std::size_t current_index_ = 0; //index used for round robin selection static DatabaseService* INSTANCE; static std::mutex singleton_mutex; }; #endif