ekylibre-plugin_system 0.4.0 → 0.5.0
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 +4 -4
- data/ekylibre-plugin_system.gemspec +0 -1
- data/lib/ekylibre-plugin_system.rb +0 -2
- data/lib/ekylibre/plugin_system/console_helper.rb +4 -1
- data/lib/ekylibre/plugin_system/middleware/sidekiq_middleware.rb +36 -13
- data/lib/ekylibre/plugin_system/middleware/sidekiq_middleware/client_middleware.rb +28 -0
- data/lib/ekylibre/plugin_system/middleware/sidekiq_middleware/server_middleware.rb +33 -0
- data/lib/ekylibre/plugin_system/rails/railtie.rb +1 -10
- data/lib/ekylibre/plugin_system/sugar/rights.rb +10 -3
- data/lib/ekylibre/plugin_system/version.rb +1 -1
- metadata +8 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e67301a6ea670850bd6794f51d287fabb277f209fbbf5983d3e29540de7fefb4
|
4
|
+
data.tar.gz: 5fe4b34bdad1085b5484ba7ebf809466005ca01343634aa5942596e9bf7d0d18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81ff8b3f60e94fca1a5ecf30ad0ebdd39c946af640ec6ab15e578a72fc881d2096bdcc7f96d2dc531111e5f83e57a04abdd0c9cfef61753e9fd1a63b512631b9
|
7
|
+
data.tar.gz: 38521c74d7ef72588fe61d8b0e7d27f04260c2d964e2b36c5715052e2c8ebf8f7d741608f44376ecfa2b0c5ea832391982b14f9197cd2791c7063319497901fc
|
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'corindon', '~> 0.7.0'
|
23
23
|
spec.add_dependency 'railties', '> 4'
|
24
24
|
spec.add_dependency 'request_store', '~> 1.5.0'
|
25
|
-
spec.add_dependency 'request_store-sidekiq', '~> 0.1.0'
|
26
25
|
spec.add_dependency 'zeitwerk', '~> 2.4'
|
27
26
|
|
28
27
|
spec.add_development_dependency 'bundler', '>= 1.17'
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'corindon'
|
4
4
|
require 'request_store'
|
5
|
-
require 'request_store/sidekiq'
|
6
5
|
require 'zeitwerk'
|
7
6
|
|
8
7
|
module Ekylibre # :nodoc:
|
@@ -12,7 +11,6 @@ end
|
|
12
11
|
loader = Zeitwerk::Loader.for_gem
|
13
12
|
loader.ignore(__FILE__)
|
14
13
|
loader.ignore("#{__dir__}/plugin_system/rails/**/*.rb")
|
15
|
-
loader.ignore("#{__dir__}/plugin_system/multi_tenancy/railtie.rb")
|
16
14
|
loader.setup
|
17
15
|
|
18
16
|
require_relative 'ekylibre/plugin_system/rails/railtie' if defined?(::Rails)
|
@@ -3,22 +3,45 @@
|
|
3
3
|
module Ekylibre
|
4
4
|
module PluginSystem
|
5
5
|
module Middleware
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
module SidekiqMiddleware
|
7
|
+
class << self
|
8
|
+
# This method sets up sidekiq middlewares allowing to access the container natively inside jobs.
|
9
|
+
#
|
10
|
+
# In addition, it also stores the job's container inside RequestStore so that
|
11
|
+
# the legacy code of Ekylibre can globally access the container when needed.
|
12
|
+
#
|
13
|
+
# The client middleware is called when a job is enqueued, the server middleware when the job is executed.
|
14
|
+
#
|
15
|
+
def setup(container:)
|
16
|
+
::Sidekiq.configure_client do |config|
|
17
|
+
configure_client(config, container: container)
|
18
|
+
end
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
item['container'] = container
|
20
|
+
::Sidekiq.configure_server do |config|
|
21
|
+
configure_client(config, container: container)
|
15
22
|
|
16
|
-
|
17
|
-
|
23
|
+
configure_server(config, container: container)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
29
|
+
def configure_client(config, container:)
|
30
|
+
config.client_middleware do |chain|
|
31
|
+
chain.add ClientMiddleware, container
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def configure_server(config, container:)
|
36
|
+
config.server_middleware do |chain|
|
37
|
+
if defined?(::Sidekiq::Batch::Server)
|
38
|
+
chain.insert_before ::Sidekiq::Batch::Server, ServerMiddleware, container
|
39
|
+
else
|
40
|
+
chain.add ServerMiddleware, container
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
22
45
|
end
|
23
46
|
end
|
24
47
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ekylibre
|
4
|
+
module PluginSystem
|
5
|
+
module Middleware
|
6
|
+
# Sidekiq client middleware adding the provided container to the job context
|
7
|
+
# so that all other middlewares can access it for configuring newly enqueued jobs.
|
8
|
+
module SidekiqMiddleware
|
9
|
+
class ClientMiddleware
|
10
|
+
def initialize(container)
|
11
|
+
@container = container
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(worker_class, item, queue, redis_pool = nil)
|
15
|
+
item['container'] = container
|
16
|
+
|
17
|
+
yield
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# @return [Corindon::DependencyInjection::Container]
|
23
|
+
attr_reader :container
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ekylibre
|
4
|
+
module PluginSystem
|
5
|
+
module Middleware
|
6
|
+
# Sidekiq server middleware adding the provided container to the job context.
|
7
|
+
# It also makes the container accessible through RequestStore for the legacy code to be able to access it globally.
|
8
|
+
module SidekiqMiddleware
|
9
|
+
class ServerMiddleware
|
10
|
+
def initialize(container)
|
11
|
+
@container = container
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(_worker_class, item, _queue)
|
15
|
+
RequestStore['container'] = container
|
16
|
+
item['container'] = container
|
17
|
+
|
18
|
+
yield
|
19
|
+
ensure
|
20
|
+
# We want to have the same behavior as the request_store-sidekiq gem.
|
21
|
+
# However, we want to insert our middleware BEFORE the Batch middleware.
|
22
|
+
RequestStore.clear!
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# @return [Corindon::DependencyInjection::Container]
|
28
|
+
attr_reader :container
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -14,20 +14,11 @@ module Ekylibre
|
|
14
14
|
end
|
15
15
|
|
16
16
|
initializer(:register_middleware, after: :engines_blank_point) do |app|
|
17
|
-
# app.config.middleware.insert_after(apartment_middleware, Ekylibre::PluginSystem::Middleware::RackMiddleware, app.system.container)
|
18
17
|
app.config.middleware.use(Middleware::RackMiddleware, app.system.container)
|
19
18
|
end
|
20
19
|
|
21
20
|
initializer(:register_sidekiq_middleware, after: :engines_blank_point) do |app|
|
22
|
-
::
|
23
|
-
config.server_middleware do |chain|
|
24
|
-
if defined?(::Sidekiq::Batch::Server)
|
25
|
-
chain.insert_before ::Sidekiq::Batch::Server, Middleware::SidekiqMiddleware, app.system.container
|
26
|
-
else
|
27
|
-
chain.add Middleware::SidekiqMiddleware, app.system.container
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
21
|
+
Middleware::SidekiqMiddleware.setup(container: app.system.container)
|
31
22
|
end
|
32
23
|
|
33
24
|
# rubocop:disable Lint/Debugger
|
@@ -9,10 +9,17 @@ module Ekylibre
|
|
9
9
|
using Corindon::DependencyInjection::Injectable
|
10
10
|
|
11
11
|
# @param [Corindon::DependencyInjection::Container] container
|
12
|
-
|
12
|
+
# @param [String] origin
|
13
|
+
def register_rights(container:, origin:)
|
14
|
+
root_param = Corindon::DependencyInjection::Token::ValueToken.new(value: engine.root)
|
15
|
+
origin_param = Corindon::DependencyInjection::Token::ValueToken.new(value: origin)
|
16
|
+
|
13
17
|
container.add_definition(
|
14
|
-
self.class.make_definition(
|
15
|
-
|
18
|
+
self.class.make_definition(
|
19
|
+
'rights_loader',
|
20
|
+
Ekylibre::Access::RightsLoader,
|
21
|
+
root: root_param, origin: origin_param
|
22
|
+
) do
|
16
23
|
tag 'ekylibre.access.rights_loader'
|
17
24
|
end
|
18
25
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ekylibre-plugin_system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ekylibre developers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: corindon
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.5.0
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: request_store-sidekiq
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.0
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.0
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: zeitwerk
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +122,7 @@ dependencies:
|
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: 1.3.0
|
139
|
-
description:
|
125
|
+
description:
|
140
126
|
email:
|
141
127
|
- dev@ekylibre.com
|
142
128
|
executables: []
|
@@ -149,6 +135,8 @@ files:
|
|
149
135
|
- lib/ekylibre/plugin_system/controller_mixin.rb
|
150
136
|
- lib/ekylibre/plugin_system/middleware/rack_middleware.rb
|
151
137
|
- lib/ekylibre/plugin_system/middleware/sidekiq_middleware.rb
|
138
|
+
- lib/ekylibre/plugin_system/middleware/sidekiq_middleware/client_middleware.rb
|
139
|
+
- lib/ekylibre/plugin_system/middleware/sidekiq_middleware/server_middleware.rb
|
152
140
|
- lib/ekylibre/plugin_system/parameters.rb
|
153
141
|
- lib/ekylibre/plugin_system/plugin.rb
|
154
142
|
- lib/ekylibre/plugin_system/plugin_registration.rb
|
@@ -163,7 +151,7 @@ homepage: https://www.ekylibre.com
|
|
163
151
|
licenses:
|
164
152
|
- AGPL-3.0-only
|
165
153
|
metadata: {}
|
166
|
-
post_install_message:
|
154
|
+
post_install_message:
|
167
155
|
rdoc_options: []
|
168
156
|
require_paths:
|
169
157
|
- lib
|
@@ -179,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
167
|
version: '0'
|
180
168
|
requirements: []
|
181
169
|
rubygems_version: 3.0.3
|
182
|
-
signing_key:
|
170
|
+
signing_key:
|
183
171
|
specification_version: 4
|
184
172
|
summary: Plugin system for Rails built around a Dependency Injection Container
|
185
173
|
test_files: []
|