maestrano-connector-rails 2.3.4 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0794a88f0a65a6b53b28ab58e23fc0871ca6eaff
4
- data.tar.gz: 597c52ff1576e7231e2aa594e1c95e99481dcb0c
3
+ metadata.gz: 281bc1ff015d7a52fea1344faf8043cb24d0dff7
4
+ data.tar.gz: a0cea7d9c59defc98176b45b64909afe523a7aa1
5
5
  SHA512:
6
- metadata.gz: ef5fb1768878fa8eaac456858186a0e45c654d158a5209ba5fe935c76a959c3a104c7a1a0aa90a902f63f6b51fe28d4b72829a7002662f3cf659ef9b4924c91a
7
- data.tar.gz: 2165702acab307200051e02e90f12dceaa449fb3be9d2351c5be3af9f87fbb968a3cb7cf9949de78d73aa78b3be5c4db1ef75ee4a280be370c56128b160ce55b
6
+ metadata.gz: 0cee71417cd68c6cc2b620a5ece25bc5dee1877a8327d47d1e7433e364e2fff1fa8c5eae1dc07b910f109df394fcad53801f4c2c1e3dcb129acfeb2e3227d874
7
+ data.tar.gz: 4501102c4571eab87459e7f84fdcb5e538bf7522b5dba7704e1693f12ec029a2ca103f52dff4613f6641efd142a4e829dffb48ef6c26f3228de71623e213d8f3
@@ -8,6 +8,8 @@ Rails/ApplicationRecord:
8
8
  Enabled: false
9
9
 
10
10
  AllCops:
11
+ DisplayCopNames: true
12
+ DisplayStyleGuide: true
11
13
  TargetRubyVersion: 2.3
12
14
  Exclude:
13
15
  - 'maestrano-connector-rails.gemspec'
@@ -14,7 +14,7 @@ Lint/AssignmentInCondition:
14
14
 
15
15
  # Offense count: 28
16
16
  Metrics/AbcSize:
17
- Max: 69
17
+ Max: 70
18
18
 
19
19
  # Offense count: 1
20
20
  # Configuration parameters: CountComments.
@@ -1,5 +1,17 @@
1
- ## 2.3.4
2
- - Fix gemfile template to remove test/dev gems from the production group
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
- active_organizations = Maestrano::Connector::Rails::Organization
8
- .where.not(oauth_provider: nil, encrypted_oauth_token: nil)
9
- .select { |o| [true, 1].include?(o.sync_enabled) }
10
-
11
- return true if active_organizations.count.zero?
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] || 100
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
@@ -1,4 +1,5 @@
1
1
  require 'maestrano-rails'
2
+ require 'retriable'
2
3
 
3
4
  require 'haml-rails'
4
5
  require 'bootstrap-sass'
@@ -1,7 +1,7 @@
1
1
  module Maestrano
2
2
  module Connector
3
3
  module Rails
4
- VERSION = '2.3.4'.freeze
4
+ VERSION = '2.3.5'.freeze
5
5
  end
6
6
  end
7
7
  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
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-10-04 00:00:00.000000000 Z
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