MatchingTermsLookupFactory:
public function getLookupForDatabase( $dbName ): MatchingTermsLookup { $loadBalancer = $this->loadBalancerFactory->getMainLB( $dbName ); $databaseTypeIdsStore = new DatabaseTypeIdsStore( $loadBalancer, $this->objectCache, $dbName, $this->logger ); return new DatabaseMatchingTermsLookup( $loadBalancer, $databaseTypeIdsStore, $databaseTypeIdsStore, $this->entityIdComposer, $this->logger ); }
DatabaseTypeIdsStore creates a NameTableStore which uses the LoadBalancer as follows:
private function getDBConnection( $index, $flags = 0 ) { return $this->loadBalancer->getConnectionRef( $index, [], $this->domain, $flags ); }
and
$this->loadBalancer->resolveDomainID( $this->domain )
DatabaseMatchingTermsLookup uses it only to get a connection:
private function getDbr() { return $this->lb->getConnection( ILoadBalancer::DB_REPLICA, [], $this->databaseDomain ); }
NameTableStore is a core class that expects a ILoadBalancer in its constructor. NameTableStoreFactory expects a ILBFactory. Not sure what would be easier/cleaner to implement. Extract NameTableStore generation into a Wikibase Service?