From 4671f4a46bf9aca39f0a09d0bec115a7f8913614 Mon Sep 17 00:00:00 2001 From: neodarz Date: Thu, 8 Aug 2019 13:48:39 +0200 Subject: Implement mongocxx pool connection --- db/mongo_access.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 db/mongo_access.h (limited to 'db/mongo_access.h') diff --git a/db/mongo_access.h b/db/mongo_access.h new file mode 100644 index 0000000..f03cece --- /dev/null +++ b/db/mongo_access.h @@ -0,0 +1,43 @@ +#ifndef MongoAccess_H_ +#define MongoAccess_H_ + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + + +class mongo_access { + public: + + mongo_access (); + ~mongo_access (); + + void configure(mongocxx::uri uri); + + using connection = mongocxx::pool::entry; + + connection get_connection() { + return _pool->acquire(); + } + + bsoncxx::stdx::optional try_get_connection() { + return _pool->try_acquire(); + } + + private: + std::unique_ptr _instance = nullptr; + std::unique_ptr _pool = nullptr; + +}; + +#endif -- cgit v1.2.1