You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for retrying failed requests with exponential backoff.
This feature can be enabled by setting the `retries` configuration for the `Google_Task_Runner` class: ~~~php $client = new Google_Client(); $client->setClassConfig('Google_Task_Runner', 'retries', 5); ~~~ Once `retries` is configured, the following error types will be retried by default: * Errors with a `500` or a `503` HTTP status code. * Errors with a `rateLimitExceeded` or a `userRateLimitExceeded` reason type. * cURL errors: * `CURLE_COULDNT_RESOLVE_HOST` * `CURLE_COULDNT_CONNECT` * `CURLE_OPERATION_TIMEOUTED` * `CURLE_SSL_CONNECT_ERROR` * `CURLE_GOT_NOTHING` These error types can be configured using the `retry_map` configurations for the `Google_IO_Exception` and `Google_Service_Exception` classes. The retry map is an associative array which maps errors types to the number of times each error can be retried (-1 can be used to retry an error indefinitely). For example: ~~~php $client = new Google_Client(); $client->setClassConfig( 'Google_Service_Exception', 'retry_map', array( // Don't retry 500 errors '500' => 0, // Retry 503 errors once '503' => 1, // Retry rate limit errors until we hit `retries` 'rateLimitExceeded' => -1, 'userRateLimitExceeded' => -1 ) ); ~~~ For convenience, `Google_Config` provides three constants for configuring retry limits: `Google_Config::TASK_RETRY_NEVER`, `Google_Config::TASK_RETRY_ONCE`, and `Google_Config::TASK_RETRY_ALWAYS`.
0 commit comments