app/models/maestrano/connector/rails/concerns/entity.rb in maestrano-connector-rails-2.3.4 vs app/models/maestrano/connector/rails/concerns/entity.rb in maestrano-connector-rails-2.3.5

- old
+ new

@@ -463,11 +463,11 @@ # array_with_idmap must be an array of hashes with a key idmap # proc is a lambda to create a batch_op from an element of the array # Perform batch calls on Connec API and parse the response def batch_calls(array_with_idmap, proc, connec_entity_name, id_update_only = false) - request_per_call = @opts[:request_per_batch_call] || 100 + request_per_call = @opts[:request_per_batch_call] || 50 start = 0 while start < array_with_idmap.size # Prepare batch request batch_entities = array_with_idmap.slice(start, request_per_call) batch_request = {sequential: true, ops: []} @@ -477,11 +477,11 @@ end # Batch call log_info = id_update_only ? 'with only ids' : '' Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "Sending batch request to Connec! #{log_info} for #{self.class.normalize_connec_entity_name(connec_entity_name)}. Batch_request_size: #{batch_request[:ops].size}. Call_number: #{(start / request_per_call) + 1}") - response = @connec_client.batch(batch_request) + response = Retriable.with_context(:connec) { @connec_client.batch(batch_request) } Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Received batch response from Connec! for #{self.class.normalize_connec_entity_name(connec_entity_name)}: #{response}") raise "No data received from Connec! when trying to send batch request #{log_info} for #{self.class.connec_entity_name.pluralize}" unless response && response.body.present? response = JSON.parse(response.body) @@ -503,10 +503,10 @@ end end def fetch_connec(uri) Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Fetching data from connec entity=#{self.class.connec_entity_name}, url=#{uri}") - response = @connec_client.get(uri) + response = Retriable.with_context(:connec) { @connec_client.get(uri) } raise "No data received from Connec! when trying to fetch #{self.class.normalized_connec_entity_name}" unless response && response.body.present? response_hash = JSON.parse(response.body) Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Received response for entity=#{self.class.connec_entity_name}, response=#{response_hash}")