Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Query builder read prefs and wrap driver classes directly #143

Merged
merged 7 commits into from
Nov 1, 2013

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Oct 31, 2013

This is comprehensive change to properly support read preferences.

Database and Collection are now constructed with corresponding driver classes, which they wrap permanently. The getter methods no longer act like factory methods, which means it's possible for settings such as read preferences to be assigned and stay in place.

Constructor signatures for core classes (excluding Connection) changed a bit, but there should not be BC breaks for public methods.

Constructor signatures have changed. Collections and Databases are now constructed with the MongoCollection and MongoDB instances to be wrapped, respectively. The getter methods for driver classes no longer operate like factories (returning new instances on each call), which makes it possible to set and maintain read preferences.

The ability to reconstruct MongoClient has been removed from Cursor::retry() and Connection::initialize(), since that is not necessary for the driver to reestablish a database connection.

For the Loggable classes, the loggerCallable argument has been moved to the end of the constructor. This removes previous inconsistencies between Loggable and non-Loggable constructors.
MongoCursor::setReadPreference() is not affected, since its method wasn't implemented until 1.3.3.
The driver may emit an E_WARNING for invalid arguments, but the return value should always be the MongoCursor (not a boolean).

Move the saving of readPreference and tags arguments after the driver method, so that we don't capture the arguments if an error handler decides to throw an exception.

See: https://jira.mongodb.org/browse/PHP-920
Read preferences will be applied during cursor preparation. For read-only commands, the read preference will be temporarily applied to the database (most cases) or collection and then restored before the command's result is returned or its exception propagated.
jmikola added a commit that referenced this pull request Nov 1, 2013
Query builder read prefs and wrap driver classes directly
@jmikola jmikola merged commit 5654777 into master Nov 1, 2013
@jmikola jmikola deleted the readPreference branch November 1, 2013 20:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant