Manual:Hooks/ApiMaxLagInfo

From Linux Web Expert

ApiMaxLagInfo
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Called right before giving out information about max lag in API
<translate> Define function:</translate>
public static function onApiMaxLagInfo( array &$lagInfo ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"ApiMaxLagInfo": "MediaWiki\\Extension\\MyExtension\\Hooks::onApiMaxLagInfo"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> api/ApiMain.php
<translate> Interface:</translate> ApiMaxLagInfoHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:ApiMaxLagInfo extensions</tvar>.</translate>


Details

Use this to override lag information. Generally a hook function should only replace $lagInfo if the new $lagInfo['lag'] is greater than the current $lagInfo['lag'].

  • &$lagInfo: Maximum lag information array. Fields in the array are:
    • 'lag' is the number of seconds of lag.
    • 'host' is the host name on which the lag exists.
    • 'type' is an indication of the type of lag, e.g. "db" for database replication lag or "jobqueue" for job queue size converted to pseudo-seconds.
    • It is possible to add more fields and they will be returned to the user in the API response.