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.

$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.

CommentFileSizeAuthor
#2 1793532_slave_ok.patch1.05 KBRok Žlender
None View
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

Rok Žlender’s picture

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

Rok Žlender’s picture

Status: Needs work » Needs review
FileSize
1.05 KB
None View

Attached patch allows crating a connection that allows querying slave.

marcingy’s picture

Status: Needs review » Reviewed & tested by the community
chx’s picture

Yes this is good to go.

Rok Žlender’s picture

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.