Use _OpReply class instead of passing bytes around.
Remove unnecessary operation argument to receive message.
Move _first_batch to message.py to avoid circular import.
This commit add the pymongo.collation.Collation class and associated enums. A
collation may be sent with individual write operations when connected to MongoDB
3.4+. Unlike read and write concern, a collation may not be attached to a
database or collection instance.
This commit implements the following simplifications and improvements:
- The Subscriber ABC has been renamed to CommandListener
- The subscribe function has been renamed to register
- The COMMAND constant has been removed
- The get_subscribers function has been removed
- Command listeners can now be registered per MongoClient instance
instead of just globally
This commit adds support for monitoring queries and getMore
operations, including getMore operations for command cursors
(e.g. aggregate cursor getMore). It also fixes a bug in duration
calculation.
SocketInfo and Pool are now responsible for catching all socket.errors and
gaierrors and translating them to ConnectionFailure. Server and MongoClient
need no longer worry about anything but ConnectionFailure. Functions in pool.py
and network.py still throw socket.errors into SocketInfo and Pool.
Call ismaster on each new connection and store the results on the SocketInfo
instance.
The upcoming Authentication Spec says: "If credentials exist, upon opening a
socket, drivers MUST send an isMaster command immediately. This allows a driver
to determine whether the server is an Arbiter. Calling ismaster additionally
allows the driver to know if the default authentication method for each socket
is MONGODB-CR or SCRAM-SHA-1, avoiding races when the driver repopulates the
pool after a disconnect."
In theory we could choose not to call ismaster if there are no credentials, but
it's simpler always to call ismaster, and paves the way for future breaking
changes to the wire protocol besides the current breaking change to
authentication.
Remove MongoClient's methods start_request(), in_request(), and end_request().
The purpose of requests was to provide read-your-writes consistency when using
w=0 write concern. Starting a request pins a socket to a thread so any
operations on that thread end up in the same queue on the server side.
Justification for removing: mongos 2.6+ doesn't support socket pinning by
default, and mongos 2.8+ doesn't support it at all (SERVER-12273), so whatever
weak consistency guarantees a request was supposed to provide are not provided
with sharding.
It's unnecessary with MongoDB 2.6+ since write commands always block and send a
response.
It's a confusing feature that should rarely be used, if ever, yet people
incorrectly use it all the time. It makes our connection pool unmaintainable to
any but the most expert developers.
The Server Discovery And Monitoring Spec has replaced the term "cluster"
with "topology", since "cluster" in MongoDB terminology should be reserved
for sharded clusters. "Topology" describes a single server, replica set, or a
set of mongoses.
The previous commit replaced "cluster" with "topology" in file names. Here
I replace the term in class and variable names.
MongoClient now supports all MongoReplicaSetClient's features.
Fix bugs and add features in the new MongoClient to bring it up
to spec. MongoReplicaSetClient is now a deprecated stub that
subclasses MongoClient.
Introduce new errors, NetworkTimeout and NotMasterError, to
communicate events that MongoClient must handle specially.
The new MongoClient, based on Cluster and Server,
includes functionality that had been split between the
old MongoClient and MongoReplicaSetClient. A
previous commit introduced the new MongoClient
but broke authentication.
Replace MongoClient with an implementation that relies on Cluster and Server. The new MongoClient takes over MongoReplicaSetClient's responsibilities.
Authentication, secondary-pinning, and Mongos high-availability are broken and will be reimplemented in a future commit. RS tests are temporarily disabled.
SocketInfo is now responsible for sending and receiving messages,
for closing itself on error, and for returning itself to the pool
when its with-statement is exited.
Pool.discard_socket is removed. Returning a closed socket to the
pool has the same effect as discard_socket had.
Remove client._exhaust_next.