lib/google/cloud/bigquery/service.rb in google-cloud-bigquery-1.28.0 vs lib/google/cloud/bigquery/service.rb in google-cloud-bigquery-1.29.0
- old
+ new
@@ -481,11 +481,11 @@
project_id: m["prj"],
dataset_id: m["dts"],
table_id: m["tbl"]
}.delete_if { |_, v| v.nil? }
str_table_ref_hash = default_ref.to_h.merge str_table_ref_hash
- ref = Google::Apis::BigqueryV2::TableReference.new str_table_ref_hash
+ ref = Google::Apis::BigqueryV2::TableReference.new(**str_table_ref_hash)
validate_table_ref ref
ref
end
def self.validate_table_ref table_ref
@@ -552,13 +552,13 @@
mime_type.content_type
rescue StandardError
nil
end
- def execute backoff: nil
+ def execute backoff: nil, &block
if backoff
- Backoff.new(retries: retries).execute { yield }
+ Backoff.new(retries: retries).execute(&block)
else
yield
end
rescue Google::Apis::Error => e
raise Google::Cloud::Error.from_error e
@@ -588,25 +588,23 @@
end
def execute
current_retries = 0
loop do
- begin
- return yield
- rescue Google::Apis::Error => e
- raise e unless retry? e.body, current_retries
+ return yield
+ rescue Google::Apis::Error => e
+ raise e unless retry? e.body, current_retries
- @backoff.call current_retries
- current_retries += 1
- end
+ @backoff.call current_retries
+ current_retries += 1
end
end
protected
def retry? result, current_retries #:nodoc:
- if current_retries < @retries
- return true if retry_error_reason? result
+ if current_retries < @retries && retry_error_reason?(result)
+ return true
end
false
end
def retry_error_reason? err_body