Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | 1793532_slave_ok.patch | 1.05 KB | Rok Žlender |
Comments
Comment #1
Rok Žlender CreditAttribution: Rok Žlender commentedOh 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
Comment #2
Rok Žlender CreditAttribution: Rok Žlender commentedAttached patch allows crating a connection that allows querying slave.
Comment #3
marcingy CreditAttribution: marcingy commentedComment #4
chx CreditAttribution: chx commentedYes this is good to go.
Comment #5
Rok Žlender CreditAttribution: Rok Žlender commentedThanks chx and Marc for review. Committed to 7.x-1.x