Adding a guard to connection to replica set.