zuora_connect 1.7.07 → 1.7.08
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/zuora_connect/app_instance_base.rb +25 -22
- data/lib/zuora_connect/railtie.rb +11 -3
- data/lib/zuora_connect/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5f73ba41b420d1b552236557a910cadb74a0f29
|
4
|
+
data.tar.gz: a32115c1a42f2774bbb030eeacc5480f0afcc0f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e65354cd51cfa0a818a9979a45b217d2535131b1739e15753882db63340f106ec582dc023e865221985746f99b16c725f203b1cdeb08942f6b3ae580d2a5e957
|
7
|
+
data.tar.gz: d7c556be08e52be64a65f3f9a9ceb9dd95c7a60790076b6de46dfedfe28132efce0d2b45d239c4b4d62da1a9212fd4615b9b095990e966429d37206c00f2a344
|
@@ -4,7 +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
|
self.table_name = "zuora_connect_app_instances"
|
7
|
-
attr_accessor :options, :mode, :logins, :task_data, :last_refresh, :username, :password, :s3_client, :api_version, :drop_message
|
7
|
+
attr_accessor :options, :mode, :logins, :task_data, :last_refresh, :username, :password, :s3_client, :api_version, :drop_message, :new_session_message, :connect_user
|
8
8
|
@@telegraf_host = nil
|
9
9
|
REFRESH_TIMEOUT = 2.minute #Used to determine how long to wait on current refresh call before executing another
|
10
10
|
INSTANCE_REFRESH_WINDOW = 1.hours #Used to set how how long till app starts attempting to refresh cached task connect data
|
@@ -13,9 +13,10 @@ module ZuoraConnect
|
|
13
13
|
BLANK_OBJECT_ID_LOOKUP = 'BlankValueSupplied'
|
14
14
|
|
15
15
|
def init
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
self.connect_user = 'Nobody'
|
17
|
+
self.options = Hash.new
|
18
|
+
self.logins = Hash.new
|
19
|
+
self.api_version = "v2"
|
19
20
|
self.attr_builder("timezone", ZuoraConnect.configuration.default_time_zone)
|
20
21
|
self.attr_builder("locale", ZuoraConnect.configuration.default_locale)
|
21
22
|
PaperTrail.whodunnit = "Backend" if defined?(PaperTrail)
|
@@ -38,11 +39,13 @@ module ZuoraConnect
|
|
38
39
|
Thread.current[:appinstance] = self
|
39
40
|
end
|
40
41
|
|
41
|
-
def new_session(session: self.data_lookup, username: self.access_token, password: self.refresh_token, holding_pattern: false, log_level: Logger::
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
def new_session(session: self.data_lookup, username: self.access_token, password: self.refresh_token, holding_pattern: false, log_level: Logger::DEBUG)
|
43
|
+
self.api_version = "v2"
|
44
|
+
self.username = username
|
45
|
+
self.password = password
|
46
|
+
self.last_refresh = session["#{self.id}::last_refresh"]
|
47
|
+
self.connect_user = session["#{self.id}::user::email"]
|
48
|
+
PaperTrail.whodunnit = self.connect_user if defined?(PaperTrail)
|
46
49
|
|
47
50
|
## DEV MODE TASK DATA MOCKUP
|
48
51
|
if ZuoraConnect.configuration.mode != "Production"
|
@@ -52,7 +55,7 @@ module ZuoraConnect
|
|
52
55
|
|
53
56
|
case ZuoraConnect.configuration.dev_mode_options.class
|
54
57
|
when Hash
|
55
|
-
|
58
|
+
self.options = ZuoraConnect.configuration.dev_mode_options
|
56
59
|
when Array
|
57
60
|
mock_task_data["options"] = ZuoraConnect.configuration.dev_mode_options
|
58
61
|
end
|
@@ -67,34 +70,34 @@ module ZuoraConnect
|
|
67
70
|
time_expire = (session["#{self.id}::last_refresh"] || Time.now).to_i - INSTANCE_REFRESH_WINDOW.ago.to_i
|
68
71
|
|
69
72
|
if session.empty?
|
70
|
-
|
73
|
+
self.new_session_message = "REFRESHING - Session Empty"
|
71
74
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
72
75
|
self.refresh(session)
|
73
76
|
|
74
77
|
elsif (self.id != session["appInstance"].to_i)
|
75
|
-
|
78
|
+
self.new_session_message = "REFRESHING - AppInstance ID(#{self.id}) does not match session id(#{session["appInstance"].to_i})"
|
76
79
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
77
80
|
self.refresh(session)
|
78
81
|
|
79
82
|
elsif session["#{self.id}::task_data"].blank?
|
80
|
-
|
83
|
+
self.new_session_message = "REFRESHING - Task Data Blank"
|
81
84
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
82
85
|
self.refresh(session)
|
83
86
|
|
84
87
|
elsif session["#{self.id}::last_refresh"].blank?
|
85
|
-
|
88
|
+
self.new_session_message = "REFRESHING - No Time on Cookie"
|
86
89
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
87
90
|
self.refresh(session)
|
88
91
|
|
89
92
|
# If the cache is expired and we can aquire a refresh lock
|
90
93
|
elsif (session["#{self.id}::last_refresh"].to_i < INSTANCE_REFRESH_WINDOW.ago.to_i) && self.mark_for_refresh
|
91
|
-
|
94
|
+
self.new_session_message = "REFRESHING - Session Old by #{time_expire.abs} second"
|
92
95
|
self.refresh(session)
|
93
96
|
else
|
94
97
|
if time_expire < 0
|
95
|
-
|
98
|
+
self.new_session_message = ["REBUILDING - Expired by #{time_expire} seconds", self.marked_for_refresh? ? " cache updating as of #{self.reset_mark_refreshed_at} seconds ago" : nil].compact.join(',')
|
96
99
|
else
|
97
|
-
|
100
|
+
self.new_session_message = "REBUILDING - Expires in #{time_expire} seconds"
|
98
101
|
end
|
99
102
|
self.build_task(task_data: session["#{self.id}::task_data"], session: session)
|
100
103
|
end
|
@@ -108,12 +111,15 @@ module ZuoraConnect
|
|
108
111
|
return self
|
109
112
|
rescue ZuoraConnect::Exceptions::HoldingPattern => ex
|
110
113
|
while self.marked_for_refresh?
|
111
|
-
Rails.logger.add(log_level, "
|
114
|
+
Rails.logger.add(log_level, "Holding - Expires in #{self.reset_mark_expires_at}")
|
112
115
|
sleep(5)
|
113
116
|
end
|
114
117
|
self.reload_attributes([:refresh_token, :oauth_expires_at, :access_token])
|
115
118
|
session = self.data_lookup(session: session)
|
116
119
|
retry
|
120
|
+
|
121
|
+
ensure
|
122
|
+
Rails.logger.add(log_level, self.new_session_message)
|
117
123
|
end
|
118
124
|
|
119
125
|
def refresh(session = nil)
|
@@ -358,9 +364,6 @@ module ZuoraConnect
|
|
358
364
|
end
|
359
365
|
|
360
366
|
def data_lookup(session: {})
|
361
|
-
if defined?(PaperTrail)
|
362
|
-
PaperTrail.whodunnit = session["#{self.id}::user::email"].present? ? session["#{self.id}::user::email"] : nil if session.present?
|
363
|
-
end
|
364
367
|
if defined?(Redis.current)
|
365
368
|
cached_instance = Redis.current.get("AppInstance:#{self.id}")
|
366
369
|
if cached_instance.blank?
|
@@ -368,7 +371,7 @@ module ZuoraConnect
|
|
368
371
|
return session
|
369
372
|
else
|
370
373
|
Rails.logger.debug("[#{self.id}] Cached AppInstance Found")
|
371
|
-
return decrypt_data(data: cached_instance, rescue_return: session)
|
374
|
+
return decrypt_data(data: cached_instance, rescue_return: session).merge(session)
|
372
375
|
end
|
373
376
|
else
|
374
377
|
return session
|
@@ -33,17 +33,25 @@ module ZuoraConnect
|
|
33
33
|
require 'lograge'
|
34
34
|
logger = ActiveSupport::Logger.new(STDOUT)
|
35
35
|
logger.formatter = ::Logger::Formatter.new
|
36
|
+
# logger.formatter = proc do |severity, datetime, progname, msg|
|
37
|
+
# {severity: severity, time: datetime.strftime('%FT%T.%6N'), process_id: Process.pid, message: msg }.to_json
|
38
|
+
# end
|
36
39
|
Rails.configuration.logger = ActiveSupport::TaggedLogging.new(logger)
|
40
|
+
Rails.configuration.log_tags = [:uuid]
|
37
41
|
Rails.configuration.lograge.enabled = true
|
38
42
|
Rails.configuration.lograge.formatter = Lograge::Formatters::Json.new
|
39
43
|
Rails.configuration.lograge.custom_options = lambda do |event|
|
40
44
|
exceptions = %w(controller action format id)
|
41
|
-
{
|
42
|
-
|
45
|
+
items = {
|
46
|
+
#time: event.time.strftime('%FT%T.%6N'),
|
43
47
|
params: event.payload[:params].except(*exceptions),
|
44
48
|
exception: event.payload[:exception],
|
45
|
-
exception_object: event.payload[:exception_object]
|
49
|
+
exception_object: event.payload[:exception_object],
|
50
|
+
process_id: Process.pid
|
46
51
|
}
|
52
|
+
if Thread.current[:appinstance].present?
|
53
|
+
items.merge({appinstance_id: Thread.current[:appinstance].id, connect_user: Thread.current[:appinstance].connect_user, new_session: Thread.current[:appinstance].new_session_message})
|
54
|
+
end
|
47
55
|
end
|
48
56
|
end
|
49
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.08
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|