MediaWiki master
Wikimedia\Rdbms\IConnectionProvider Interface Reference

Provide primary and replica IDatabase connections. More...

Inherited by Wikimedia\Rdbms\ILBFactory.

Public Member Functions

 commitAndWaitForReplication ( $fname, $ticket, array $opts=[])
 Commit primary DB transactions and wait for replication (if $ticket indicates it is safe).
 
 getEmptyTransactionTicket ( $fname)
 Get a token asserting that no write transactions are active on tracked connections.
 
 getPrimaryDatabase ( $domain=false)
 Get connection to the primary database.
 
 getReplicaDatabase ( $domain=false, $group=null)
 Get connection to a replica database.
 

Detailed Description

Provide primary and replica IDatabase connections.

This is a narrow interface intended as the main entrypoint to the Rdbms library. No methods should be added unless absolutely needed.

The main implementation is \Wikimedia\Rdbms\LBFactory. To obtain an instance, use \MediaWiki\MediaWikiServices::getDBLoadBalancerFactory().

See also
ILBFactory
Since
1.40

Definition at line 35 of file IConnectionProvider.php.

Member Function Documentation

◆ commitAndWaitForReplication()

Wikimedia\Rdbms\IConnectionProvider::commitAndWaitForReplication ( $fname,
$ticket,
array $opts = [] )

Commit primary DB transactions and wait for replication (if $ticket indicates it is safe).

This is mostly used in jobs or deferred updates dealing with batching.

The ticket is used to check that the caller owns the transaction round or can act on behalf of the caller that owns the transaction round.

See also
ILBFactory::commitPrimaryChanges()
ILBFactory::waitForReplication()
Since
1.28
Parameters
string$fnameCaller name (e.g. METHOD)
mixed$ticketResult of getEmptyTransactionTicket()
array$optsOptions to waitForReplication()
Returns
bool True if the wait was successful, false on timeout

Implemented in Wikimedia\Rdbms\LBFactory.

◆ getEmptyTransactionTicket()

Wikimedia\Rdbms\IConnectionProvider::getEmptyTransactionTicket ( $fname)

Get a token asserting that no write transactions are active on tracked connections.

This is mostly used in jobs or deferred updates dealing with batching.

Since
1.28
Parameters
string$fnameCaller name (e.g. METHOD)
Returns
mixed A value to pass to commitAndWaitForReplication()

Implemented in Wikimedia\Rdbms\LBFactory.

◆ getPrimaryDatabase()

Wikimedia\Rdbms\IConnectionProvider::getPrimaryDatabase ( $domain = false)

Get connection to the primary database.

This should be used when there the code needs to write to the database.

This method accepts virtual domains ({

See also
\MediaWiki\MainConfigSchema::VirtualDomainsMapping}).
Since
1.40
Parameters
string | false$domainDomain ID, or false for the current domain
Returns
IDatabase

Implemented in Wikimedia\Rdbms\LBFactory.

Referenced by MediaWiki\Page\MergeHistory\__construct(), Wikimedia\Rdbms\DBAccessObjectUtils\getDBFromIndex(), and Wikimedia\Rdbms\DBAccessObjectUtils\getDBFromRecency().

◆ getReplicaDatabase()


The documentation for this interface was generated from the following file: