Closed tinchodias closed 4 years ago
Hello all, it is finally ready for merging, I can just do it as it doesn't alter the "default" group of the Metacello baseline.
But would be great if you can give your opinion/review. @noha ? @estebanlm ? :) :)
Some possible questions:
Why should we care about the SDAM stuff? Operating with a mongodb replica set is not trivial and this SDAM specification should bring the experience of developers of several other official Mongodb clients (e.g. C, Python, JS) in aspects such as how regularly ping servers, how to act on a unresponsive server, or how to select a secondary server to perform a read (with ReadPreference).
Why did you add it as a new Metacello group (instead of just default)? As the 'SDAM' group includes a new project as dependency (Taskit), I didn't want to force all users to load it. At least for this initial and partial implementation. But I think MongoClient works well and it's tested, so everybody should be fine with loading it.
Doesn't it deserve to be a different github project/have its own BaselineOfMongoSDAMClient? It was an alternative, and MongoTalk could be just a dependency of the new project. But my opinion is that, in the future, MongoTalk 'default' group and 'SDAM' group will be just one.
mc/Mongo-SDAM.package/MongoClient.class/instance/mongoDo.serverSelection..st, line 7 at r1 (raw file):
This doesn't honor a socket timeout and might block for a long time.
Oh, this is a pending-to-fix comment.
The period to review it has extended too long and the changes doesn't impact users unless they load the SDAM group specifically. So I wrote some documentation for README and I'm merging it.
These changes add a partial implementation of a SDAM MongoClient (explained in issue #54 but also give an introduction in this text).
Intro
As you know, we can open a connection and perform a write operation simply as follows:
This is fine in a mongodb single server configuration, but it is not as simple when we are not sure to which server perform the operation. This is the case when the server belongs to a Replica Set, because write operations can only be performed to the current primary server and it may change along the time due to network issues or other inconveniences.
Additionally, Replica Sets support read operations to be performed on non-primary servers so caller could choose between multiple servers (see mongodb's ReadPreferences).
SDAM client
To help in this kind of scenarios, the SDAM MongoClient monitors the Replica Set status to provide the instance of Mongo that the caller requires to perform the operation.
The client can be created and make it start monitoring as follows:
and perform write operations with code such as:
Note
This is only a partial implementation of the official mongodb's SDAM specification. Why? One reason is that the MongoClient doesn't provide any db or collection operations (e.g. CRUD operations) like the specification states. Instead, such operations are supported by first obtaining a Mongo instance (the one provided by current MongoTalk) and then obtaining the db/collection to perform the operations.
Metacello configuration
Reviewers can load this change with:
Please note that SDAM requires taskit as dependency (the client monitors are taskit services).
This change is