Class: Gcloud::Backoff

Inherits:
Object
  • Object
show all
Defined in:
lib/gcloud/backoff.rb

Overview

Backoff allows users to control how Google API calls are retried. If an API call fails the response will be checked to see if the call can be retried. If the response matches the criteria, then it will be retried with an incremental backoff. This means that an increasing delay will be added between each retried call. The first retry will be delayed one second, the second retry will be delayed two seconds, and so on.

require "gcloud/backoff"

Gcloud::Backoff.retries = 5 # Set a maximum of five retries per call

Class Attribute Summary collapse

Class Attribute Details

.backoffObject

The code to run when a backoff is handled. This must be a Proc and must take the number of retries as an argument.

Note: This method is undocumented and may change.


56
57
58
# File 'lib/gcloud/backoff.rb', line 56

def backoff
  @backoff
end

.http_codesObject

The HTTP Status Codes that should be retried.

The default values are 500 and 503.


41
42
43
# File 'lib/gcloud/backoff.rb', line 41

def http_codes
  @http_codes
end

.reasonsObject

The Google API error reasons that should be retried.

The default values are rateLimitExceeded and userRateLimitExceeded.


48
49
50
# File 'lib/gcloud/backoff.rb', line 48

def reasons
  @reasons
end

.retriesObject

The number of times a retriable API call should be retried.

The default value is 3.


35
36
37
# File 'lib/gcloud/backoff.rb', line 35

def retries
  @retries
end