Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob Class Reference

Job for updating translation memory. More...

Inheritance diagram for MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob:

Public Member Functions

 __construct (Title $title, array $params=[])
 
 run ()
 Fetch all the translations and update them.
 
 allowRetries ()
 @inheritDoc
 
 setDelay (int $delay)
 Set a delay for this job.
 

Static Public Member Functions

static newJob (MessageHandle $handle, string $command)
 
static backoffDelay (int $errorCount)
 

Protected Member Functions

 resend (self $job)
 Extracted for testing purpose.
 
 getHandle ()
 Extracted for testing purpose.
 
 getTranslation (MessageHandle $handle)
 Extracted for testing purpose.
 

Protected Attributes

const MAX_ERROR_RETRY = 4
 Number of retries allowed, 4 means we attempt to run the job 5 times (1 initial attempt + 4 retries).
 
const WRITE_BACKOFF_EXPONENT = 7
 Constant used by backoffDelay().
 

Detailed Description

Job for updating translation memory.

job params:

  • command: the command to run, defaults to 'rebuild'
  • service: the service to write to, if set to null the job will write to the default (primary) service and its replicas.
  • errorCount: number of errors encountered while trying to perform the write on this service

This job handles retries itself and return false in allowRetries to disable JobQueue's internal retry service.

Author
Niklas Laxström @license GPL-2.0-or-later

Definition at line 33 of file TtmServerMessageUpdateJob.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::__construct ( Title $title,
array $params = [] )

Definition at line 54 of file TtmServerMessageUpdateJob.php.

Member Function Documentation

◆ allowRetries()

MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::allowRetries ( )

@inheritDoc

Definition at line 79 of file TtmServerMessageUpdateJob.php.

◆ backoffDelay()

static MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::backoffDelay ( int $errorCount)
static
Parameters
int$errorCountThe number of times the job has errored out.
Returns
int Number of seconds to delay. With the default minimum exponent of 6 the possible return values are 64, 128, 256, 512 and 1024 giving a maximum delay of 17 minutes.

Definition at line 269 of file TtmServerMessageUpdateJob.php.

◆ getHandle()

MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::getHandle ( )
protected

Extracted for testing purpose.

Definition at line 163 of file TtmServerMessageUpdateJob.php.

◆ getTranslation()

MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::getTranslation ( MessageHandle $handle)
protected

Extracted for testing purpose.

Definition at line 168 of file TtmServerMessageUpdateJob.php.

◆ newJob()

static MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::newJob ( MessageHandle $handle,
string $command )
static

Definition at line 50 of file TtmServerMessageUpdateJob.php.

◆ resend()

MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::resend ( self $job)
protected

Extracted for testing purpose.

Definition at line 136 of file TtmServerMessageUpdateJob.php.

◆ run()

MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::run ( )

Fetch all the translations and update them.

Definition at line 70 of file TtmServerMessageUpdateJob.php.

◆ setDelay()

MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::setDelay ( int $delay)

Set a delay for this job.

Note that this might not be possible, the JobQueue implementation handling this job doesn't support it (JobQueueDB) but is possible for the high performance JobQueueRedis. Note also that delays are minimums - at least JobQueueRedis makes no effort to remove the delay as soon as possible after it has expired. By default, it only checks every five minutes or so. Note yet again that if another delay has been set that is longer then this one then the longer delay stays.

Parameters
int$delayseconds to delay this job if possible

Definition at line 250 of file TtmServerMessageUpdateJob.php.

Member Data Documentation

◆ MAX_ERROR_RETRY

const MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::MAX_ERROR_RETRY = 4
protected

Number of retries allowed, 4 means we attempt to run the job 5 times (1 initial attempt + 4 retries).

Definition at line 38 of file TtmServerMessageUpdateJob.php.

◆ WRITE_BACKOFF_EXPONENT

const MediaWiki\Extension\Translate\TtmServer\TtmServerMessageUpdateJob::WRITE_BACKOFF_EXPONENT = 7
protected

Constant used by backoffDelay().

With 7 the cumulative delay between the first and last attempt is between 8 and 33 minutes.

Definition at line 45 of file TtmServerMessageUpdateJob.php.


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