canvas_sync 0.17.36 → 0.17.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canvas_sync/engine.rb +6 -0
- data/lib/canvas_sync/job_batches/jobs/base_job.rb +1 -1
- data/lib/canvas_sync/job_batches/jobs/managed_batch_job.rb +2 -2
- data/lib/canvas_sync/job_batches/pool.rb +2 -2
- data/lib/canvas_sync/job_batches/sidekiq.rb +15 -12
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/dummy/log/test.log +10852 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa91c7ca59af567024be0ac8cb9d13ffff059fe7c04fb075101609b3fc78fe4f
|
4
|
+
data.tar.gz: 8f4e9744ed47825c119e4725c506bf8a55a0dca44d045f49c239e272eed3ea7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a6213cb2348019af23683bfa1847e6f0025dd81269fe0950f6a0217acd15565d74096cbcc536bdd42eea8d214f1a5e8a67f8fd6f5188a09aa5442d8f7a26ac7
|
7
|
+
data.tar.gz: 8a502df328aff5498bf191bc6b3ef73ed91c32b1bcdf2b0f9aa1ec14ce8f0aaf9c908284c8e51da61b2ce51c97df43af0461c297dcb1b0b48252aab8b0240cad
|
data/lib/canvas_sync/engine.rb
CHANGED
@@ -5,6 +5,12 @@ module CanvasSync
|
|
5
5
|
class Engine < ::Rails::Engine
|
6
6
|
isolate_namespace CanvasSync
|
7
7
|
|
8
|
+
initializer "canvas_sync.serialze_symbols" do |app|
|
9
|
+
app.config.active_record.yaml_column_permitted_classes ||= []
|
10
|
+
app.config.active_record.yaml_column_permitted_classes |= [Symbol]
|
11
|
+
rescue
|
12
|
+
end
|
13
|
+
|
8
14
|
initializer :append_migrations do |app|
|
9
15
|
config.paths["db/migrate"].expanded.each do |expanded_path|
|
10
16
|
app.config.paths["db/migrate"] << expanded_path
|
@@ -26,7 +26,7 @@ module CanvasSync
|
|
26
26
|
|
27
27
|
mapped_sub_jobs = sub_jobs.each_with_index.map do |j, i|
|
28
28
|
j['_mngbid_index_'] = i # This allows duplicate jobs when a Redis Set is used
|
29
|
-
j = ActiveJob::Arguments.serialize([j])
|
29
|
+
j = ::ActiveJob::Arguments.serialize([j])
|
30
30
|
JSON.unparse(j)
|
31
31
|
end
|
32
32
|
if ordered
|
@@ -104,7 +104,7 @@ module CanvasSync
|
|
104
104
|
return unless next_job_json.present?
|
105
105
|
|
106
106
|
next_job = JSON.parse(next_job_json)
|
107
|
-
next_job = ActiveJob::Arguments.deserialize(next_job)[0]
|
107
|
+
next_job = ::ActiveJob::Arguments.deserialize(next_job)[0]
|
108
108
|
|
109
109
|
Batch.new(root_bid).jobs do
|
110
110
|
Batch.new.tap do |batch|
|
@@ -171,7 +171,7 @@ module CanvasSync
|
|
171
171
|
jobs_key = "#{redis_key}-jobs"
|
172
172
|
# This allows duplicate jobs when a Redis Set is used
|
173
173
|
job_desc[:_pool_random_key_] = SecureRandom.urlsafe_base64(10)
|
174
|
-
job_json = JSON.unparse(ActiveJob::Arguments.serialize([job_desc]))
|
174
|
+
job_json = JSON.unparse(::ActiveJob::Arguments.serialize([job_desc]))
|
175
175
|
order = self.order
|
176
176
|
|
177
177
|
redis.multi do |r|
|
@@ -204,7 +204,7 @@ module CanvasSync
|
|
204
204
|
|
205
205
|
return nil unless job_json.present?
|
206
206
|
|
207
|
-
ActiveJob::Arguments.deserialize(JSON.parse(job_json))[0]&.symbolize_keys
|
207
|
+
::ActiveJob::Arguments.deserialize(JSON.parse(job_json))[0]&.symbolize_keys
|
208
208
|
end
|
209
209
|
|
210
210
|
def self.redis(&blk)
|
@@ -76,11 +76,21 @@ module CanvasSync
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def self.is_activejob_job?(msg)
|
79
|
-
return false unless defined?(ActiveJob)
|
79
|
+
return false unless defined?(::ActiveJob)
|
80
80
|
|
81
81
|
msg['class'] == 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper' && (msg['wrapped'].to_s).constantize < JobBatches::ActiveJob::BatchAwareJob
|
82
82
|
end
|
83
83
|
|
84
|
+
def self.switch_tenant(job)
|
85
|
+
if defined?(::Apartment)
|
86
|
+
::Apartment::Tenant.switch(job['apartment'] || 'public') do
|
87
|
+
yield
|
88
|
+
end
|
89
|
+
else
|
90
|
+
yield
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
84
94
|
def self.configure
|
85
95
|
if defined?(::Sidekiq::Batch) && ::Sidekiq::Batch != JobBatches::Batch
|
86
96
|
print "WARNING: Detected Sidekiq Pro or sidekiq-batch. CanvasSync JobBatches may not be fully compatible!"
|
@@ -104,19 +114,12 @@ module CanvasSync
|
|
104
114
|
end
|
105
115
|
|
106
116
|
config.death_handlers << ->(job, ex) do
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
return unless job['bid'].present?
|
113
|
-
|
114
|
-
if defined?(::Apartment)
|
115
|
-
::Apartment::Tenant.switch(job['apartment'] || 'public') do
|
117
|
+
switch_tenant(job) do
|
118
|
+
if is_activejob_job?(job)
|
119
|
+
JobBatches::ActiveJob.handle_job_death(job["args"][0], ex)
|
120
|
+
elsif job['bid'].present?
|
116
121
|
::Sidekiq::Batch.process_dead_job(job['bid'], job['jid'])
|
117
122
|
end
|
118
|
-
else
|
119
|
-
::Sidekiq::Batch.process_dead_job(job['bid'], job['jid'])
|
120
123
|
end
|
121
124
|
end
|
122
125
|
end
|
data/lib/canvas_sync/version.rb
CHANGED