I'm playing around with data replication in MongoDb, and I currently have a master and several slave nodes. All of these are running on different ports, but they could just as well be on different machines (I'm testing atm).
My question is, how would I go about connecting to these from my code? Currently, I just have one instance of a db class, which is connected to x port on localhost. Obviously, if this node fails, I want to use the slave at y port on localhost, and if that fails, z port on localhost. Shall I use separate db objects for different connections?