panda_pal 5.2.4 → 5.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/initializers/apartment.rb +59 -11
- data/lib/panda_pal/version.rb +1 -1
- 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: dc40f9ca1d3a036a82a30105f8390bfe9faf57519ca977040921999c1e97221c
|
4
|
+
data.tar.gz: 01cca7d9851d83e6d2029291fde3f0baba97c1ba46e51287211b9769f803ae7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f41f229e1d8101ce9de5ba9d97ec3e8a3a96b5a11d5fa7972534df8e1d2226172db2e82c3af17f228cc48b1ceb0f8e71e6ded9ed08308c9124a45365e89cf8fa
|
7
|
+
data.tar.gz: 29dbfab39a1b5445d31975306af414e336f0a3965c2fd5426e90335963d4da50238c69c7232a66248ad4f7524b7fd3444fc01d2a535ba4e1414aa2f02267b1bc
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'apartment/elevators/generic'
|
2
2
|
|
3
3
|
Apartment.configure do |config|
|
4
|
-
config.excluded_models
|
4
|
+
config.excluded_models ||= []
|
5
|
+
config.excluded_models |= ['PandaPal::Organization', 'PandaPal::Session']
|
5
6
|
|
6
7
|
config.tenant_names = lambda {
|
7
8
|
PandaPal::Organization.pluck(:name)
|
@@ -14,6 +15,21 @@ Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda {
|
|
14
15
|
end
|
15
16
|
}
|
16
17
|
|
18
|
+
module PandaPal::Plugins::ApartmentCache
|
19
|
+
private
|
20
|
+
|
21
|
+
if Rails.version >= '5.0'
|
22
|
+
def normalize_key(key, options)
|
23
|
+
"tenant:#{Apartment::Tenant.current}/#{super}"
|
24
|
+
end
|
25
|
+
else
|
26
|
+
def namespaced_key(*args)
|
27
|
+
"tenant:#{Apartment::Tenant.current}/#{super}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
ActiveSupport::Cache::Store.send(:prepend, PandaPal::Plugins::ApartmentCache)
|
32
|
+
|
17
33
|
if defined?(ActionCable)
|
18
34
|
module ActionCable
|
19
35
|
module Channel
|
@@ -38,7 +54,7 @@ if defined?(ActionCable)
|
|
38
54
|
end
|
39
55
|
end
|
40
56
|
|
41
|
-
module ActionCableApartment
|
57
|
+
module PandaPal::Plugins::ActionCableApartment
|
42
58
|
module Connection
|
43
59
|
def tenant=(name)
|
44
60
|
@tenant = name
|
@@ -56,18 +72,50 @@ if defined?(ActionCable)
|
|
56
72
|
end
|
57
73
|
end
|
58
74
|
|
59
|
-
ActionCable::Connection::Base.prepend(ActionCableApartment::Connection)
|
75
|
+
ActionCable::Connection::Base.prepend(PandaPal::Plugins::ActionCableApartment::Connection)
|
60
76
|
end
|
61
77
|
|
62
|
-
|
63
|
-
|
78
|
+
if defined?(Delayed)
|
79
|
+
module PandaPal::Plugins
|
80
|
+
class ApartmentDelayedJobsPlugin < ::Delayed::Plugin
|
81
|
+
callbacks do |lifecycle|
|
82
|
+
lifecycle.around(:enqueue) do |job, *args, &block|
|
83
|
+
current_tenant = Apartment::Tenant.current
|
64
84
|
|
65
|
-
|
66
|
-
|
67
|
-
|
85
|
+
#make sure enqueue on public tenant unless we are testing since delayed job is set to run immediately
|
86
|
+
Apartment::Tenant.switch!('public') unless Rails.env.test?
|
87
|
+
job.tenant = current_tenant
|
88
|
+
begin
|
89
|
+
block.call(job, *args)
|
90
|
+
rescue Exception => e
|
91
|
+
Rails.logger.error("Error enqueing job #{job.to_s} - #{e.backtrace}")
|
92
|
+
ensure
|
93
|
+
#switch back to prev tenant
|
94
|
+
Apartment::Tenant.switch!(current_tenant)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
lifecycle.before(:perform) do |worker, *args, &block|
|
99
|
+
tenant = args.first.tenant
|
100
|
+
Apartment::Tenant.switch!(tenant) if tenant.present?
|
101
|
+
Rails.logger.debug("Running job with tenant #{Apartment::Tenant.current}")
|
102
|
+
end
|
103
|
+
|
104
|
+
lifecycle.around(:invoke_job) do |job, *args, &block|
|
105
|
+
begin
|
106
|
+
block.call(job, *args)
|
107
|
+
ensure
|
108
|
+
Apartment::Tenant.switch!('public')
|
109
|
+
Rails.logger.debug("Resetting Tenant back to: #{Apartment::Tenant.current}")
|
110
|
+
end
|
111
|
+
end
|
68
112
|
|
69
|
-
|
70
|
-
|
113
|
+
lifecycle.after(:failure) do |job, *args|
|
114
|
+
Rails.logger.error("Job failed on tenant: #{Apartment::Tenant.current}")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
71
118
|
end
|
119
|
+
|
120
|
+
Delayed::Worker.plugins << PandaPal::Plugins::ApartmentDelayedJobsPlugin
|
72
121
|
end
|
73
|
-
ActiveSupport::Cache::Store.send :prepend, ApartmentCache
|
data/lib/panda_pal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panda_pal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure ProServe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|