Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
TTMServerMessageUpdateJob Class Reference

Job for updating translation memory. More...

Inheritance diagram for TTMServerMessageUpdateJob:

Public Member Functions

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

Static Public Member Functions

static newJob (MessageHandle $handle, $command)
 
static backoffDelay ( $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.

If mirroring is activated on the primary service then the first job will try to write to all services, it will resend a new job to every single service that failed and will increment errorCount. When too many errors occur on single service the job is dropped.

Definition at line 33 of file TTMServerMessageUpdateJob.php.

Constructor & Destructor Documentation

◆ __construct()

TTMServerMessageUpdateJob::__construct ( $title,
$params = [] )
Parameters
Title$title
array$params

Definition at line 64 of file TTMServerMessageUpdateJob.php.

Member Function Documentation

◆ allowRetries()

TTMServerMessageUpdateJob::allowRetries ( )

@inheritDoc

Definition at line 118 of file TTMServerMessageUpdateJob.php.

◆ backoffDelay()

static TTMServerMessageUpdateJob::backoffDelay ( $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 295 of file TTMServerMessageUpdateJob.php.

◆ getHandle()

TTMServerMessageUpdateJob::getHandle ( )
protected

Extracted for testing purpose.

Returns
MessageHandle

Definition at line 224 of file TTMServerMessageUpdateJob.php.

◆ getTranslation()

TTMServerMessageUpdateJob::getTranslation ( MessageHandle $handle)
protected

Extracted for testing purpose.

Parameters
MessageHandle$handle
Returns
string

Definition at line 234 of file TTMServerMessageUpdateJob.php.

◆ newJob()

static TTMServerMessageUpdateJob::newJob ( MessageHandle $handle,
$command )
static
Parameters
MessageHandle$handle
string$command
Returns
self

Definition at line 54 of file TTMServerMessageUpdateJob.php.

◆ resend()

TTMServerMessageUpdateJob::resend ( self $job)
protected

Extracted for testing purpose.

Parameters
self$job

Definition at line 202 of file TTMServerMessageUpdateJob.php.

◆ run()

TTMServerMessageUpdateJob::run ( )

Fetch all the translations and update them.

Returns
bool

Definition at line 82 of file TTMServerMessageUpdateJob.php.

◆ setDelay()

TTMServerMessageUpdateJob::setDelay ( $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 276 of file TTMServerMessageUpdateJob.php.

Member Data Documentation

◆ MAX_ERROR_RETRY

const 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 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: