Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 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