[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/jobqueue/ -> JobRunner.php (summary)

Job queue runner utility methods This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 350 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

JobRunner:: (7 methods):
  setDebugHandler()
  run()
  getBackoffTimeToWait()
  loadBackoffs()
  syncBackoffDeltas()
  assertMemoryOK()
  runJobsLog()


Class: JobRunner  - X-Ref

Job queue runner utility methods

setDebugHandler( $debug )   X-Ref

param: callable $debug Optional debug output handler

run( array $options )   X-Ref
Run jobs of the specified number/type for the specified time

The response map has a 'job' field that lists status of each job, including:
- type   : the job type
- status : ok/failed
- error  : any error message string
- time   : the job run time in ms
The response map also has:
- backoffs : the (job type => seconds) map of backoff times
- elapsed  : the total time spent running tasks in ms
- reached  : the reason the script finished, one of (none-ready, job-limit, time-limit)

This method outputs status information only if a debug handler was set.
Any exceptions are caught and logged, but are not reported as output.

param: array $options Map of parameters:
return: array Summary response that can easily be JSON serialized

getBackoffTimeToWait( Job $job )   X-Ref

param: Job $job
return: int Seconds for this runner to avoid doing more jobs of this type

loadBackoffs( array $backoffs, $mode = 'wait' )   X-Ref
Get the previous backoff expiries from persistent storage
On I/O or lock acquisition failure this returns the original $backoffs.

param: array $backoffs Map of (job type => UNIX timestamp)
param: string $mode Lock wait mode - "wait" or "nowait"
return: array Map of (job type => backoff expiry timestamp)

syncBackoffDeltas( array $backoffs, array &$deltas, $mode = 'wait' )   X-Ref
Merge the current backoff expiries from persistent storage

The $deltas map is set to an empty array on success.
On I/O or lock acquisition failure this returns the original $backoffs.

param: array $backoffs Map of (job type => UNIX timestamp)
param: array $deltas Map of (job type => seconds)
param: string $mode Lock wait mode - "wait" or "nowait"
return: array The new backoffs account for $backoffs and the latest file data

assertMemoryOK()   X-Ref
Make sure that this script is not too close to the memory usage limit.
It is better to die in between jobs than OOM right in the middle of one.


runJobsLog( $msg )   X-Ref
Log the job message

param: string $msg The message to log



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1