Interactor class for dispatching change notifications to client wikis via the job queue.
More...
Interactor class for dispatching change notifications to client wikis via the job queue.
- See also
- md_docs_topics_change-propagation for an overview of the change propagation mechanism.
- Copyright
- GPL-2.0-or-later
- Author
- Daniel Kinzler
◆ __construct()
- Parameters
-
ChangeDispatchCoordinator | $coordinator | |
ChangeNotificationSender | $notificationSender | |
ChunkAccess | $chunkedChangesAccess | Access to the changes table. Should only return Change objects from loadChunk. |
SubscriptionLookup | $subscriptionLookup | |
◆ filterChanges()
Wikibase\Repo\ChangeDispatcher::filterChanges |
( |
|
$siteID, |
|
|
array |
$changes, |
|
|
|
$limit |
|
) |
| |
|
private |
Filters a list of changes, removing changes not relevant to the given client wiki.
Currently, we keep EntityChanges for entities the client wiki is subscribed to, or that modify a sitelink to the client wiki.
- Parameters
-
string | $siteID | The client wiki's global site identifier, as used by sitelinks. |
Change[] | $changes | The list of changes to filter. |
int | $limit | The max number of changes to return |
- Returns
- array ( EntityChange[] $batch, int $seen ), where $batch is the filtered list of Change objects, and $seen is the ID of the last change considered for the batch (even if that was filtered out), for use as a continuation marker. -return array{0:EntityChange[],1:int}
◆ getBatchChunkFactor()
Wikibase\Repo\ChangeDispatcher::getBatchChunkFactor |
( |
| ) |
|
◆ getBatchSize()
Wikibase\Repo\ChangeDispatcher::getBatchSize |
( |
| ) |
|
◆ getDispatchCoordinator()
Wikibase\Repo\ChangeDispatcher::getDispatchCoordinator |
( |
| ) |
|
- Returns
- ChangeDispatchCoordinator
◆ getExceptionHandler()
Wikibase\Repo\ChangeDispatcher::getExceptionHandler |
( |
| ) |
|
◆ getMaxChunks()
Wikibase\Repo\ChangeDispatcher::getMaxChunks |
( |
| ) |
|
- Returns
- int Maximum number of chunks or passes per wiki when selecting pending changes.
◆ getMessageReporter()
Wikibase\Repo\ChangeDispatcher::getMessageReporter |
( |
| ) |
|
◆ getPendingChanges()
Wikibase\Repo\ChangeDispatcher::getPendingChanges |
( |
|
$siteID, |
|
|
|
$after |
|
) |
| |
Returns a batch of changes for the given client wiki, starting from the given position in the wb_changes table.
The changes may be filtered to only include those changes that are relevant to the given client wiki. The number of changes returned by this method is limited by $this->batchSize. Changes are returned with IDs in ascending order.
- Note
- due to programmatic filtering, this method may use multiple database queries to collect the changes for the next batch. The number of requests needed can be adjusted using $this->batchChunkFactor (via the 'dispatchBatchChunkFactor' setting).
- Parameters
-
string | $siteID | The client wiki's global site identifier, as used by sitelinks. |
int | $after | The last change ID processed by a previous run. All changes returned will have an ID greater than $after. |
- Returns
- array ( Change[] $batch, int $seen ), where $batch is a list of Change objects, and $seen is the ID of the last change considered for the batch (even if that was filtered out), for use as a continuation marker. -return array{0:Change[],1:int}
◆ isRelevantChange()
Wikibase\Repo\ChangeDispatcher::isRelevantChange |
( |
Change |
$change, |
|
|
|
$siteID |
|
) |
| |
|
private |
Checks whether the given Change is somehow relevant to the given wiki site.
In particular this check whether the Change modifies any sitelink that refers to the given wiki site.
- Note
- this does not check whether the entity that was changes is or is not at all connected with (resp. used on) the target wiki.
- Parameters
-
Change | $change | the change to examine. |
string | $siteID | the site to consider. |
- Returns
- bool
◆ isVerbose()
Wikibase\Repo\ChangeDispatcher::isVerbose |
( |
| ) |
|
◆ log()
Wikibase\Repo\ChangeDispatcher::log |
( |
|
$message | ) |
|
|
private |
◆ reIndexEntityIds()
Wikibase\Repo\ChangeDispatcher::reIndexEntityIds |
( |
array |
$entityIds | ) |
|
|
private |
- Parameters
-
- Returns
- EntityId[] $entityIds re-keyed by id string.
◆ selectClient()
Wikibase\Repo\ChangeDispatcher::selectClient |
( |
| ) |
|
Selects a client wiki and locks it.
If no suitable client wiki can be found, this method returns null.
Note: this implementation will try a wiki from the list returned by getCandidateClients() at random. If all have been tried and failed, it returns null.
- Returns
- array An associative array containing the state of the selected client wiki (or null, if no target could be locked). Fields are:
- chd_site: the client wiki's global site ID
- chd_db: the client wiki's logical database name
- chd_seen: the last change ID processed for that client wiki
- chd_touched: timestamp giving the last time that client wiki was updated
- chd_lock: the name of a global lock currently active for that client wiki
- Exceptions
-
MWException | if no available client wiki could be found. |
- See also
- releaseWiki()
◆ setBatchChunkFactor()
Wikibase\Repo\ChangeDispatcher::setBatchChunkFactor |
( |
|
$batchChunkFactor | ) |
|
Sets the chunk factor.
The governs how many changes getPendingChanges will load in one go: the number loaded is the batch size multiplied by the batch chunk factor. A chunk factor > 1 reduces the need to load more changes in case not all end up in the batch opf pending changes due to programmatic filtering (e.g. by whether the client site is subscribed to a given change).
For example: Consider loading a batch of 5 changes to dispatch to foowiki, but of the first 5 changes, only 3 are relevant to foowiki. A chunk factor of 1 means only 5 changes have been loaded for examination, meaning at least one more batch has to be loaded. A chunk factor of 2 means 10 changes have been loaded for examination, which makes it more likely to fine the desired 5 changes for foowiki without loading more changes.
- Parameters
-
◆ setBatchSize()
Wikibase\Repo\ChangeDispatcher::setBatchSize |
( |
|
$batchSize | ) |
|
◆ setExceptionHandler()
Wikibase\Repo\ChangeDispatcher::setExceptionHandler |
( |
ExceptionHandler |
$exceptionHandler | ) |
|
◆ setMaxChunks()
Wikibase\Repo\ChangeDispatcher::setMaxChunks |
( |
|
$maxChunks | ) |
|
- Parameters
-
int | $maxChunks | Maximum number of chunks or passes per wiki when selecting pending changes. |
◆ setMessageReporter()
Wikibase\Repo\ChangeDispatcher::setMessageReporter |
( |
MessageReporter |
$messageReporter | ) |
|
◆ setVerbose()
Wikibase\Repo\ChangeDispatcher::setVerbose |
( |
|
$verbose | ) |
|
◆ trace()
Wikibase\Repo\ChangeDispatcher::trace |
( |
|
$message | ) |
|
|
private |
Log a message if verbose mode is enabled.
- Parameters
-
◆ $batchChunkFactor
Wikibase\Repo\ChangeDispatcher::$batchChunkFactor = 3 |
|
private |
◆ $batchSize
Wikibase\Repo\ChangeDispatcher::$batchSize = 1000 |
|
private |
◆ $chunkedChangesAccess
Wikibase\Repo\ChangeDispatcher::$chunkedChangesAccess |
|
private |
◆ $coordinator
Wikibase\Repo\ChangeDispatcher::$coordinator |
|
private |
◆ $exceptionHandler
Wikibase\Repo\ChangeDispatcher::$exceptionHandler |
|
private |
◆ $maxChunks
Wikibase\Repo\ChangeDispatcher::$maxChunks = 15 |
|
private |
◆ $messageReporter
Wikibase\Repo\ChangeDispatcher::$messageReporter |
|
private |
◆ $notificationSender
Wikibase\Repo\ChangeDispatcher::$notificationSender |
|
private |
◆ $subscriptionLookup
Wikibase\Repo\ChangeDispatcher::$subscriptionLookup |
|
private |
◆ $verbose
Wikibase\Repo\ChangeDispatcher::$verbose = false |
|
private |
The documentation for this class was generated from the following file: