lib/embulk/output/zendesk_users.rb in embulk-output-zendesk_users-0.0.3 vs lib/embulk/output/zendesk_users.rb in embulk-output-zendesk_users-0.0.4
- old
+ new
@@ -104,16 +104,28 @@
temp.store("user_fields", data["#{@user_fields_column}"]) if @user_fields_column
Embulk.logger.debug {"Uploading data: #{temp}"}
requests << temp
end
- job_status = @client.users.update_many!(requests)
-
+ begin
+ job_status = @client.users.update_many!(requests)
+ rescue ZendeskAPI::Error::NetworkError => e
+ Embulk.logger.warn {"#{e}"}
+ Embulk.logger.warn {"Retrying..."}
+ retry
+ end
+
# https://github.com/zendesk/zendesk_api_client_rb#apps-api
# Note: job statuses are currently not supported, so you must manually poll the job status API for app creation.
body = {}
until %w{failed completed}.include?(job_status['status'])
- response = @client.connection.get(job_status['url'])
+ begin
+ response = @client.connection.get(job_status['url'])
+ rescue ZendeskAPI::Error::NetworkError => e
+ Embulk.logger.warn {"#{e}"}
+ Embulk.logger.warn {"Retrying..."}
+ retry
+ end
job_status = response.body['job_status']
sleep(1)
end
job_status['results'].each do |result|