Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
Google_Task_Runner Class Reference

Public Member Functions

 __construct (Google_Client $client, $name, $action, array $arguments=array())
 Creates a new task runner with exponential backoff support.
 
 attempt ()
 Runs a task once, if possible.
 
 canAttmpt ()
 Checks if a retry can be attempted.
 
 run ()
 Runs the task and (if applicable) automatically retries when errors occur.
 

Constructor & Destructor Documentation

◆ __construct()

Google_Task_Runner::__construct ( Google_Client $client,
$name,
$action,
array $arguments = array() )

Creates a new task runner with exponential backoff support.

Parameters
Google_Client$clientThe current API client
string$nameThe name of the current task (used for logging)
callable$actionThe task to run and possibly retry
array$argumentsThe task arguments
Exceptions
Google_Task_Exceptionwhen misconfigured

Member Function Documentation

◆ attempt()

Google_Task_Runner::attempt ( )

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 values
boolean

◆ canAttmpt()

Google_Task_Runner::canAttmpt ( )

Checks if a retry can be attempted.

Return values
boolean

◆ run()

Google_Task_Runner::run ( )

Runs the task and (if applicable) automatically retries when errors occur.

Return values
mixed
Exceptions
Google_Task_Retryableon failure when no retries are available.

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