MediaWiki REL1_40
Wikimedia\Rdbms\IConnectionProvider Interface Reference

Narrow interface providing primary/replica 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

Narrow interface providing primary/replica connections.

This will be heavily used outside the rdmbs library and will become the main interface. No methods should be added unless absolutely needed.

See also
ILBFactory
Access: internal
Since
1.40

Definition at line 33 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.

Referenced by DeferredUpdates\attemptUpdate().

◆ 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.

Since
1.40
Parameters
string | false$domainDomain ID, or false for the current domain
Returns
IDatabase

Implemented in Wikimedia\Rdbms\LBFactory.

◆ getReplicaDatabase()

Wikimedia\Rdbms\IConnectionProvider::getReplicaDatabase ( $domain = false,
$group = null )

Get connection to a replica database.

Note that a read can have replication lag.

Since
1.40
Parameters
string | false$domainDomain ID, or false for the current domain
string | null$groupQuery group; null for the default group
Returns
IDatabase

Implemented in Wikimedia\Rdbms\LBFactory.


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