在C ++ R3.0.2驱动程序中使用连接池连接到MongoDB副本集的正确方法是什么?
what's the correct way to connect to mongodb replica set with connection pool in c++ r3.0.2 driver?
我正在升级我的mongodb c++客户端代码从传统驱动程序和26compat驱动程序到r3.0.2驱动程序。scoped连接池类现在被删除了。我的问题是如何连接到副本集与连接池。我现在的代码是:
//only call it once in my app
mongocxx::instance inst{};
//call it in anywhere I need
mongocxx::client conn{mongocxx::uri{mongodb://i-e6ql0k8k,i-exiv5yox,i-sfdxzsjr/?replicaSet=rs1}};
使用默认的最大池大小100值。但我不知道我的方式是否正确?
您将需要使用mongocxx::pool类。URI看起来很好—只要您有replicaSet
选项,驱动程序就可以理解以复制集模式连接。
相关文章:
- 当套接字连接断开时检测C/C++Unix
- 用callgrind追踪不必要的副本
- 无法在windows上使用mingw将sqlite3与c连接
- 关于:C++中异常对象的范围:为什么我没有得到副本?
- 到连接组件算法的问题(递归)
- QTcpSocket在不阻塞GUI的情况下重新连接到服务器
- 在为LINUX创建共享库时,如何避免STL的私有/弱副本
- 无法在C++中建立与MySQL数据库的连接
- PC中的程序和PHONE中的本机描述应用程序之间的数据连接
- 在Qt Creator中,如何在连接到正在运行的进程后查看控制台输出
- 检查注册表项是否链接到(或副本)另一个注册表项
- 连接 dockerized 模型和 dockerized 数据库时出现"无法 SQLConnect"错误
- 使用 bfs 解决连接组件问题时得到错误的答案
- 在C++的两个字符串中连接以逗号分隔的唯一值
- 如何修复valgrind启动时的致命错误(与libc6-dbg和libc6-dbg:i386连接)
- C++应用程序 MySQL odbc 数据库连接错误:在引发"otl_tmpl_exception<>"实例后终止调用
- OSX蓝牙打开RFCOMMChannelAsync声称已连接,但未建立连接,并且从未调用过委托
- 在 libcurl 连接池中预创建连接
- MongoDB C++驱动程序处理副本集连接故障
- 在C ++ R3.0.2驱动程序中使用连接池连接到MongoDB副本集的正确方法是什么?