zuora_connect 1.7.711 → 1.7.791

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: 6a1133f6da135108cf5eb1d4794c7d16637c71e2
4
- data.tar.gz: e559213443b6098369b2585c2ee1131fe95632cf
3
+ metadata.gz: 753cf6136eba70f94335ed9c9cf6f80475208594
4
+ data.tar.gz: 1e26f0d293399f118f12c85b8dd3120d2ce478d8
5
5
  SHA512:
6
- metadata.gz: 47f5968069e7fb52a50bfcf0c580208ea4683db2645afdd406ebd22eee42a1b7e9c64c38295e337a0e8abb0d68185a08999a4565ea2890875d985f16a2a50127
7
- data.tar.gz: 7a1052be676f123fd7a8c909cff03599b81c24527aff5412e7080ca6bdfe768173b577e5662d2e273fc02e35ddf88e2c08266c56b35c028a8c63ca9cdce8eb06
6
+ metadata.gz: 61bd48c5799396cedbf7ca97566efbef0ef1ad3830b57a0cf84a2e1622d3aa9dbf5fbf6cee2ab304dc8c6a1bc56c7a82ff992178666826bf30ea6c98b9a9c781
7
+ data.tar.gz: 72a60a7926f075aac8163a822fdb771a01132bf527dbb7a1f93985fa96b2aced41eb56fce81e02f0b988e8b89b811bdb4f167cf8aca744c88da76a20bbe0bdd0
@@ -1,10 +1,10 @@
1
1
  module ZuoraConnect
2
2
  class StaticController < ApplicationController
3
- before_filter :authenticate_connect_app_request, :except => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
4
- before_filter :clear_connect_app_session, :only => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
5
- after_filter :persist_connect_app_session, :except => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
3
+ before_action :authenticate_connect_app_request, :except => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
4
+ before_action :clear_connect_app_session, :only => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
5
+ after_action :persist_connect_app_session, :except => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
6
6
 
7
- skip_before_filter :verify_authenticity_token, :only => [:initialize_app]
7
+ skip_before_action :verify_authenticity_token, :only => [:initialize_app]
8
8
 
9
9
  def session_error
10
10
  respond_to do |format|
@@ -4,6 +4,7 @@ module ZuoraConnect
4
4
  default_scope {select(ZuoraConnect::AppInstance.column_names.delete_if {|x| ["catalog_mapping", "catalog"].include?(x) }) }
5
5
  after_initialize :init
6
6
  after_create :initialize_redis_placeholder
7
+ before_destroy :prune_data
7
8
 
8
9
  self.table_name = "zuora_connect_app_instances"
9
10
  attr_accessor :options, :mode, :logins, :task_data, :last_refresh, :username, :password, :s3_client, :api_version, :drop_message, :new_session_message, :connect_user, :logitems
@@ -39,6 +40,7 @@ module ZuoraConnect
39
40
 
40
41
  def initialize_redis_placeholder
41
42
  if defined?(Redis.current)
43
+ Redis.current.zrem("AppInstance:Deleted", id)
42
44
  Redis.current.zadd("APILimits", 9999999999, "placeholder")
43
45
  Redis.current.zadd("InstanceRefreshing", 9999999999, "placeholder")
44
46
  end
@@ -47,18 +49,39 @@ module ZuoraConnect
47
49
  end
48
50
  end
49
51
 
52
+ def prune_data(id: self.id)
53
+ if defined?(Redis.current)
54
+ Redis.current.zadd("AppInstance:Deleted", Time.now.to_i, id)
55
+ Redis.current.del("AppInstance:#{id}")
56
+ Redis.current.zrem("APILimits", id)
57
+ Redis.current.zrem("InstanceRefreshing", id)
58
+ end
59
+ if defined?(Resque.redis)
60
+ Resque.redis.zrem("PauseQueue", id)
61
+ end
62
+ return true
63
+ end
64
+
50
65
  def apartment_switch(method = nil, migrate = false)
51
- begin
52
- Apartment::Tenant.switch!(self.id) if self.persisted?
53
- rescue Apartment::TenantNotFound => ex
66
+ switch_count ||= 0
67
+ if self.persisted?
54
68
  begin
55
- Apartment::Tenant.create(self.id.to_s)
56
- rescue Apartment::TenantExists => ex
69
+ Apartment::Tenant.switch!(self.id)
70
+ rescue Apartment::TenantNotFound => ex
71
+ sleep(2)
72
+ begin
73
+ Apartment::Tenant.create(self.id.to_s)
74
+ rescue Apartment::TenantExists => ex
75
+ end
76
+ if (switch_count += 1) < 2
77
+ retry
78
+ else
79
+ raise
80
+ end
81
+ end
82
+ if migrate && ActiveRecord::Migrator.needs_migration?
83
+ Apartment::Migrator.migrate(self.id)
57
84
  end
58
- retry
59
- end
60
- if migrate && ActiveRecord::Migrator.needs_migration?
61
- Apartment::Migrator.migrate(self.id)
62
85
  end
63
86
  Thread.current[:appinstance] = self
64
87
  end
@@ -0,0 +1,24 @@
1
+ if defined?(ElasticAPM)
2
+ ElasticAPM.agent.config.disable_send = true
3
+ if ZuoraConnect.configuration.enable_apm && !defined?(Rails::Console)
4
+ #require 'elastic_apm'
5
+ case Rails.env.to_s
6
+ when 'production'
7
+ ElasticAPM.agent.config.server_url = "http://apm-server.logging:8200"
8
+ ElasticAPM.agent.config.transaction_sample_rate = 0.20
9
+ ElasticAPM.agent.config.capture_body = false
10
+ when 'staging'
11
+ ElasticAPM.agent.config.server_url = "http://apm-server.logging:8200"
12
+ ElasticAPM.agent.config.transaction_sample_rate = 1.0
13
+ when 'development'
14
+ ElasticAPM.agent.config.server_url = "http://logging.0.ecc.auw2.zuora:8200"
15
+ ElasticAPM.agent.config.transaction_sample_rate = 1.0
16
+ end
17
+ ElasticAPM.agent.config.pool_size = 1
18
+ ElasticAPM.agent.config.transaction_max_spans = 500
19
+ ElasticAPM.agent.config.ignore_url_patterns = ['^\/admin\/resque.*', '^\/admin\/redis.*', '^\/admin\/peek.*', '^\/peek.*']
20
+ ElasticAPM.agent.config.verify_server_cert = false
21
+ ElasticAPM.agent.config.log_level = Logger::INFO
22
+ ElasticAPM.agent.config.disable_send = false
23
+ end
24
+ end
@@ -1,9 +1,9 @@
1
1
  redis_url = ENV["REDIS_URL"].present? ? ENV["REDIS_URL"] : defined?(Rails.application.secrets.redis) ? Rails.application.secrets.redis : 'redis://localhost:6379/1'
2
2
  resque_url = ENV["RESQUE_URL"].present? ? ENV["RESQUE_URL"] : defined?(Rails.application.secrets.resque) ? Rails.application.secrets.resque : 'redis://localhost:6379/1'
3
3
  if defined?(Redis.current)
4
- Redis.current = Redis.new(:id => "#{ZuoraConnect::Telegraf.full_process_name(process_name: 'Redis')}", :url => redis_url, :timeout => 10, :reconnect_attempts => 2)
4
+ Redis.current = Redis.new(:id => "#{ZuoraConnect::Telegraf.full_process_name(process_name: 'Redis')}", :url => redis_url, :timeout => 6, :reconnect_attempts => 2)
5
5
  if defined?(Resque.redis)
6
- Resque.redis = resque_url != redis_url ? Redis.new(:id => "#{ZuoraConnect::Telegraf.full_process_name(process_name: 'Resque')}", :url => resque_url, :timeout => 10, :reconnect_attempts => 2) : Redis.current
6
+ Resque.redis = resque_url != redis_url ? Redis.new(:id => "#{ZuoraConnect::Telegraf.full_process_name(process_name: 'Resque')}", :url => resque_url, :timeout => 6, :reconnect_attempts => 2) : Redis.current
7
7
  end
8
8
  end
9
9
  if defined?(RedisBrowser)
@@ -1,4 +1,4 @@
1
- class CreateConnectAppInstances < ActiveRecord::Migration[4.2]
1
+ class CreateConnectAppInstances < ActiveRecord::Migration
2
2
  def change
3
3
  if !ActiveRecord::Base.connection.table_exists?('zuora_connect_app_instances')
4
4
  create_table :zuora_connect_app_instances do |t|
@@ -1,4 +1,4 @@
1
- class AddTokensToAppInstance < ActiveRecord::Migration[4.2]
1
+ class AddTokensToAppInstance < ActiveRecord::Migration
2
2
  def change
3
3
  add_column :zuora_connect_app_instances, :access_token, :string unless column_exists? :zuora_connect_app_instances, :access_token
4
4
  add_column :zuora_connect_app_instances, :refresh_token, :string unless column_exists? :zuora_connect_app_instances, :refresh_token
@@ -1,4 +1,4 @@
1
- class AddTokenToAppInstance < ActiveRecord::Migration[4.2]
1
+ class AddTokenToAppInstance < ActiveRecord::Migration
2
2
  def change
3
3
  add_column :zuora_connect_app_instances, :token, :string unless column_exists? :zuora_connect_app_instances, :token
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddSessionsTable < ActiveRecord::Migration[4.2]
1
+ class AddSessionsTable < ActiveRecord::Migration
2
2
  def change
3
3
  if !ActiveRecord::Base.connection.table_exists?('sessions')
4
4
  create_table :sessions do |t|
@@ -1,4 +1,4 @@
1
- class AddExpirationToAppInstance < ActiveRecord::Migration[4.2]
1
+ class AddExpirationToAppInstance < ActiveRecord::Migration
2
2
  def change
3
3
  add_column :zuora_connect_app_instances, :oauth_expires_at, :datetime unless column_exists? :zuora_connect_app_instances, :oauth_expires_at
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddNewApiToken < ActiveRecord::Migration[4.2]
1
+ class AddNewApiToken < ActiveRecord::Migration
2
2
  def change
3
3
  add_column :zuora_connect_app_instances, :api_token, :string unless column_exists? :zuora_connect_app_instances, :api_token
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddCatalogDataToAppInstance < ActiveRecord::Migration[4.2]
1
+ class AddCatalogDataToAppInstance < ActiveRecord::Migration
2
2
  def change
3
3
  add_column :zuora_connect_app_instances, :catalog_updated_at, :datetime unless column_exists? :zuora_connect_app_instances, :catalog_updated_at
4
4
  add_column :zuora_connect_app_instances, :catalog, :jsonb, default: {} unless column_exists? :zuora_connect_app_instances, :catalog
@@ -1,4 +1,4 @@
1
- class AddCatalogMappingsToAppInstance < ActiveRecord::Migration[4.2]
1
+ class AddCatalogMappingsToAppInstance < ActiveRecord::Migration
2
2
  def change
3
3
  add_column :zuora_connect_app_instances, :catalog_mapping, :jsonb, default: {} unless column_exists? :zuora_connect_app_instances, :catalog_mapping
4
4
  end
@@ -1,4 +1,4 @@
1
- class CatalogDefault < ActiveRecord::Migration[4.2]
1
+ class CatalogDefault < ActiveRecord::Migration
2
2
  def change
3
3
  change_column :zuora_connect_app_instances, :catalog, :jsonb, default: {}
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddCatalogAttemptedAt < ActiveRecord::Migration[4.2]
1
+ class AddCatalogAttemptedAt < ActiveRecord::Migration
2
2
  def change
3
3
  add_column :zuora_connect_app_instances, :catalog_update_attempt_at, :datetime unless column_exists? :zuora_connect_app_instances, :catalog_update_attempt_at
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddFieldsToInstance < ActiveRecord::Migration[4.2]
1
+ class AddFieldsToInstance < ActiveRecord::Migration
2
2
  def change
3
3
  add_column :zuora_connect_app_instances, :name, :string, default: "" unless column_exists? :zuora_connect_app_instances, :name
4
4
  end
@@ -3,13 +3,6 @@
3
3
  #
4
4
  # Monologger supports printing logs in trap block.
5
5
  #
6
- # Usage:
7
- # require 'resque/plugins/custom_logger'
8
- # class ExecuteWorkflowJob
9
- # extend Resque::Plugins::CustomLogger
10
- # ...
11
- # end
12
-
13
6
  module Resque
14
7
  module Plugins
15
8
  module CustomLogger
@@ -36,8 +29,17 @@ module Resque
36
29
 
37
30
  Resque.logger = logger
38
31
  Rails.logger = logger
39
-
40
- Rails.logger.info(args.to_json) if args.present?
32
+ case args.class.to_s
33
+ when "Array"
34
+ if args.first.class == Hash
35
+ data = args.first.merge({:worker_class => self.to_s})
36
+ else
37
+ data = {:worker_class => self.to_s, :args => args}
38
+ end
39
+ when "Hash"
40
+ data = args.merge({:worker_class => self.to_s})
41
+ end
42
+ Rails.logger.info(data.to_json) if data.present?
41
43
  end
42
44
  end
43
45
  end
@@ -3,7 +3,7 @@ module ZuoraConnect
3
3
 
4
4
  attr_accessor :default_locale, :default_time_zone, :url, :mode, :delayed_job,:private_key, :additional_apartment_models
5
5
 
6
- attr_accessor :enable_metrics, :telegraf_endpoint, :telegraf_debug, :custom_prometheus_update_block, :silencer_resque_finish, :blpop_queue
6
+ attr_accessor :enable_metrics, :enable_apm, :telegraf_endpoint, :telegraf_debug, :custom_prometheus_update_block, :silencer_resque_finish, :blpop_queue
7
7
 
8
8
  attr_accessor :oauth_client_id, :oauth_client_secret, :oauth_client_redirect_uri
9
9
 
@@ -24,7 +24,7 @@ module ZuoraConnect
24
24
  @enable_metrics = false
25
25
  @telegraf_endpoint = 'udp://telegraf-app-metrics.monitoring.svc.cluster.local:8094'
26
26
  @telegraf_debug = false
27
-
27
+ @enable_apm = false
28
28
  # OAuth Settings
29
29
  @oauth_client_id = ""
30
30
  @oauth_client_secret = ""
@@ -15,7 +15,7 @@ module ZuoraConnect
15
15
  end
16
16
  end
17
17
 
18
- initializer :append_migrations do |app|
18
+ initializer :append_migrations do |app|
19
19
  unless app.root.to_s.match root.to_s
20
20
  config.paths["db/migrate"].expanded.each do |expanded_path|
21
21
  app.config.paths["db/migrate"] << expanded_path
@@ -28,10 +28,5 @@ module ZuoraConnect
28
28
  include ZuoraConnect::Controllers::Helpers
29
29
  end
30
30
  end
31
-
32
- initializer :append_migrations do |app|
33
- next if app.root.to_s.start_with?(root.to_s) # only run when called from other apps
34
- app.config.paths['db/migrate'].concat(config.paths['db/migrate'].expanded)
35
- end
36
31
  end
37
32
  end
@@ -29,7 +29,7 @@ module ZuoraConnect
29
29
  ActiveSupport::Notifications.subscribe('process_action.action_controller', Middleware::PageRequest.new)
30
30
 
31
31
  initializer(:rails_stdout_logging, before: :initialize_logger) do
32
- if true || Rails.env != 'development' && !ENV['DEIS_APP'].blank?
32
+ if Rails.env != 'development' && !ENV['DEIS_APP'].blank?
33
33
  require 'lograge'
34
34
  logger = ActiveSupport::Logger.new(STDOUT)
35
35
  logger.formatter = ::Logger::Formatter.new
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.7.711"
2
+ VERSION = "1.7.791"
3
3
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.711
4
+ version: 1.7.791
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-01 00:00:00.000000000 Z
11
+ date: 2019-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.2'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 1.2.0
19
+ version: '0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '1.2'
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
- version: 1.2.0
26
+ version: '0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: zuora_api
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,14 +50,40 @@ dependencies:
56
50
  requirements:
57
51
  - - "~>"
58
52
  - !ruby/object:Gem::Version
59
- version: 0.14.0
53
+ version: 0.16.4
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.16.4
60
57
  type: :runtime
61
58
  prerelease: false
62
59
  version_requirements: !ruby/object:Gem::Requirement
63
60
  requirements:
64
61
  - - "~>"
65
62
  - !ruby/object:Gem::Version
66
- version: 0.14.0
63
+ version: 0.16.4
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.16.4
67
+ - !ruby/object:Gem::Dependency
68
+ name: elastic-apm
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: 2.5.0
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 2.5.0
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 2.5.0
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 2.5.0
67
87
  - !ruby/object:Gem::Dependency
68
88
  name: bundler
69
89
  requirement: !ruby/object:Gem::Requirement
@@ -285,6 +305,7 @@ files:
285
305
  - app/views/zuora_connect/static/session_error.html.erb
286
306
  - config/initializers/apartment.rb
287
307
  - config/initializers/aws.rb
308
+ - config/initializers/elastic_apm.rb
288
309
  - config/initializers/object_method_hooks.rb
289
310
  - config/initializers/postgresql_adapter.rb
290
311
  - config/initializers/prometheus.rb