Using setSlaveOkay we can tell mongo driver that it is allowed to connect to slave servers and execute queries on them. Functionality is explained here http://php.net/manual/en/mongo.queries.php php driver allows this to be set on every level connection, db, collection...

I suggest setting it on connection level and make it configurable with connection settings like bellow.

<?php
$conf
['mongodb_connections'] = array(
    
// Connection name/alias
     
'default' => array(
      
'host' => 'slave1',
      
// Database name
      
'db' => 'drupal_default',
      
'slave_ok' => TRUE,
     ),
);
?>

We would then set setSlaveOkay to true in mongodb function. I'm working on a patch.

Files: 
CommentFileSizeAuthor
#2 1793532_slave_ok.patch1.05 KBRok Žlender
Test request sent.
[ View ]

Comments

Oh php docs say setSlaveOkay is deprecated but they undeprecated it in https://jira.mongodb.org/browse/PHP-444 release in latest php mongo driver http://pecl.php.net/package-info.php?package=mongo&version=1.2.12

Status:Needs work» Needs review
StatusFileSize
new1.05 KB
Test request sent.
[ View ]

Attached patch allows crating a connection that allows querying slave.

Status:Needs review» Reviewed & tested by the community

Yes this is good to go.

Status:Reviewed & tested by the community» Fixed

Thanks chx and Marc for review. Committed to 7.x-1.x

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.