@@ -94,7 +94,7 @@ def recover_notification_key(key_name, project_id)
94
94
notification_key_name : key_name
95
95
}
96
96
}
97
-
97
+
98
98
extra_headers = {
99
99
'project_id' => project_id
100
100
}
@@ -144,7 +144,7 @@ def get_instance_id_info iid_token, options={}
144
144
params = {
145
145
query : options
146
146
}
147
-
147
+
148
148
for_uri ( INSTANCE_ID_API ) do |connection |
149
149
response = connection . get ( '/iid/info/' +iid_token , params )
150
150
build_response ( response )
@@ -177,7 +177,14 @@ def send_to_topic_condition(condition, options = {})
177
177
private
178
178
179
179
def for_uri ( uri , extra_headers = { } )
180
+ retryable_exceptions = Faraday ::Request ::Retry ::DEFAULT_EXCEPTIONS +[ ServerError ]
180
181
connection = ::Faraday . new ( :url => uri ) do |faraday |
182
+ faraday . request :retry , max : 5 , interval : 0.1 , interval_randomness : 0.5 , backoff_factor : 2 ,
183
+ exceptions : retryable_exceptions , retry_statuses : [ 200 ] , methods : [ ] ,
184
+ retry_if : Proc . new do |env , exception |
185
+ return true unless exception . is_a? ( Faraday ::RetriableResponse )
186
+ return true if exception . response . body [ :results ] . any? { |result | result [ :error ] == "Unavailable" }
187
+ end
181
188
faraday . adapter Faraday . default_adapter
182
189
faraday . headers [ "Content-Type" ] = "application/json"
183
190
faraday . headers [ "Authorization" ] = "key=#{ api_key } "
0 commit comments