maestrano-connector-rails 2.3.4 → 2.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +14 -2
- data/app/jobs/maestrano/connector/rails/all_synchronizations_job.rb +6 -9
- data/app/models/maestrano/connector/rails/concerns/entity.rb +3 -3
- data/config/initializers/retriable.rb +14 -0
- data/lib/generators/connector/install_generator.rb +5 -0
- data/lib/maestrano/connector/rails.rb +1 -0
- data/lib/maestrano/connector/rails/version.rb +1 -1
- data/maestrano-connector-rails.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 281bc1ff015d7a52fea1344faf8043cb24d0dff7
|
4
|
+
data.tar.gz: a0cea7d9c59defc98176b45b64909afe523a7aa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cee71417cd68c6cc2b620a5ece25bc5dee1877a8327d47d1e7433e364e2fff1fa8c5eae1dc07b910f109df394fcad53801f4c2c1e3dcb129acfeb2e3227d874
|
7
|
+
data.tar.gz: 4501102c4571eab87459e7f84fdcb5e538bf7522b5dba7704e1693f12ec029a2ca103f52dff4613f6641efd142a4e829dffb48ef6c26f3228de71623e213d8f3
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
|
-
##
|
2
|
-
|
1
|
+
## [v2.3.5](https://github.com/maestrano/maestrano-connector-rails/tree/v2.3.5) (2018-11-02)
|
2
|
+
[Full Changelog](https://github.com/maestrano/maestrano-connector-rails/compare/v2.3.4...v2.3.5)
|
3
|
+
|
4
|
+
**Fixed bugs:**
|
5
|
+
|
6
|
+
- \[APPINT-1323\] Retry call to Connec! [\#180](https://github.com/maestrano/maestrano-connector-rails/pull/180) ([ouranos](https://github.com/ouranos))
|
7
|
+
- \[APPINT-1205\] Fix cron jobs & cleanup template [\#179](https://github.com/maestrano/maestrano-connector-rails/pull/179) ([ouranos](https://github.com/ouranos))
|
8
|
+
|
9
|
+
## [v2.3.4](https://github.com/maestrano/maestrano-connector-rails/tree/v2.3.4) (2018-10-04)
|
10
|
+
[Full Changelog](https://github.com/maestrano/maestrano-connector-rails/compare/v2.3.3...v2.3.4)
|
11
|
+
|
12
|
+
**Fixed bugs:**
|
13
|
+
|
14
|
+
- Fix Gemfile template [\#178](https://github.com/maestrano/maestrano-connector-rails/pull/178) ([ouranos](https://github.com/ouranos))
|
3
15
|
|
4
16
|
## 2.3.3
|
5
17
|
|
@@ -4,15 +4,12 @@ module Maestrano::Connector::Rails
|
|
4
4
|
|
5
5
|
# Trigger synchronization of all active organizations
|
6
6
|
def perform(name = nil, count = nil)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
time_span_seconds = (3600 / active_organizations.count).to_i
|
14
|
-
active_organizations.each_with_index do |organization, i|
|
15
|
-
Maestrano::Connector::Rails::SynchronizationJob.set(wait: time_span_seconds * i).perform_later(organization.id, {})
|
7
|
+
Maestrano::Connector::Rails::Organization
|
8
|
+
.where.not(oauth_provider: nil, encrypted_oauth_token: nil)
|
9
|
+
.where(sync_enabled: true)
|
10
|
+
.select(:id)
|
11
|
+
.find_each do |organization|
|
12
|
+
Maestrano::Connector::Rails::SynchronizationJob.set(wait: rand(3600)).perform_later(organization.id, {})
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
@@ -465,7 +465,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
465
465
|
# proc is a lambda to create a batch_op from an element of the array
|
466
466
|
# Perform batch calls on Connec API and parse the response
|
467
467
|
def batch_calls(array_with_idmap, proc, connec_entity_name, id_update_only = false)
|
468
|
-
request_per_call = @opts[:request_per_batch_call] ||
|
468
|
+
request_per_call = @opts[:request_per_batch_call] || 50
|
469
469
|
start = 0
|
470
470
|
while start < array_with_idmap.size
|
471
471
|
# Prepare batch request
|
@@ -479,7 +479,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
479
479
|
# Batch call
|
480
480
|
log_info = id_update_only ? 'with only ids' : ''
|
481
481
|
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}")
|
482
|
-
response = @connec_client.batch(batch_request)
|
482
|
+
response = Retriable.with_context(:connec) { @connec_client.batch(batch_request) }
|
483
483
|
Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Received batch response from Connec! for #{self.class.normalize_connec_entity_name(connec_entity_name)}: #{response}")
|
484
484
|
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?
|
485
485
|
|
@@ -505,7 +505,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
505
505
|
|
506
506
|
def fetch_connec(uri)
|
507
507
|
Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Fetching data from connec entity=#{self.class.connec_entity_name}, url=#{uri}")
|
508
|
-
response = @connec_client.get(uri)
|
508
|
+
response = Retriable.with_context(:connec) { @connec_client.get(uri) }
|
509
509
|
|
510
510
|
raise "No data received from Connec! when trying to fetch #{self.class.normalized_connec_entity_name}" unless response && response.body.present?
|
511
511
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
CONNEC_RETRIABLE_ERRORS = [Net::OpenTimeout, Net::ReadTimeout].freeze
|
4
|
+
|
5
|
+
Retriable.configure do |c|
|
6
|
+
c.tries = 3
|
7
|
+
|
8
|
+
c.contexts[:connec] = {
|
9
|
+
on: CONNEC_RETRIABLE_ERRORS,
|
10
|
+
on_retry: proc do |exception, try, elapsed_time, next_interval|
|
11
|
+
Rails.logger.info "Connec! error - #{exception.class}: '#{exception.message}' - #{try} tries in #{elapsed_time} seconds and #{next_interval} seconds until the next try."
|
12
|
+
end
|
13
|
+
}
|
14
|
+
end
|
@@ -71,5 +71,10 @@ module Connector
|
|
71
71
|
def copy_oauth_controller
|
72
72
|
copy_file 'oauth_controller.rb', 'app/controllers/oauth_controller.rb'
|
73
73
|
end
|
74
|
+
|
75
|
+
def cleanup
|
76
|
+
# The connector framework already provide a working implementation of this controller
|
77
|
+
remove_file 'app/controllers/maestrano/account/groups_controller.rb'
|
78
|
+
end
|
74
79
|
end
|
75
80
|
end
|
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.add_runtime_dependency('hash_mapper', '>= 0.2.2')
|
38
38
|
s.add_runtime_dependency('pundit')
|
39
39
|
s.add_runtime_dependency('pundit-resources')
|
40
|
+
s.add_runtime_dependency('retriable', '~> 3.1.2')
|
40
41
|
s.add_runtime_dependency('sidekiq', '~> 4.2.9')
|
41
42
|
s.add_runtime_dependency('sidekiq-cron')
|
42
43
|
s.add_runtime_dependency('sidekiq-unique-jobs')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maestrano-connector-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maestrano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: retriable
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 3.1.2
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 3.1.2
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: sidekiq
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -487,6 +501,7 @@ files:
|
|
487
501
|
- app/resources/maestrano/api/synchronization_resource.rb
|
488
502
|
- app/resources/maestrano/api/user_resource.rb
|
489
503
|
- config/initializers/json_api.rb
|
504
|
+
- config/initializers/retriable.rb
|
490
505
|
- config/routes.rb
|
491
506
|
- db/migrate/20151122162100_create_users.rb
|
492
507
|
- db/migrate/20151122162414_create_organizations.rb
|