Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 and 403]

(no description)

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

Defines 1 class

Google_Task_Runner:: (7 methods):
  __construct()
  canAttmpt()
  run()
  attempt()
  backOff()
  getDelay()
  getJitter()


Class: Google_Task_Runner  - X-Ref

A task runner with exponential backoff support.

__construct(Google_Client $client,$name,$action,array $arguments = array()   X-Ref
Creates a new task runner with exponential backoff support.

param: Google_Client $client The current API client
param: string $name The name of the current task (used for logging)
param: callable $action The task to run and possibly retry
param: array $arguments The task arguments

canAttmpt()   X-Ref
Checks if a retry can be attempted.

return: boolean

run()   X-Ref
Runs the task and (if applicable) automatically retries when errors occur.

return: mixed

attempt()   X-Ref
Runs a task once, if possible. This is useful for bypassing the `run()`
loop.

NOTE: If this is not the first attempt, this function will sleep in
accordance to the backoff configurations before running the task.

return: boolean

backOff()   X-Ref
Sleeps in accordance to the backoff configurations.


getDelay()   X-Ref
Gets the delay (in seconds) for the current backoff period.

return: float

getJitter()   X-Ref
Gets the current jitter (random number between -$this->jitter and
$this->jitter).

return: float