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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bcfff804b06ecd1812adc2b4cc52ac50f925329cdfe196b1e734a7ab6f308f8
4
- data.tar.gz: c553b8bdab0ba265e6d81f254c7d7022392a90a01af1bd998a81bdb36948d2b7
3
+ metadata.gz: aa91c7ca59af567024be0ac8cb9d13ffff059fe7c04fb075101609b3fc78fe4f
4
+ data.tar.gz: 8f4e9744ed47825c119e4725c506bf8a55a0dca44d045f49c239e272eed3ea7d
5
5
  SHA512:
6
- metadata.gz: 4e2ac201fb1645f14cc82f3e8dda29640c7b82cbf9ff35b07d82ad898c926d2436694d4eb48fed3f7f528df4a33529e59304978f229e72ce9d469cc0d794b674
7
- data.tar.gz: d6345cf78fe6f606d98d8aadfc0ab9e7ae9f7cfb4b3655fa274e7d74381b2ffb32295896569e13d79357a58254f365b1453cdeab98d543f855709b0072289da7
6
+ metadata.gz: 9a6213cb2348019af23683bfa1847e6f0025dd81269fe0950f6a0217acd15565d74096cbcc536bdd42eea8d214f1a5e8a67f8fd6f5188a09aa5442d8f7a26ac7
7
+ data.tar.gz: 8a502df328aff5498bf191bc6b3ef73ed91c32b1bcdf2b0f9aa1ec14ce8f0aaf9c908284c8e51da61b2ce51c97df43af0461c297dcb1b0b48252aab8b0240cad
@@ -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
@@ -1,6 +1,6 @@
1
1
  module CanvasSync
2
2
  module JobBatches
3
- class BaseJob < ActiveJob::Base
3
+ class BaseJob < ::ActiveJob::Base
4
4
 
5
5
  end
6
6
  end
@@ -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
- if is_activejob_job?(job)
108
- JobBatches::ActiveJob.handle_job_death(job["args"][0], ex)
109
- return
110
- end
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
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.17.36".freeze
2
+ VERSION = "0.17.37".freeze
3
3
  end