Addshore has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311438

Change subject: Give store configurable access to other db clusters
......................................................................

Give store configurable access to other db clusters

Change-Id: Ibdbc0d539eddb20c8a9a9a1f6685eed3864a11cc
---
M extension.json
M src/CognateStore.php
M src/ServiceWiring.php
3 files changed, 14 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cognate 
refs/changes/38/311438/1

diff --git a/extension.json b/extension.json
index 94e789e..f98b899 100644
--- a/extension.json
+++ b/extension.json
@@ -13,7 +13,8 @@
     "CognateStore": "src/CognateStore.php"
   },
   "config": {
-    "CognateWiki": false,
+    "CognateDb": false,
+    "CognateCluster": false,
     "CognateNamespaces": [ 0 ]
   },
   "Hooks": {
diff --git a/src/CognateStore.php b/src/CognateStore.php
index 0b10293..2b8fc22 100644
--- a/src/CognateStore.php
+++ b/src/CognateStore.php
@@ -11,20 +11,13 @@
         */
        private $loadBalancer;
 
-       /**
-        * @var string
-        */
-       private $wikiName;
-
        const TABLE_NAME = 'inter_language_titles';
 
        /**
         * @param LoadBalancer $loadBalancer
-        * @param string $wikiName
         */
-       public function __construct( LoadBalancer $loadBalancer, $wikiName ) {
+       public function __construct( LoadBalancer $loadBalancer ) {
                $this->loadBalancer = $loadBalancer;
-               $this->wikiName = $wikiName;
        }
 
        /**
@@ -37,7 +30,7 @@
                        'ilt_language' => $language,
                        'ilt_title' => $title
                ];
-               $dbw = $this->loadBalancer->getConnection( DB_MASTER, [], 
$this->wikiName );
+               $dbw = $this->loadBalancer->getConnection( DB_MASTER );
                $result = $dbw->insert( self::TABLE_NAME, $pageData, 
__METHOD__, [ 'IGNORE' ] );
                $this->loadBalancer->reuseConnection( $dbw );
 
@@ -54,7 +47,7 @@
        public function getTranslationsForPage( $language, $title ) {
                $languages = [];
 
-               $dbr = $this->loadBalancer->getConnection( DB_SLAVE, [], 
$this->wikiName );
+               $dbr = $this->loadBalancer->getConnection( DB_SLAVE );
                $result = $dbr->select( self::TABLE_NAME, ['ilt_language'], [
                        'ilt_language != ' . $dbr->addQuotes( $language ),
                        'ilt_title' => $title
diff --git a/src/ServiceWiring.php b/src/ServiceWiring.php
index 694a3ad..af44ab9 100644
--- a/src/ServiceWiring.php
+++ b/src/ServiceWiring.php
@@ -7,9 +7,14 @@
 
 return [
        'CognateStore' => function( MediaWikiServices $services ) {
-               return new CognateStore(
-                       $services->getDBLoadBalancer(),
-                       $services->getMainConfig()->get( 'CognateWiki' )
-               );
+               $lbFactory = $services->getDBLoadBalancerFactory();
+               $cognateDb = $services->getMainConfig()->get( 'CognateDb' );
+               $cognateCluster = $services->getMainConfig()->get( 
'CognateCluster' );
+               if ( $cognateCluster ) {
+                       $lb = $lbFactory->getExternalLB( $cognateCluster, 
$cognateDb );
+               } else {
+                       $lb = $lbFactory->getMainLB( $cognateDb );
+               }
+               return new CognateStore( $lb );
        },
 ];

-- 
To view, visit https://gerrit.wikimedia.org/r/311438
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdbc0d539eddb20c8a9a9a1f6685eed3864a11cc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cognate
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to