Page MenuHomePhabricator

Replace ILBFactory and ILoadBalancer with injecting new Db-Service in Lib's MatchingTermsLookupFactory and created classes: NameTableStore, DatabaseMatchingTermsLookup
Closed, ResolvedPublic

Description

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?

Event Timeline

Michael renamed this task from Replace ILBFactory and ILoadBalancer with injecting new Db-Service in Lib's MatchingTermsLookupFactory and created classes: NameTableStore to Replace ILBFactory and ILoadBalancer with injecting new Db-Service in Lib's MatchingTermsLookupFactory and created classes: NameTableStore, DatabaseMatchingTermsLookup.May 21 2021, 11:24 AM
Michael updated the task description. (Show Details)

Change 698503 had a related patch set uploaded (by Jakob; author: Jakob):

[mediawiki/extensions/Wikibase@master] Change RepoDomainDbFactory::newForEntityType to newForEntitySource

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

Change 698566 had a related patch set uploaded (by Jakob; author: Jakob):

[mediawiki/extensions/Wikibase@master] MatchingTermsLookupFactory: use RepoDomainDbFactory

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

Change 698503 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Change RepoDomainDbFactory::newForEntityType to newForEntitySource

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

Change 698566 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] MatchingTermsLookupFactory: use RepoDomainDbFactory

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