/** * @file mix_cc/ihyper_db/connection.h * @brief ihyperDB的连接库 * @author Cat (null.null.null@qq.com) * @version 0.1 * @date 2020-12-12 * * Copyright: Baosight Co. Ltd. * DO NOT COPY/USE WITHOUT PERMISSION * */ #pragma once #include "mix_cc/fp.h" #include "mix_cc/ihyper_db/utility.h" #include "mix_cc/type/mix_time.h" #include #include #include #include #include #include #include #include namespace mix_cc { namespace ihd { /** * @brief IhyperDB的连接 */ struct Connection { // 由于iHyperDB的设计独特,一个进程只使用一个iHyperDB连接 // 且ihyperDB的连接一经建立,即使断开网络连接,也不会自动释放,故不再对其使用手动释放 struct Config { // 基本信息 std::string username; std::string password; HD3Connection hd3_conn; }; enum class State { disconnected, connected }; Config config; State state; std::thread::id tid; }; auto read_conn_config_maybe() -> maybe; auto init_conn_maybe(maybe&& conn_config_maybe) -> maybe; auto disconnect_maybe(maybe conn_maybe) -> maybe; auto connect_maybe(maybe conn_maybe) -> maybe; auto read_conn_state() -> Connection::State; auto read_conn() -> Connection; auto store_conn_to_local(Connection& conn) -> Connection; auto auto_connect() -> maybe; } // namespace ihd } // namespace mix_cc