[英]pymongo: Advantage of using MongoReplicaSetClient?
It seems that both MongoClient and MongoReplicaSetClient can connect to mongo replica sets. 似乎MongoClient和MongoReplicaSetClient都可以连接到mongo副本集。 In fact, their documentation pages are nearly identical - same options, same methods, etc - except that the latter's constructor requires me to specify a replicaSet.
实际上,他们的文档页面几乎相同 - 相同的选项,相同的方法等 - 除了后者的构造函数要求我指定replicaSet。
In both cases, we may specify a read preference. 在这两种情况下,我们都可以指定读取首选项。 In both cases, we must handle the AutoReconnect exception if a stepdown occurs.
在这两种情况下,如果发生降级,我们必须处理AutoReconnect异常。
So my questions are: 所以我的问题是:
Why would one use one versus the other, since one can perform the exact same operations with both? 为什么一个人使用一个而不是另一个,因为一个人可以执行完全相同的操作?
Both can perform secondary reads, correct? 两者都可以执行二次读取,对吗? The documentation says that the advantage of a ReplicaSetClient is that we can do secondary reads, but clearly they are supported in both.
文档说ReplicaSetClient的优点是我们可以进行二次读取,但显然它们都受支持。
The documentation says that the ReplicaSetClient features "replica set health monitoring." 文档说ReplicaSetClient具有“副本集健康监控”功能。 What exactly does that mean?
这到底是什么意思呢? Are there new methods I can invoke which tell me about a replset's health that I cannot otherwise do with MongoClient?
是否有我可以调用的新方法告诉我有关我不能用MongoClient做的replset的健康状况?
In theory a MongoReplicaSetClient will connect to all members of the replset, rather than just one. 理论上 ,MongoReplicaSetClient将连接到replset的所有成员,而不仅仅是一个。 This is false: you may munge or omit any of the servers in the connection string, and both MongoClient and MongoReplicaSetClient are still able to connect.
这是错误的:您可能会删除连接字符串中的任何服务器,MongoClient和MongoReplicaSetClient仍然可以连接。 Am I missing something?
我错过了什么吗?
This is was a confusing API choice that we regret in PyMongo 2.x. 这是一个令人困惑的API选择,我们在PyMongo 2.x中感到遗憾。 We will merge all the client classes into MongoClient in PyMongo 3, in April 2015:
我们将在2015年4月将所有客户端类合并到PyMongo 3中的MongoClient:
http://emptysqua.re/blog/good-idea-at-the-time-pymongo-mongoreplicasetclient/ http://emptysqua.re/blog/good-idea-at-the-time-pymongo-mongoreplicasetclient/
Meanwhile: 与此同时:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.