WMDE-leszek has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/332760 )

Change subject: Add DataRetrievalServiceFactory interface
......................................................................

Add DataRetrievalServiceFactory interface

Introduces generic interface for factories providing data
retrieving/lookup services.
DispatchingServiceFactory implements the new interface,
providing dispatching wrappers around lookup services.

DirectSqlStore does not need to know about implementation details
of the particular factory it uses, therefore it now expectes any
DataRetrievalServiceFactory implementation.
WikibaseClient also hides implementation details and exposes
DataRetrievalServiceFactory implementation without limiting to
the particular implementation.

Bug: T155623
Change-Id: I1d545ca947e3e8b5c3dcae667a582a57a54b0a39
---
A client/includes/DataRetrievalServiceFactory.php
M client/includes/DispatchingServiceFactory.php
M client/includes/Store/Sql/DirectSqlStore.php
M client/includes/WikibaseClient.php
4 files changed, 49 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/60/332760/2

diff --git a/client/includes/DataRetrievalServiceFactory.php 
b/client/includes/DataRetrievalServiceFactory.php
new file mode 100644
index 0000000..908798b
--- /dev/null
+++ b/client/includes/DataRetrievalServiceFactory.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Wikibase\Client;
+
+use Wikibase\DataModel\Services\Term\TermBuffer;
+use Wikibase\Lib\Store\EntityRevisionLookup;
+use Wikibase\Lib\Store\PropertyInfoLookup;
+
+/**
+ * An interface of a factory of data retrieval/lookup services.
+ *
+ * @license GPL-2.0+
+ */
+interface DataRetrievalServiceFactory {
+
+       /**
+        * @return EntityRevisionLookup
+        */
+       public function getEntityRevisionLookup();
+
+       /**
+        * @return PropertyInfoLookup
+        */
+       public function getPropertyInfoLookup();
+
+       /**
+        * @return TermBuffer
+        */
+       public function getTermBuffer();
+
+}
diff --git a/client/includes/DispatchingServiceFactory.php 
b/client/includes/DispatchingServiceFactory.php
index 4af6e76..974357c 100644
--- a/client/includes/DispatchingServiceFactory.php
+++ b/client/includes/DispatchingServiceFactory.php
@@ -20,7 +20,7 @@
  *
  * @license GPL-2.0+
  */
-class DispatchingServiceFactory extends ServiceContainer {
+class DispatchingServiceFactory extends ServiceContainer implements 
DataRetrievalServiceFactory {
 
        /**
         * @var RepositoryServiceContainer[]
diff --git a/client/includes/Store/Sql/DirectSqlStore.php 
b/client/includes/Store/Sql/DirectSqlStore.php
index 8a2329a..0353439 100644
--- a/client/includes/Store/Sql/DirectSqlStore.php
+++ b/client/includes/Store/Sql/DirectSqlStore.php
@@ -4,12 +4,11 @@
 
 use HashBagOStuff;
 use ObjectCache;
-use Wikibase\Client\DispatchingServiceFactory;
+use Wikibase\Client\DataRetrievalServiceFactory;
 use Wikibase\Client\RecentChanges\RecentChangesDuplicateDetector;
 use Wikibase\Client\Store\Sql\PagePropsEntityIdLookup;
 use Wikibase\Lib\Store\CachingPropertyInfoLookup;
 use Wikibase\Lib\Store\PropertyInfoLookup;
-use Wikibase\Lib\Store\Sql\PropertyInfoTable;
 use Wikimedia\Rdbms\SessionConsistentConnectionManager;
 use Wikibase\Client\Store\UsageUpdater;
 use Wikibase\Client\Usage\Sql\SqlSubscriptionManager;
@@ -110,9 +109,9 @@
        private $entityRevisionLookup = null;
 
        /**
-        * @var DispatchingServiceFactory
+        * @var DataRetrievalServiceFactory
         */
-       private $dispatchingServiceFactory = null;
+       private $dataRetrievalServiceFactory = null;
 
        /**
         * @var PropertyLabelResolver|null
@@ -175,7 +174,7 @@
         * @param EntityIdParser $entityIdParser
         * @param EntityIdComposer $entityIdComposer
         * @param EntityNamespaceLookup $entityNamespaceLookup
-        * @param DispatchingServiceFactory $dispatchingServiceFactory
+        * @param DataRetrievalServiceFactory $dataRetrievalServiceFactory
         * @param string|bool $repoWiki The symbolic database name of the repo 
wiki or false for the
         * local wiki.
         * @param string $languageCode
@@ -186,7 +185,7 @@
                EntityIdParser $entityIdParser,
                EntityIdComposer $entityIdComposer,
                EntityNamespaceLookup $entityNamespaceLookup,
-               DispatchingServiceFactory $dispatchingServiceFactory,
+               DataRetrievalServiceFactory $dataRetrievalServiceFactory,
                $repoWiki = false,
                $languageCode
        ) {
@@ -195,7 +194,7 @@
                $this->entityIdParser = $entityIdParser;
                $this->entityIdComposer = $entityIdComposer;
                $this->entityNamespaceLookup = $entityNamespaceLookup;
-               $this->dispatchingServiceFactory = $dispatchingServiceFactory;
+               $this->dataRetrievalServiceFactory = 
$dataRetrievalServiceFactory;
                $this->repoWiki = $repoWiki;
                $this->languageCode = $languageCode;
 
@@ -338,7 +337,7 @@
                // NOTE: Keep cache key in sync with 
SqlStore::newEntityRevisionLookup in WikibaseRepo
                $cacheKeyPrefix = $this->cacheKeyPrefix . 
':WikiPageEntityRevisionLookup';
 
-               $dispatchingLookup = 
$this->dispatchingServiceFactory->getEntityRevisionLookup();
+               $dispatchingLookup = 
$this->dataRetrievalServiceFactory->getEntityRevisionLookup();
 
                // Lower caching layer using persistent cache (e.g. memcached).
                $persistentCachingLookup = new CachingEntityRevisionLookup(
@@ -439,7 +438,7 @@
         */
        public function getPropertyInfoLookup() {
                if ( $this->propertyInfoLookup === null ) {
-                       $propertyInfoLookup = 
$this->dispatchingServiceFactory->getPropertyInfoLookup();
+                       $propertyInfoLookup = 
$this->dataRetrievalServiceFactory->getPropertyInfoLookup();
                        $cacheKey = $this->cacheKeyPrefix . 
':CacheAwarePropertyInfoStore';
 
                        $this->propertyInfoLookup = new 
CachingPropertyInfoLookup(
diff --git a/client/includes/WikibaseClient.php 
b/client/includes/WikibaseClient.php
index be8b86a..869f6c4 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -120,9 +120,9 @@
        private $siteLookup;
 
        /**
-        * @var DispatchingServiceFactory
+        * @var DataRetrievalServiceFactory
         */
-       private $dispatchingServiceFactory;
+       private $dataRetrievalServiceFactory;
 
        /**
         * @var PropertyDataTypeLookup|null
@@ -381,17 +381,17 @@
        }
 
        /**
-        * @return DispatchingServiceFactory
+        * @return DataRetrievalServiceFactory
         */
-       private function getDispatchingServiceFactory() {
-               if ( $this->dispatchingServiceFactory === null ) {
+       private function getDataRetrievalServiceFactory() {
+               if ( $this->dataRetrievalServiceFactory === null ) {
                        $factory = new DispatchingServiceFactory( $this );
                        $factory->loadWiringFiles( $this->settings->getSetting( 
'dispatchingServiceWiringFiles' ) );
 
-                       $this->dispatchingServiceFactory = $factory;
+                       $this->dataRetrievalServiceFactory = $factory;
                }
 
-               return $this->dispatchingServiceFactory;
+               return $this->dataRetrievalServiceFactory;
        }
 
        /**
@@ -420,7 +420,7 @@
         */
        private function getPrefetchingTermLookup() {
                if ( !$this->termLookup ) {
-                       $this->termLookup = 
$this->getDispatchingServiceFactory()->getTermBuffer();
+                       $this->termLookup = 
$this->getDataRetrievalServiceFactory()->getTermBuffer();
                }
 
                return $this->termLookup;
@@ -533,7 +533,7 @@
                                $this->getEntityIdParser(),
                                $this->getEntityIdComposer(),
                                $this->getEntityNamespaceLookup(),
-                               $this->getDispatchingServiceFactory(),
+                               $this->getDataRetrievalServiceFactory(),
                                $repoDatabase,
                                $this->contentLanguage->getCode()
                        );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d545ca947e3e8b5c3dcae667a582a57a54b0a39
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to